Skip to content

Commit 201483e

Browse files
committed
Handle opposite order sensor discovery
1 parent 02fd069 commit 201483e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

custom_components/powersensor/sensor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,16 @@ async def handle_discovered_sensor(sensor_mac: str, sensor_role: str):
133133
]
134134
async_add_entities(new_sensors, True)
135135
async_dispatcher_send(hass, SENSOR_ADDED_TO_HA_SIGNAL, sensor_mac, sensor_role)
136-
mains_present = entry.data.get('with_mains', False)
137-
if sensor_role == "solar" and mains_present:
136+
with_mains = entry.data.get('with_mains', False)
137+
with_solar = entry.data.get('with_solar', False)
138+
139+
if sensor_role == "solar" and with_mains:
138140
async_dispatcher_send(hass, HAVE_SOLAR_SENSOR_SIGNAL)
139141

140142
if sensor_role == "house-net":
141143
async_dispatcher_send(hass, HAVE_MAINS_SENSOR_SIGNAL)
144+
if with_solar:
145+
async_dispatcher_send(hass, HAVE_SOLAR_SENSOR_SIGNAL)
142146

143147
entry.async_on_unload(
144148
async_dispatcher_connect(

0 commit comments

Comments
 (0)