Smart plugs are duplicated as Switches and Binary Sensors
Closed this issue · 1 comments
GeoffAtHome commented
If we are saying Smart Plugs should be switches and not Binary Sensors, then Smart Plugs should be filtered out of Binary Sensors. To do this make the following two changes to binary_sensor.py:
Add
GH_TYPE = "Receiver"
to
GH_STATE_ATTR = "outputOnOff"
GH_TYPE = "Receiver"
And change:
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Genius Hub sensor entities."""
if discovery_info is None:
return
broker = hass.data[DOMAIN]["broker"]
switches = [
GeniusBinarySensor(broker, d, GH_STATE_ATTR)
for d in broker.client.device_objs
if GH_STATE_ATTR in d.data["state"]
]
async_add_entities(switches, update_before_add=True)
to
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up the Genius Hub sensor entities."""
if discovery_info is None:
return
broker = hass.data[DOMAIN]["broker"]
switches = [
GeniusBinarySensor(broker, d, GH_STATE_ATTR)
for d in broker.client.device_objs
if GH_TYPE in d.data["type"]
]
async_add_entities(switches, update_before_add=True)```
GeoffAtHome commented
Created PR in Home Assistant core to address this.