I added the “def get_api_battery_data_value …” section to the coordinator
Not having much luck getting it going, getting the following error in the HA logs any ideas?
Error while setting up platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 365, in _async_setup_platform
await asyncio.shield(awaitable)
File "/config/custom_components/iBMS/sensor.py", line 57, in async_setup_entry
for battery_sensor in [battery for battery in coordinator.data["batteries"]]
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'batteries'
After having relooked at this and the data you have, and thinking how best to make it easy for you to adjust and change, I have refactored it quite a lot to allow you to define your sensors in const.py.
I have created an EXPLANAITION.md file to hopefully give you some idea of how it owrks and how to use it.
I have also transferred some of your entities into the new way of doing it but not all as, frankly I didn’t understand what needed to go where as I couldn’t match it to the data sample you gave me.
Have a look at it, ask me any questions you don’t understand and see if this is a better way for you to manage it.
Let me know.
Mark
EDIT: Sorry should add that I created it as a branch on your github repo