Skip to content

Commit

Permalink
disable sensor restore for the time being because of to many issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Roeland authored and Roeland committed Aug 31, 2024
1 parent abfb5a0 commit 0c4249b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/entsoe/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ async def async_step_init(
): TemplateSelector(TemplateSelectorConfig()),
vol.Optional(
CONF_CURRENCY,
default=self.config_entry.options[CONF_CURRENCY],
default=self.config_entry.options.get(CONF_CURRENCY, DEFAULT_CURRENCY)
): vol.All(vol.Coerce(str)),
vol.Optional(
CONF_CALCULATION_MODE,
Expand Down
13 changes: 7 additions & 6 deletions custom_components/entsoe/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ def __init__(self, coordinator: EntsoeCoordinator, description: EntsoeEntityDesc
async def async_added_to_hass(self):
"""Handle entity which will be added."""
await super().async_added_to_hass()
if (last_sensor_data := await self.async_get_last_sensor_data()) is not None:
# new introduced in 2022.04
if last_sensor_data.native_value is not None:
self._attr_native_value = last_sensor_data.native_value
if last_sensor_data._attr_extra_state_attributes is not None:
self._attr_extra_state_attributes = dict(last_sensor_data._attr_extra_state_attributes)
# if (last_sensor_data := await self.async_get_last_sensor_data()) is not None:
# # new introduced in 2022.04
# if last_sensor_data.native_value is not None:
# self._attr_native_value = last_sensor_data.native_value
# if last_sensor_data._attr_extra_state_attributes is not None:
# self._attr_extra_state_attributes = dict(last_sensor_data._attr_extra_state_attributes)

async def async_update(self) -> None:
"""Get the latest data and updates the states."""
Expand All @@ -197,6 +197,7 @@ async def async_update(self) -> None:
value = value.to_pydatetime()

self._attr_native_value = value
_LOGGER.debug(f"updated '{self.entity_id}' to value: {value}")
except Exception as exc:
# No data available
_LOGGER.warning(f"Unable to update entity '{self.entity_id}' due to data processing error: {value} and error: {exc} , data: {self.coordinator.data}")
Expand Down

0 comments on commit 0c4249b

Please sign in to comment.