martinarva / dynamic_energy_cost

35 stars 9 forks source link

add last energy reading to attributes #27

Closed JannikL87 closed 1 month ago

JannikL87 commented 1 month ago

Fixes the following errors, so dynamic energy cost is no longer broken at startup:

2024-05-26 08:39:24.350 ERROR (MainThread) [homeassistant.components.sensor] Error adding entity sensor.washing_machine_switch_0_daily_energy_cost for domain sensor with platform dynamic_energy_cost Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 892, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1358, in add_to_platform_finish await self.async_added_to_hass() File "/config/custom_components/dynamic_energy_cost/energy_based_sensors.py", line 118, in async_added_to_hass self._last_energy_reading = float(last_state.attributes.get('last_energy'))

martinarva commented 1 month ago

thank you for your contribution @JannikL87