theosnel / python-xsense

a Python XSense module
27 stars 2 forks source link

Unexpected error fetching xsense data: 'state' #3

Closed Robin19777 closed 1 week ago

Robin19777 commented 3 weeks ago

Hi, I have got some problems. I have installed this integration today, but it won't work...

image

`Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.xsense Quelle: helpers/update_coordinator.py:315 Integration: X-Sense Home Security Erstmals aufgetreten: 12:34:33 (43 Vorkommnisse) Zuletzt protokolliert: 13:20:59

Unexpected error fetching xsense data: 'state' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/xsense/coordinator.py", line 49, in _async_update_data return await self.get_devices() ^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/xsense/coordinator.py", line 87, in get_devices await self.xsense.get_station_state(s) File "/usr/local/lib/python3.12/site-packages/xsense/async_xsense.py", line 140, in get_station_state station.set_data(res['state']['reported'])


KeyError: 'state'
`

FYI:
- Acount information is correct 
- it is a second account with shared homes as needed

Do you have a solution or any suggestions for this, please?
theosnel commented 3 weeks ago

Did you share a base-station with all sensors or did you share the separate sensors?

The library basestation and the integration was trying to retrieve information about it, which seem to fail. I'm currently working on better error-handling, and will include this as well.

Robin19777 commented 3 weeks ago

In the x sense App i have created 2 homes. One for the main residence and one for the rental apartment. I have enabled both for Home Assistant, because of course I want to be notified even if the apartment above me burns down

Robin19777 commented 2 weeks ago

Did you find a solution?

theosnel commented 2 weeks ago

What kind of devices do you have? Do you have stand alone wifi sensors?

You can also try the latest version, which has better error-handling. You can fetch it from here: https://github.com/theosnel/homeassistant-core/tree/xsense/homeassistant/components/xsense or use the hacs version made by Jarnsen (https://github.com/Jarnsen/ha-xsense-component_test). This version does not support wifi-devices yet, but we do have testdata now, so it will be added in the near future.

Robin19777 commented 2 weeks ago

I have got 12 smoke detectors XS01-WX 6 are stored in home 1 and the others are stored in home 2. both homes are shared to the sperate account

I will try the other versions, thank you

theosnel commented 2 weeks ago

Yes, these are stand-alone wifi-devices, which are not yet supported. But we have some test-data for this specific device. Maybe I have time next week to include it. I'll let you know.

Robin19777 commented 2 weeks ago

Yes, let me know, I will support you if you need an account to integrate with those devices. btw: Same Problem with Jarnsen's intregration

Robin19777 commented 1 week ago

@theosnel I just would let you know, that I got it working. I do not know what excatly bring me to the success.

Possibility 1: Maybe it is working now, because I used this repo: https://github.com/Jarnsen/ha-xsense-component_test Possibility 2: Otherwise it could be, because I shared only 1 home and added this by the integration. After finding those smoke detektors, I shared the second home to that account. So, I only had to reload the integration and it found the devices of the second home. In short: Add only home after home to the second account.

btw: Icons of devices do not show up. Link to picture is broken image Link of Picture: https://brands.home-assistant.io/xsense/dark_icon.png

theosnel commented 1 week ago

Good to hear. I released a new version yesterday that added support for wifi-devices. But I totally forgot to inform you about it. The repo that you mention is created by Jarnsen, which makes a hacs module from my code. At the moment that is the easiest way to use it.