Skip to content

Commit

Permalink
Checks if messwert is present and negative length
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoerk authored and DarwinsBuddy committed Oct 26, 2024
1 parent fb604ba commit ae19f4b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion custom_components/wnsm/live_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async def async_update(self):
reading_dates = [before(today(),1), before(today(),2)]
for reading_date in reading_dates:
meter_readings = await self.get_meter_reading_from_historic_data(smartmeter,reading_date)
if "values" in meter_readings and len(meter_readings['values'])!=0:
if "values" in meter_readings and all("messwert" in messwert for messwert in meter_readings['values']) and len(meter_readings['values'])>0:
self._state = meter_readings['values'][-1]['messwert']/1000
break
else:
Expand Down

0 comments on commit ae19f4b

Please sign in to comment.