@@ -77,7 +77,8 @@ async def handle_battery_replaced(call: ServiceCall) -> ServiceResponse:
7777 config_entry : BatteryNotesConfigEntry
7878 for config_entry in hass .config_entries .async_loaded_entries (DOMAIN ):
7979 coordinator = config_entry .runtime_data .coordinator
80- if coordinator .source_entity_id == source_entity_id :
80+ assert (coordinator )
81+ if coordinator .source_entity_id and coordinator .source_entity_id == source_entity_id :
8182
8283 coordinator .last_replaced = datetime_replaced
8384 await coordinator .async_request_refresh ()
@@ -120,9 +121,9 @@ async def handle_battery_replaced(call: ServiceCall) -> ServiceResponse:
120121 )
121122 return None
122123
123- config_entry : BatteryNotesConfigEntry
124124 for config_entry in hass .config_entries .async_loaded_entries (DOMAIN ):
125125 coordinator = config_entry .runtime_data .coordinator
126+ assert (coordinator )
126127 if coordinator .device_id == device_id :
127128 coordinator .last_replaced = datetime_replaced
128129 await coordinator .async_request_refresh ()
@@ -168,6 +169,7 @@ async def handle_battery_last_reported(call: ServiceCall) -> ServiceResponse:
168169 config_entry : BatteryNotesConfigEntry
169170 for config_entry in hass .config_entries .async_loaded_entries (DOMAIN ):
170171 coordinator = config_entry .runtime_data .coordinator
172+ assert (coordinator )
171173
172174 if coordinator .wrapped_battery and coordinator .last_reported :
173175 time_since_lastreported = (
@@ -206,6 +208,7 @@ async def handle_battery_low(call: ServiceCall) -> ServiceResponse:
206208 config_entry : BatteryNotesConfigEntry
207209 for config_entry in hass .config_entries .async_loaded_entries (DOMAIN ):
208210 coordinator = config_entry .runtime_data .coordinator
211+ assert (coordinator )
209212
210213 if coordinator .battery_low is True :
211214 hass .bus .async_fire (
0 commit comments