Skip to content

Commit

Permalink
Use binary_sensor_schema (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Oct 21, 2024
1 parent dcf7834 commit bbf7c92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
19 changes: 5 additions & 14 deletions components/soyosource_display/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import esphome.codegen as cg
from esphome.components import binary_sensor
import esphome.config_validation as cv
from esphome.const import CONF_ICON, CONF_ID
from esphome.const import CONF_ID

from . import CONF_SOYOSOURCE_DISPLAY_ID, SoyosourceDisplay

Expand All @@ -12,9 +12,6 @@
CONF_FAN_RUNNING = "fan_running"
CONF_LIMITER_CONNECTED = "limiter_connected"

ICON_FAN_RUNNING = "mdi:fan"
ICON_LIMITER_CONNECTED = "mdi:connection"

BINARY_SENSORS = [
CONF_FAN_RUNNING,
CONF_LIMITER_CONNECTED,
Expand All @@ -23,17 +20,11 @@
CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_SOYOSOURCE_DISPLAY_ID): cv.use_id(SoyosourceDisplay),
cv.Optional(CONF_FAN_RUNNING): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(binary_sensor.BinarySensor),
cv.Optional(CONF_ICON, default=ICON_FAN_RUNNING): cv.icon,
}
cv.Optional(CONF_FAN_RUNNING): binary_sensor.binary_sensor_schema(
icon="mdi:fan"
),
cv.Optional(CONF_LIMITER_CONNECTED): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(binary_sensor.BinarySensor),
cv.Optional(CONF_ICON, default=ICON_LIMITER_CONNECTED): cv.icon,
}
cv.Optional(CONF_LIMITER_CONNECTED): binary_sensor.binary_sensor_schema(
icon="mdi:connection"
),
}
)
Expand Down
11 changes: 3 additions & 8 deletions components/soyosource_inverter/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import esphome.codegen as cg
from esphome.components import binary_sensor
import esphome.config_validation as cv
from esphome.const import CONF_ICON, CONF_ID
from esphome.const import CONF_ID

from . import CONF_SOYOSOURCE_INVERTER_ID, SoyosourceInverter

Expand All @@ -11,20 +11,15 @@

CONF_FAN_RUNNING = "fan_running"

ICON_FAN_RUNNING = "mdi:fan"

BINARY_SENSORS = [
CONF_FAN_RUNNING,
]

CONFIG_SCHEMA = cv.Schema(
{
cv.GenerateID(CONF_SOYOSOURCE_INVERTER_ID): cv.use_id(SoyosourceInverter),
cv.Optional(CONF_FAN_RUNNING): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(binary_sensor.BinarySensor),
cv.Optional(CONF_ICON, default=ICON_FAN_RUNNING): cv.icon,
}
cv.Optional(CONF_FAN_RUNNING): binary_sensor.binary_sensor_schema(
icon="mdi:fan"
),
}
)
Expand Down

0 comments on commit bbf7c92

Please sign in to comment.