Skip to content

Commit

Permalink
Merge pull request #6 from jbramburek/ha
Browse files Browse the repository at this point in the history
Updated binary_sensor
  • Loading branch information
wasilukm authored Sep 25, 2024
2 parents 9ecb8ac + c6138e2 commit b5650d0
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions custom_components/satel_integra/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def async_setup_platform(
zone_type = device_config_data[CONF_ZONE_TYPE]
zone_name = device_config_data[CONF_ZONE_NAME]
device = SatelIntegraBinarySensor(
controller, zone_num, zone_name, zone_type, SIGNAL_ZONES_UPDATED
controller, zone_num, zone_name, zone_type, CONF_ZONES, SIGNAL_ZONES_UPDATED
)
devices.append(device)

Expand All @@ -50,7 +50,12 @@ async def async_setup_platform(
zone_type = device_config_data[CONF_ZONE_TYPE]
zone_name = device_config_data[CONF_ZONE_NAME]
device = SatelIntegraBinarySensor(
controller, zone_num, zone_name, zone_type, SIGNAL_OUTPUTS_UPDATED
controller,
zone_num,
zone_name,
zone_type,
CONF_OUTPUTS,
SIGNAL_OUTPUTS_UPDATED,
)
devices.append(device)

Expand All @@ -63,10 +68,17 @@ class SatelIntegraBinarySensor(BinarySensorEntity):
_attr_should_poll = False

def __init__(
self, controller, device_number, device_name, zone_type, react_to_signal
self,
controller,
device_number,
device_name,
zone_type,
sensor_type,
react_to_signal,
):
"""Initialize the binary_sensor."""
self._device_number = device_number
self._attr_unique_id = f"satel_{sensor_type}_{device_number}"
self._name = device_name
self._zone_type = zone_type
self._state = 0
Expand All @@ -80,11 +92,10 @@ async def async_added_to_hass(self) -> None:
self._state = 1
else:
self._state = 0
elif self._device_number in self._satel.violated_zones:
self._state = 1
else:
if self._device_number in self._satel.violated_zones:
self._state = 1
else:
self._state = 0
self._state = 0
self.async_on_remove(
async_dispatcher_connect(
self.hass, self._react_to_signal, self._devices_updated
Expand All @@ -97,10 +108,11 @@ def name(self):
return self._name

@property
def icon(self):
def icon(self) -> str | None:
"""Icon for device by its type."""
if self._zone_type is BinarySensorDeviceClass.SMOKE:
return "mdi:fire"
return None

@property
def is_on(self):
Expand Down

0 comments on commit b5650d0

Please sign in to comment.