Skip to content

Commit

Permalink
fix for changed init-procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
marq24 committed Jun 6, 2024
1 parent fb29e41 commit 9fce194
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion custom_components/tibber_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
session = async_get_clientsession(hass)

coordinator = TibberLocalDataUpdateCoordinator(hass, session, config_entry)
await coordinator.async_refresh()
await coordinator.init_on_load()

if not coordinator.last_update_success:
raise ConfigEntryNotReady
Expand Down Expand Up @@ -113,6 +113,13 @@ def __init__(self, hass: HomeAssistant, session, config_entry):
# _LOGGER.warning(str(evt))
# return True

async def init_on_load(self):
try:
await self.bridge.update()
_LOGGER.info(f"after init - found OBIS entries: '{self.bridge._obis_values}'")
except Exception as exception:
_LOGGER.warning(f"init caused {exception}")

async def _async_update_data(self):
try:
await self.bridge.update()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/tibber_local/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/marq24/ha-tibber-pulse-local/issues",
"requirements": ["smllib==1.4"],
"version": "2024.6.0"
"version": "2024.6.1"
}
3 changes: 2 additions & 1 deletion custom_components/tibber_local/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities):
coordinator = hass.data[DOMAIN][config_entry.entry_id]
entities = []

available_sensors = None
if hasattr(coordinator, 'bridge' ):
if hasattr(coordinator.bridge, '_obis_values'):
if len(coordinator.bridge._obis_values) > 0:
available_sensors = coordinator.bridge._obis_values.keys()
_LOGGER.info(f"available sensors found: {available_sensors}")
else:
_LOGGER.warning(f"no sensors found @ bridge")

if available_sensors is None or len(available_sensors) == 0:
_LOGGER.warning(f"could not detect available sensors (obis-codes) using just 'import total' and 'power current' as default!")
Expand Down

0 comments on commit 9fce194

Please sign in to comment.