AlexxIT / SonoffLAN

Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant
https://github.com/AlexxIT/Blog
MIT License
2.75k stars 416 forks source link

Bug in ZBBridge-P local protocol #1529

Open aferende opened 1 day ago

aferende commented 1 day ago

Hi, I installed the master version of SONOFFLAN because I recently bought a SNZB-05P probe (Water Sensor) and I must say that with the master version (3.8.2 has not yet been released) it works well, compliments to @AlexxIT . When HA starts the AddOn starts without problems but if I try to restart the integration ...

image

... the system remains in loop for several minutes (about 10 minutes) ...

image

image

and then shows this error:

Questo errore ha avuto origine da un'integrazione personalizzata.

Registratore: custom_components.sonoff.core.ewelink.local
Fonte: custom_components/sonoff/core/ewelink/local.py:198
Integrazione: Sonoff (documentazione, problemi)
Prima occorrenza: 19:33:08 (1 occorrenze)
Ultima registrazione: 19:33:08

10022bd4a5 => Local4 | 192.168.100.223:8081 | None
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_proto.py", line 262, in data_received
    messages, upgraded, tail = self._parser.feed_data(data)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "aiohttp/_http_parser.pyx", line 563, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message:
  Data after `Connection: close`:

    b'{"sequence":"1732127586617","seq":3,"error":400,"encrypt":true}HTTP/1.1 200 OK'
                                                                      ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1059, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 644, in read
    await self._waiter
aiohttp.http_exceptions.HttpProcessingError: 400, message:
  Data after `Connection: close`:

    b'{"sequence":"1732127586617","seq":3,"error":400,"encrypt":true}HTTP/1.1 200 OK'
                                                                      ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/sonoff/core/ewelink/local.py", line 198, in send
    r = await self.session.post(
        ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 690, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1061, in start
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Data after `Connection: close`:\n\n  b\'{"sequence":"1732127586617","seq":3,"error":400,"encrypt":true}HTTP/1.1 200 OK\'\n                                                                    ^', url='http://192.168.100.223:8081/zeroconf/getState'

and also

2024-11-20 19:34:42 [D] CLOUD change state old=True, new=None
2024-11-20 19:34:42 [W] Can't load devices|  File "/config/custom_components/sonoff/__init__.py", line 219, in async_setup_entry|    devices = await registry.cloud.get_devices(homes)|              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|RuntimeError: Session is closed|
2024-11-20 19:34:42 [D] 27 devices loaded from Cache
2024-11-20 19:34:42 [D] a4800b3c9f UIID 7019 | {'subDevId': 'f54064feffa7db287019', 'parentid': '10022bd4a5', 'fwVersion': '1.0.2', 'subDevRssi': -73, 'battery': 100, 'trigTime': '1732122385000', 'supportPowConfig': 1, 'water': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800a840d UIID 7004 | {'subDevId': 'ba85e8feffdec7b07004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'subDevRssi': -78, 'switch': 'off', 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ac882 UIID 2026 | {'subDevId': 'f108cb2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -64, 'battery': 77, 'trigTime': '1732122672000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800aad2b UIID 7004 | {'subDevId': 'b52acafeff5fae0c7004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'subDevRssi': -62, 'switch': 'off', 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ae20e UIID 2026 | {'subDevId': '5a1ca02f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -75, 'battery': 100, 'trigTime': '1732123354000', 'supportPowConfig': 1, 'motion': 1, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ab03c UIID 7004 | {'subDevId': 'd52c50feff1227847004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'subDevRssi': -75, 'switch': 'off', 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ab49b UIID 2026 | {'subDevId': '174acb2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -72, 'battery': 100, 'trigTime': '1732123400000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800acd2d UIID 7004 | {'subDevId': '869682feffa7db287004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'subDevRssi': -73, 'switch': 'off', 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ac8a0 UIID 2026 | {'subDevId': 'def7ca2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -81, 'battery': 100, 'trigTime': '1732123566000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800aa5dc UIID 7004 | {'subDevId': '304c36feff1227847004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'subDevRssi': -74, 'switch': 'off', 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ac947 UIID 2026 | {'subDevId': '6a7acf2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -78, 'battery': 73, 'trigTime': '1732123571000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800abe9c UIID 2026 | {'subDevId': 'be7ecf2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -67, 'battery': 74, 'trigTime': '1732123610000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ab016 UIID 7004 | {'subDevId': 'a33050feff1227847004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'subDevRssi': -77, 'switch': 'off', 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ada17 UIID 7027 | {'subDevId': '22abaefefff6ef0c7027', 'parentid': '10022bd4a5', 'fwVersion': '1.0.3', 'subDevRssi': -75, 'battery': 100, 'trigTime': '1731756059000', 'supportPowConfig': 1, 'switch': False, 'realIrrigationVolume': 0, 'realIrrigationVolumeGal': 0, 'todayWaterUsage': 0, 'todayWaterUsageGal': 0, 'controlMode': 'manual', 'runningMode': 2, 'exceptionReport': [1], 'hasException': True, 'lastIrrigationTime': '1732066190000', 'endIrrigationTime': '1732066251000'}
2024-11-20 19:34:42 [D] a4800ac954 UIID 2026 | {'subDevId': '937ecf2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -74, 'battery': 73, 'trigTime': '1732123826000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800acce0 UIID 7004 | {'subDevId': 'df82b8fefff6ef0c7004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'switch': 'off', 'subDevRssi': -72, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ac93a UIID 2026 | {'subDevId': 'd8f9cd2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -78, 'battery': 78, 'trigTime': '1732124546000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800a8a92 UIID 7004 | {'subDevId': '413bb6feff5fae0c7004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'switch': 'off', 'subDevRssi': -75, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ac933 UIID 2026 | {'subDevId': 'd949a12f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -71, 'battery': 100, 'trigTime': '1732100821000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800a84d0 UIID 7004 | {'subDevId': 'bc9be8feffdec7b07004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'switch': 'off', 'subDevRssi': -77, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800a9f12 UIID 2026 | {'subDevId': 'dbf7ca2f004b12002026', 'parentid': '10022bd4a5', 'subDevRssi': -76, 'battery': 100, 'trigTime': '1732123058000', 'supportPowConfig': 1, 'motion': 0, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800a86ec UIID 7004 | {'subDevId': '9de640feff1227847004', 'parentid': '10022bd4a5', 'fwVersion': '1.0.14', 'switch': 'off', 'subDevRssi': -63, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ac835 UIID 1009 | {'subDevId': '4048d330004b12001009', 'parentid': '10022bd4a5', 'fwVersion': '2.0.1', 'switch': 'on', 'subDevRssi': -77, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ad9fb UIID 1009 | {'subDevId': '0b43d330004b12001009', 'parentid': '10022bd4a5', 'fwVersion': '2.0.1', 'switch': 'off', 'subDevRssi': -77, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ac83b UIID 1009 | {'subDevId': 'f73dd330004b12001009', 'parentid': '10022bd4a5', 'fwVersion': '2.0.1', 'switch': 'off', 'subDevRssi': -73, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] a4800ada0b UIID 1009 | {'subDevId': '1e36d330004b12001009', 'parentid': '10022bd4a5', 'fwVersion': '2.0.1', 'switch': 'off', 'subDevRssi': -74, 'subDevRssiSetting': {'active': 60, 'duration': 5}}
2024-11-20 19:34:42 [D] 10022bd4a5 UIID 0168 | {'version': 8, 'sledOnline': 'off', 'rssi': -46, 'zled': 'off', 'hostVersion': '2.2.0', 'coordinatorVersion': '2.7.19', 'subDevMaxNum': 128, 'currentChannel': 25, 'fwVersion': '2.2.0', 'subDevices': [{'subDevId': '1e36d330004b12001009', 'deviceid': 'a4800ada0b', 'uiid': '1009', 'index': 0}, {'subDevId': 'f73dd330004b12001009', 'deviceid': 'a4800ac83b', 'uiid': '1009', 'index': 0}, {'subDevId': '4048d330004b12001009', 'deviceid': 'a4800ac835', 'uiid': '1009', 'index': 0}, {'subDevId': '0b43d330004b12001009', 'deviceid': 'a4800ad9fb', 'uiid': '1009', 'index': 0}, {'subDevId': '9de640feff1227847004', 'deviceid': 'a4800a86ec', 'uiid': '7004', 'index': 0}, {'subDevId': 'dbf7ca2f004b12002026', 'deviceid': 'a4800a9f12', 'uiid': '2026', 'index': 0}, {'subDevId': 'bc9be8feffdec7b07004', 'deviceid': 'a4800a84d0', 'uiid': '7004', 'index': 0}, {'subDevId': 'd949a12f004b12002026', 'deviceid': 'a4800ac933', 'uiid': '2026', 'index': 0}, {'subDevId': '413bb6feff5fae0c7004', 'deviceid': 'a4800a8a92', 'uiid': '7004', 'index': 0}, {'subDevId': 'd8f9cd2f004b12002026', 'deviceid': 'a4800ac93a', 'uiid': '2026', 'index': 0}, {'subDevId': 'df82b8fefff6ef0c7004', 'deviceid': 'a4800acce0', 'uiid': '7004', 'index': 0}, {'subDevId': '937ecf2f004b12002026', 'deviceid': 'a4800ac954', 'uiid': '2026', 'index': 0}, {'subDevId': '22abaefefff6ef0c7027', 'deviceid': 'a4800ada17', 'uiid': '7027', 'index': 0}, {'subDevId': 'a33050feff1227847004', 'deviceid': 'a4800ab016', 'uiid': '7004', 'index': 0}, {'subDevId': 'be7ecf2f004b12002026', 'deviceid': 'a4800abe9c', 'uiid': '2026', 'index': 0}, {'subDevId': '6a7acf2f004b12002026', 'deviceid': 'a4800ac947', 'uiid': '2026', 'index': 0}, {'subDevId': '304c36feff1227847004', 'deviceid': 'a4800aa5dc', 'uiid': '7004', 'index': 0}, {'subDevId': 'def7ca2f004b12002026', 'deviceid': 'a4800ac8a0', 'uiid': '2026', 'index': 0}, {'subDevId': '869682feffa7db287004', 'deviceid': 'a4800acd2d', 'uiid': '7004', 'index': 0}, {'subDevId': '174acb2f004b12002026', 'deviceid': 'a4800ab49b', 'uiid': '2026', 'index': 0}, {'subDevId': 'd52c50feff1227847004', 'deviceid': 'a4800ab03c', 'uiid': '7004', 'index': 0}, {'subDevId': '5a1ca02f004b12002026', 'deviceid': 'a4800ae20e', 'uiid': '2026', 'index': 0}, {'subDevId': 'b52acafeff5fae0c7004', 'deviceid': 'a4800aad2b', 'uiid': '7004', 'index': 0}, {'subDevId': 'f108cb2f004b12002026', 'deviceid': 'a4800ac882', 'uiid': '2026', 'index': 0}, {'subDevId': 'ba85e8feffdec7b07004', 'deviceid': 'a4800a840d', 'uiid': '7004', 'index': 0}, {'subDevId': 'f54064feffa7db287019', 'deviceid': 'a4800b3c9f', 'uiid': '7019', 'index': 0}], 'timeZone': 2, 'gatewayBindRelations': [], 'addSubDevState': 'off', 'addDevTime': 180, 'directDevNum': 10, 'routerDevNum': 4, 'cmd': 'getChannelInfo', 'panID': 38941, 'nvPanID': 38941, 'resetCode': 1, 'buzzerAlarm': {'mode': 'stop'}, 'only_device': {'ota': 'success', 'ota_fail_reason': 0}}
2024-11-20 19:34:42 [D] AUTO mode start
2024-11-20 19:34:42 [D] 10022bd4a5 <= Local3 | 192.168.100.223:8081 | {'sledOnline': 'off'} | 2

If I completely restart HA everything works again. I don't know if the procedure I'm using to install the master version is correct:

  1. I download the zip of the master version and overwrite all the files in the config\custom_components\sonoff folder
  2. I delete all the "pycache" folders and sub folders from the config\custom_components\sonoff folder
  3. I restart HA

Is it correct?

Now since in version 3.8.1 and I also believe in the master, the problem persists that sometimes the devices become "unavailable", I created a custom automation so that when one of the sensors becomes "unavailable", I restart the SONOFFLAN integration (which however does not restart for the problem described above).

alias: "Debug: Restart SonOffLan quando Motion Sensor SonOff offline"
description: ""
triggers: []
conditions:
  - condition: or
    conditions:
      - condition: state
        entity_id: switch.luce_ingresso
        state: unavailable
        for:
          hours: 0
          minutes: 0
          seconds: 10
      - condition: state
        entity_id: binary_sensor.motion_sensor_ingresso
        state: unavailable
        for:
          hours: 0
          minutes: 0
          seconds: 10
actions:
  - data:
      entry_id: 01J9M2DYSZGPG2H2V41SPPGFE4
    action: homeassistant.reload_config_entry
  - action: notify.mobile_app_oneplus_9_pro
    metadata: {}
    data:
      message: |
        "SonOffLan Integration riavviata a causa di sensori offline!"
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
mode: single

Attached the log: home-assistant_sonoff_2024-11-20T18-41-48.665Z.log

config_entry-sonoff-01J9M2DYSZGPG2H2V41SPPGFE4.json

Can anyone help me? Thanks in advance and congratulations again for this project