File tree Expand file tree Collapse file tree
custom_components/homeduino Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ async def async_setup_entry(
9898 device_class = device_class ,
9999 id = id ,
100100 unit = unit ,
101+ inverted = protocol .startswith ("contact" ),
101102 )
102103
103104 entities .append (
@@ -132,6 +133,7 @@ class HomeduinoRFBinarySensorEntityDescription(
132133 id : int
133134 unit : int | None
134135 field : str | None = None
136+ inverted : bool = False
135137
136138
137139class HomeduinoTransceiverBinarySensor (CoordinatorEntity , BinarySensorEntity ):
@@ -239,10 +241,15 @@ def _handle_coordinator_update(self) -> None:
239241
240242 _LOGGER .debug (self .coordinator .data )
241243
242- self . _attr_is_on = self .coordinator .data .get ("values" , {}).get (
244+ is_on = self .coordinator .data .get ("values" , {}).get (
243245 self .entity_description .field
244246 if self .entity_description .field
245247 else "state"
246248 )
247249
250+ if self .entity_description .inverted :
251+ is_on = not is_on
252+
253+ self ._attr_is_on = is_on
254+
248255 self .async_write_ha_state ()
You can’t perform that action at this time.
0 commit comments