dannerph / homeassistant-sunnybeam

GNU Lesser General Public License v3.0
5 stars 1 forks source link

Home Assistant OS Support #4

Open dr-waterstorm opened 3 weeks ago

dr-waterstorm commented 3 weeks ago

I had your Integration running on an older version on my NAS and it did work perfectly fine there. However I had issues with the NAS and I've migrated to a separate installation on a Raspberry PI using Home Assistant OS and I can't figure out how to get it working there.

I have a Sunny Beam with USB and it is detected by the system just fine:

Bus 001 Device 004: ID 1587:002d

However Home Assistant OS does not seem to have /etc/udev/ and if I create the folder it does not get recognized or used in any way. So I have tried this without the udev rule. When adding it in Home Assistant the integration shows me unknown error and the log states:

  File "/config/custom_components/sunnybeam/config_flow.py", line 24, in _async_has_devices
    await s_beam.get_serial_number()
          ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SunnyBeam' object has no attribute 'get_serial_number'

I'm not quite sure how to fix this and I'd be grateful if you could help out and maybe add a few lines to the readme how to use this on Home Assistant OS.

Thank you!

dr-waterstorm commented 1 week ago

Update: I managed to install the udev rule using the HA OS documentation and an USB stick. However it still shows me the very same error. The weirdest thing is, that it works in a terminal using the SSH plugin:

apk add libusb
pip install pyusb sunnybeamtool asyncio
python

Python 3.12.3 (main, Apr 18 2024, 07:52:31) [GCC 13.2.1 20240309] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sunnybeamtool.sunnybeamtool import SunnyBeam
>>> import asyncio
>>> s_beam = SunnyBeam()
>>> asyncio.run(s_beam.get_serial_number())
'00033655'  
>>> asyncio.run(s_beam.get_today_measurements())
[(datetime.datetime(2024, 9, 9, 7, 30), 0.0), ...]

I do not (yet) understand why it works in the terminal but not in the UI

Further Update: I just tried switching back to the old version 0.1.3 and that version still works as expected. So I guess this is some GUI configuration issue. I would be awesome if you could have a look at this :) Thank you! For now I will stay on the old version.