Skip to content

Commit

Permalink
binary class windows probably missing to sensor working
Browse files Browse the repository at this point in the history
  • Loading branch information
slajob committed Mar 5, 2024
1 parent c053657 commit ef8eab0
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions custom_components/dirigera_platform/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import dirigera

from homeassistant import config_entries, core
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.const import CONF_IP_ADDRESS, CONF_TOKEN
from homeassistant.core import HomeAssistantError
from homeassistant.helpers.entity import DeviceInfo
Expand Down Expand Up @@ -117,6 +120,28 @@ def __init__(self, hub, json_data):
self._hub = hub
self._json_data = json_data

@property
def device_info(self) -> DeviceInfo:
return DeviceInfo(
identifiers={("dirigera_platform", self._json_data.id)},
name=self._json_data.attributes.custom_name,
manufacturer=self._json_data.attributes.manufacturer,
model=self._json_data.attributes.model,
sw_version=self._json_data.attributes.firmware_version,
)

@property
def device_class(self) -> str:
return BinarySensorDeviceClass.WINDOW

@property
def name(self):
return self._json_data.attributes.custom_name

@property
def is_on(self):
return self._json_data.attributes.is_open

def update(self):
logger.debug("open close sensor update...")
try:
Expand All @@ -125,6 +150,3 @@ def update(self):
logger.error("error encountered running update on : {}".format(self.name))
logger.error(ex)
raise HomeAssistantError(ex, DOMAIN, "hub_exception")

def is_on(self):
return self._json_data.attributes.is_open

0 comments on commit ef8eab0

Please sign in to comment.