Skip to content

Commit

Permalink
Added support for illuminance level of motion detector.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschamm committed Feb 18, 2023
1 parent 4f7a1bd commit 5c073db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/bosch_shc/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://github.com/tschamm/boschshc-hass/blob/master/README.md",
"requirements": ["boschshcpy==0.2.56"],
"version": "0.4.47",
"version": "0.4.48",
"zeroconf": [{ "type": "_http._tcp.local.", "name": "bosch shc*" }],
"iot_class": "local_push",
"issue_tracker": "https://github.com/tschamm/boschshc-hass/issues",
Expand Down
27 changes: 27 additions & 0 deletions custom_components/bosch_shc/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ async def async_setup_entry(
)
)

for sensor in session.device_helper.motion_detectors:
entities.append(
IlluminanceLevelSensor(
device=sensor,
parent_id=session.information.unique_id,
entry_id=config_entry.entry_id,
)
)

if entities:
async_add_entities(entities)

Expand Down Expand Up @@ -454,3 +463,21 @@ def extra_state_attributes(self):
return {
"valve_tappet_state": self._device.valvestate.name,
}


class IlluminanceLevelSensor(SHCEntity, SensorEntity):
"""Representation of an SHC illuminance level reporting sensor."""

_attr_state_class = SensorStateClass.MEASUREMENT
_attr_entity_category = EntityCategory.DIAGNOSTIC

def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
"""Initialize an SHC illuminance level reporting sensor."""
super().__init__(device, parent_id, entry_id)
self._attr_name = f"{device.name} Illuminance"
self._attr_unique_id = f"{device.root_device_id}_{device.id}_illuminance"

@property
def native_value(self):
"""Return the state of the sensor."""
return self._device.illuminance

0 comments on commit 5c073db

Please sign in to comment.