home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.14k stars 31.12k forks source link

Lupusec Integration: Alarm Panel state error #86299

Closed tofrie closed 1 year ago

tofrie commented 1 year ago

The problem

The Alarmpanel won‘t change the state. If I restart Home Assistant everything works for some time. Then an error appears and I can‘t change my lupus state.

What version of Home Assistant Core has the issue?

core-2023.1.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Lupusec

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/lupusec/alarm_control_panel.py:68 
Integration: Home Assistant WebSocket API (documentation, issues) 
First occurred: 16:52:30 (3 occurrences) 
Last logged: 16:53:09

[140122481337696] Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 958, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/alarm_control_panel/__init__.py", line 177, in async_alarm_arm_away
    await self.hass.async_add_executor_job(self.alarm_arm_away, code)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/lupusec/alarm_control_panel.py", line 68, in alarm_arm_away
    self._device.set_away()
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 45, in set_away
    return self.set_mode(CONST.MODE_AWAY)
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 31, in set_mode
    response_object = self._lupusec.set_mode(self._lupusec.mode_translation[mode])
  File "/usr/local/lib/python3.10/site-packages/lupupy/__init__.py", line 326, in set_mode
    responseJson = self.clean_json(r.text)
  File "/usr/local/lib/python3.10/site-packages/lupupy/__init__.py", line 118, in clean_json
    return json.loads(self.remove_control_characters(textdata))
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Additional information

Logger: homeassistant.helpers.entity Source: components/lupusec/init.py:95 First occurred: 16:52:30 (3 occurrences) Last logged: 16:53:10

Update for alarm_control_panel.lupusec_alarm fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/lupusec/init.py", line 95, in update self._device.refresh() File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 53, in refresh response_object = LupusecDevice.refresh(self) File "/usr/local/lib/python3.10/site-packages/lupupy/devices/init.py", line 46, in refresh response = self._lupusec.get_panel() File "/usr/local/lib/python3.10/site-packages/lupupy/init.py", line 175, in get_panel raise Exception("Unable to get panel " + response.status_code) TypeError: can only concatenate str (not "int") to str

home-assistant[bot] commented 1 year ago

Hey there @majuss, mind taking a look at this issue as it has been labeled with an integration (lupusec) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `lupusec` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign lupusec` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


lupusec documentation lupusec source (message by IssueLinks)

majuss commented 1 year ago

Please manually update lupupy to 0.2.5 and report back.

Which Alarm Panel are you using? Is the connection to the panel reliable?

tofrie commented 1 year ago

I tried tue standard one and the one from mushroom cards. Both with the same result. Everything works well if i restart HA. How can i install lupupy?

majuss commented 1 year ago

No I mean which physical hardware do you own?

tofrie commented 1 year ago

XT2 Plus with Outdoor Keypad and indoor keypad v2

majuss commented 1 year ago

Wait for new HA release and this pull request: https://github.com/home-assistant/core/pull/86439

tofrie commented 1 year ago

I tried the new beta. Same issue...

majuss commented 1 year ago

Check the installed lupupy Version in the beta. I don't see the bump in any released beta version of HA. It's currently only in dev in my opinion.

tofrie commented 1 year ago

So it will be in 2023.2.0?

tofrie commented 1 year ago

Same error with the new update... 😣

majuss commented 1 year ago

Please post the full error log again.

tofrie commented 1 year ago

Logger: homeassistant.components.websocket_api.http.connection
Source: components/lupusec/alarm_control_panel.py:68 
Integration: Home Assistant WebSocket API (documentation, issues) 
First occurred: 1. Februar 2023 um 23:00:10 (6 occurrences) 
Last logged: 12:14:01

[139772689543184] Expecting value: line 1 column 1 (char 0)
[139772614157616] Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 681, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 721, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/alarm_control_panel/__init__.py", line 177, in async_alarm_arm_away
    await self.hass.async_add_executor_job(self.alarm_arm_away, code)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/lupusec/alarm_control_panel.py", line 68, in alarm_arm_away
    self._device.set_away()
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 45, in set_away
    return self.set_mode(CONST.MODE_AWAY)
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 31, in set_mode
    response_object = self._lupusec.set_mode(self._lupusec.mode_translation[mode])
  File "/usr/local/lib/python3.10/site-packages/lupupy/__init__.py", line 326, in set_mode
    responseJson = self.clean_json(r.text)
  File "/usr/local/lib/python3.10/site-packages/lupupy/__init__.py", line 118, in clean_json
    return json.loads(self.remove_control_characters(textdata))
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
tofrie commented 1 year ago

Und:


Logger: homeassistant.helpers.entity
Source: components/lupusec/__init__.py:95 
First occurred: 1. Februar 2023 um 23:00:15 (4 occurrences) 
Last logged: 12:14:00

Update for alarm_control_panel.lupusec_alarm fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 548, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 746, in async_device_update
    raise exc
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/lupusec/__init__.py", line 95, in update
    self._device.refresh()
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 53, in refresh
    response_object = LupusecDevice.refresh(self)
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/__init__.py", line 46, in refresh
    response = self._lupusec.get_panel()
  File "/usr/local/lib/python3.10/site-packages/lupupy/__init__.py", line 175, in get_panel
    raise Exception("Unable to get panel " + str(response.status_code))
Exception: Unable to get panel 401
majuss commented 1 year ago

This is the relevant one.. HTTP 401. Your panel is rejecting the request for whatever reason. Is your LAN and internet connection stable and wired without wireless bridges? Is the firmware on the XT2 recent?

tofrie commented 1 year ago

Firmware is the recent one. Internet is stable. The XT is connected over LAN. No wireless Connection. The state is correct in Home Assistant but i can't change it. Only one time after reboot.

tofrie commented 1 year ago

I activated https only. Could this be the reason? I tried another user. Same issue...

tofrie commented 1 year ago

XT Log:

Bildschirmfoto 2023-02-02 um 20 41 50

majuss commented 1 year ago

Disable HTTPS only and try again. It doesn't matter at all, as long as you don't open a port directly to the XTUs webinterface, which is absolutely not recommended.

tofrie commented 1 year ago

Same issue...

tofrie commented 1 year ago

Could this be in conjunction with the keypad? I think I can arm and disarm with the panel until I use my keypad.

i used IoBroker before I switched to Home Assistant and everything works fine.

majuss commented 1 year ago

I don't really understand what IoBroker has to do with all of this.

I only have an XT2 (wihtout plus) and have zero issues. Maybe the Plus has vastly different firmware. My guess is, as soon as the keypad enters something (I have an XT1 keypad with lupsec 868 MHz), the current session is invalidated. Quite hard to debug without access to the device and seeing stuff happening while I change the code.

majuss commented 1 year ago

Wait for https://github.com/home-assistant/core/pull/87469 to get merged, or update lupupy manually to 0.2.7. How to do it manually:

tofrie commented 1 year ago

Looks good to me. I will do some tests later.

tofrie commented 1 year ago
Logger: homeassistant.components.websocket_api.http.connection
Source: components/lupusec/alarm_control_panel.py:72 
Integration: Home Assistant WebSocket API (documentation, issues) 
First occurred: 08:20:12 (2 occurrences) 
Last logged: 08:21:20

[140103005660896] Expecting value: line 1 column 1 (char 0)
[140103005210944] Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 680, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/alarm_control_panel/__init__.py", line 161, in async_alarm_disarm
    await self.hass.async_add_executor_job(self.alarm_disarm, code)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/lupusec/alarm_control_panel.py", line 72, in alarm_disarm
    self._device.set_standby()
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 49, in set_standby
    return self.set_mode(CONST.MODE_DISARMED)
  File "/usr/local/lib/python3.10/site-packages/lupupy/devices/alarm.py", line 31, in set_mode
    response_object = self._lupusec.set_mode(self._lupusec.mode_translation[mode])
  File "/usr/local/lib/python3.10/site-packages/lupupy/__init__.py", line 333, in set_mode
    responseJson = self.clean_json(r.text)
  File "/usr/local/lib/python3.10/site-packages/lupupy/__init__.py", line 119, in clean_json
    return json.loads(self.remove_control_characters(textdata))
  File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
majuss commented 1 year ago

This will happen everytime? Did you install 2023.2.3?

To debug hardware via an github issue is kinda impossible. We have to find another way to debug this. If you're open to share a temporary VPN access to the device please drop me a mail: ich@majuss.de

majuss commented 1 year ago

Wait for https://github.com/home-assistant/core/pull/87754

HA 2023.2.4 should have it included.

Do you have a Linux or macOS machine and could test lupupy directly without HA? I really want to fix this. So please keep in touch and if you're up for it, drop me a mail (german is also fine).

tofrie commented 1 year ago

I tried the new version from the last HA Update (Home Assistant 2023.2.3). The error appears but the alarm state changes if i press the button two times. I use macOS and HA runs in a proxmox vm.