From f6180580d922941903699d1a1fc3215936aaba76 Mon Sep 17 00:00:00 2001 From: Stephan Joubert Date: Mon, 18 Apr 2022 12:17:30 +0200 Subject: [PATCH] Fix bug with set-up using config flow. --- custom_components/solarman/sensor.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/custom_components/solarman/sensor.py b/custom_components/solarman/sensor.py index 425371c..3712dea 100644 --- a/custom_components/solarman/sensor.py +++ b/custom_components/solarman/sensor.py @@ -22,7 +22,7 @@ _LOGGER = logging.getLogger(__name__) _inverter_scanner = InverterScanner() -async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): +def _do_setup_platform(hass: HomeAssistant, config, async_add_entities : AddEntitiesCallback): _LOGGER.debug(f'sensor.py:async_setup_platform: {config}') inverter_name = config.get(CONF_NAME) @@ -60,15 +60,20 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= hass_sensors.append(SolarmanStatus(inverter_name, inverter, "status_lastUpdate", inverter_sn)) hass_sensors.append(SolarmanStatus(inverter_name, inverter, "status_connection", inverter_sn)) - _LOGGER.debug(f'sensor.py:async_setup_entry: async_add_entities') + _LOGGER.debug(f'sensor.py:_do_setup_platform: async_add_entities') _LOGGER.debug(hass_sensors) async_add_entities(hass_sensors) + +# Set-up from configuration.yaml +async def async_setup_platform(hass: HomeAssistant, config, async_add_entities : AddEntitiesCallback, discovery_info=None): + _LOGGER.debug(f'sensor.py:async_setup_platform: {config}') + _do_setup_platform(hass, config, async_add_entities) # Set-up from the entries in config-flow async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback): _LOGGER.debug(f'sensor.py:async_setup_entry: {entry.options}') - async_setup_platform(hass, entry.options, async_add_entities) + _do_setup_platform(hass, entry.options, async_add_entities)