ha-myenergi
ha-myenergi copied to clipboard
Operating mode unavailable on Libbi/Zappi
I've had my Libbi & Zappi for a couple of months now and have setup some automations with my Octopus Intelligent Go tarif to prevent the Libbi supplying the house when the extra off-peak charging hours are active.
After a few weeks the Libbi 'operating mode' became unavailable. I was unable to see or set this mode directly although the automations setup seem to still trigger this correctly strangely.
More recently the Zappi 'operating mode' has also become unavailable
Any ideas as to why, and how they can be fixed (ideally without breaking any existing automations)
Oh, I’ve just seen this in the logs. Hope this helps
This error originated from a custom integration.
Logger: homeassistant
Source: custom_components/myenergi/select.py:174
integration: myenergi (documentation, issues)
First occurred: 15:44:01 (54 occurrences)
Last logged: 16:37:13
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
await self._async_refresh(log_failures=True, scheduled=True)
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
self.async_update_listeners()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
update_callback()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 494, in _handle_coordinator_update
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1056, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1004, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/select/__init__.py", line 152, in state
current_option = self.current_option
^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/myenergi/select.py", line 174, in current_option
return LIBBI_MODE_NAMES[mode]
~~~~~~~~~~~~~~~~^^^^^^
KeyError: 'BALANCE'
I have the same issue and error in the log file. I have HA-Myenergi 0.0.27 installed
Core 2024.4.3 Supervisor 2024.04.0 Operating System 12.2 Frontend 20240404.2
Firstly i am not a programmer but I do have a basic understanding of Python.
The issue seems to be at File "/config/custom_components/myenergi/select.py", line 174,
@property
def current_option(self):
"""Return the state of the sensor."""
mode = self.device.local_mode
return LIBBI_MODE_NAMES[mode]
LIBBI_MODE_NAMES = {0: "Stopped", 1: "Normal", 5: "Export"}
but I think mode is using the API returned names which are STOP, BALANCE and DRAIN and hence the key error. should it be using mode_int?
LIBBI_MODE_CONFIG = { "Stopped": {"mode_int": 0, "mode_name": "STOP"}, "Normal": {"mode_int": 1, "mode_name": "BALANCE"}, "Export": {"mode_int": 5, "mode_name": "DRAIN"},
I fixed this by changing select.py line 12 to
LIBBI_MODE_NAMES = {"STOP" : "Stopped", "BALANCE" : "Normal", "DRAIN" : "Export"}
This will need to be fixed in the next build
I have had the same issue for a few weeks and I can confirm that the fix worked for me too.
Can you retest with the latest version of this integration, BALANCE is now a key, see https://github.com/CJNE/ha-myenergi/blob/de5a7bef0e9448381d9dd780d4d94e4432597bbc/custom_components/myenergi/select.py#L13
Yes, all resolved now