diff --git a/custom_components/entsoe/config_flow.py b/custom_components/entsoe/config_flow.py index 2bf3dd7..fc28607 100644 --- a/custom_components/entsoe/config_flow.py +++ b/custom_components/entsoe/config_flow.py @@ -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, diff --git a/custom_components/entsoe/sensor.py b/custom_components/entsoe/sensor.py index 643bfa1..1154edc 100644 --- a/custom_components/entsoe/sensor.py +++ b/custom_components/entsoe/sensor.py @@ -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.""" @@ -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}")