From 03136f254e5e6e3a0417a03c48b99c2a1f5207ff Mon Sep 17 00:00:00 2001 From: Roeland Date: Sat, 31 Aug 2024 16:20:41 +0200 Subject: [PATCH] Fix error on missing currency config entry --- custom_components/entsoe/sensor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/custom_components/entsoe/sensor.py b/custom_components/entsoe/sensor.py index 9c34489..643bfa1 100644 --- a/custom_components/entsoe/sensor.py +++ b/custom_components/entsoe/sensor.py @@ -12,7 +12,6 @@ from homeassistant.components.sensor import DOMAIN, RestoreSensor, SensorDeviceClass, SensorEntityDescription, SensorExtraStoredData, SensorStateClass from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - CONF_CURRENCY, PERCENTAGE, UnitOfEnergy, ) @@ -22,7 +21,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.util import utcnow -from .const import ATTRIBUTION, CONF_COORDINATOR, CONF_ENTITY_NAME, DOMAIN, ICON +from .const import ATTRIBUTION, CONF_COORDINATOR, CONF_ENTITY_NAME, DOMAIN, ICON, DEFAULT_CURRENCY, CONF_CURRENCY from .coordinator import EntsoeCoordinator _LOGGER = logging.getLogger(__name__) @@ -102,7 +101,7 @@ async def async_setup_entry( entities = [] entity = {} - for description in sensor_descriptions(currency = config_entry.options[CONF_CURRENCY]): + for description in sensor_descriptions(currency = config_entry.options.get(CONF_CURRENCY, DEFAULT_CURRENCY)): entity = description entities.append( EntsoeSensor(