h4de5 / home-assistant-vimar

VIMAR by-me integration into home-assistant.io
GNU General Public License v3.0
44 stars 7 forks source link

Unable to add integreation. Unexpected error #73

Open Curo18 opened 1 year ago

Curo18 commented 1 year ago

Hi, I have installed HA v.2023.11.2 using docker compose. When I try to add Vimar integration I got:

image

and looking at the log file I got: ... 2023-11-16 09:54:48.965 INFO (MainThread) [custom_components.vimar.vimarlink.vimarlink] Vimar link initialized 2023-11-16 09:54:55.231 ERROR (SyncWorker_7) [custom_components.vimar.vimarlink.vimarlink] HTTP timeout occurred

Could it be related to docker installation? This is my compose.yml

version: '3'

services: homeassistant: container_name: homeassistant image: "ghcr.io/home-assistant/home-assistant:stable" volumes:

Thanks for your great job!

h4de5 commented 1 year ago

if you access the ip and the port in the browser directly, does it work? and does it still work after you try to add it to home-assistant?

Curo18 commented 1 year ago

I did some troubleshooting and these are the outcomes:

  1. Reset the Vimar Web Server (unplugged and plugged again from power source)

  2. I can reach the Vimar Web Server from the browser

  3. Run the example.py and I got the following: image

  4. I cannot reach anymore the Vimar Web Server from the browser. I have to reset it again.

I have quite a large number of devices so most likely is the same issue reported before #62

h4de5 commented 1 year ago

i thought so as well. there is a MAX_ROWS_PER_REQUEST in vimarlink.py which is currently set to 300. I you can try to lower this. but if I remember correctly it was not about the number, but due to the complexity of the query that the crashed occured. still you could try it

Curo18 commented 1 year ago

I tried to lower MAX_ROWS_PER_REQUEST but I got the same result. If is not viable to reduce the complexity of the queries, another possible solution could be to export the sql database from the VIMAR WEB SERVER and run the query on it to populate the VimarProject class. Then, the rest of the code to handle the devices should work. The only drawback is that you have to export the sql lite database every time you change something on the Vimar project.

Anyway, thanks for your time!!!

h4de5 commented 1 year ago

i am afraid the query will need to run regulary (like every HA restart) to initialize current on/off states.

you could try this: there is a get_room_id function which currently does not have a limit. in your log you should see how many rooms it can find. then add a limit to that query (LIMIT 0, 30) and try to do only half of your rooms to see if that would work.

Curo18 commented 1 year ago

I followed your suggestion and set MAX_ROWS_PER_REQUEST = 5. Same result. In case you want to investigate I have added some extra log data like the name of the function called and the query used by _generate_device_list function. I have attached the log file. example.log

These are the messages showed on the console:

Config ready Link ready Project ready Logged in Traceback (most recent call last): File "/home/HomeAssistant/custom_components/vimar/example/example.py", line 201, in main() File "/home/HomeAssistant/custom_components/vimar/example/example.py", line 137, in main vimarproject.update() File "/home/HomeAssistant/custom_components/vimar/example/vimarlink.py", line 821, in update self._link.get_paged_results(self._link.get_room_devices, self._devices) File "/home/HomeAssistant/custom_components/vimar/example/vimarlink.py", line 429, in get_paged_results objectlist, state_count = method(objectlist, start, limit) TypeError: cannot unpack non-iterable NoneType object