Skip to content

Commit

Permalink
Fix bug with set-up using config flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanJoubert committed Apr 18, 2022
1 parent 934ad55 commit f618058
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions custom_components/solarman/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)



Expand Down

0 comments on commit f618058

Please sign in to comment.