Andre0512 / speedport

Home Assistant integration for Telekom Speedport
MIT License
33 stars 6 forks source link

Speedport Smart 4 Plus: device_tracker Probleme seit 26.03.24 #16

Open Fr35h-RS opened 8 months ago

Fr35h-RS commented 8 months ago

Hallo,

vielen Dank für die tolle Integration! Aktuell scheint es leider Probleme zu geben, vielleicht ist ein Update schuld. Ich verwende einen Speedport Smart 4 Plus und aktuell scheint der device_tracker nicht mehr zu funktionieren. Ich konnte das Problem eingrenzen, es scheint seit ca. 26.03.24 aufzutreten. Woran kann das liegen?

Folgendes konnte ich per Debug-Protokollierung aufzeichnen:

2024-04-01 21:15:44.907 ERROR (MainThread) [custom_components.speedport.device] Unexpected error fetching Speedport Smart 4 Plus data: MAC check failed
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/speedport/device.py", line 32, in _async_update_data
    await asyncio.gather(
  File "/usr/local/lib/python3.12/site-packages/speedport/speedport.py", line 115, in update_ip_data
    self._ip_data = await self.api.get_ip_data()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/speedport/api.py", line 23, in inner
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/speedport/api.py", line 127, in get_ip_data
    return await self.api.get("data/IPData.json", referer=referer, auth=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/speedport/connection.py", line 105, in get
    return decode(await response.text(), key=key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/speedport/connection.py", line 25, in decode
    decrypted = cipher.decrypt_and_verify(ciphertext_tag[:-16], ciphertext_tag[-16:])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/Crypto/Cipher/_mode_ccm.py", line 597, in decrypt_and_verify
    self.verify(received_mac_tag)
  File "/usr/local/lib/python3.12/site-packages/Crypto/Cipher/_mode_ccm.py", line 538, in verify
    raise ValueError("MAC check failed")
ValueError: MAC check failed
Fr35h-RS commented 7 months ago

Anbei weitere Protokolldetails:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: homeassistant
Quelle: custom_components/speedport/device_tracker.py:75
Integration: Speedport (Dokumentation, Probleme)
Erstmals aufgetreten: 08:30:46 (373 Vorkommnisse)
Zuletzt protokolliert: 17:01:58

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/config/custom_components/speedport/device_tracker.py", line 117, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 998, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1119, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1080, in __async_calculate_state
    shadowed_attr[ATTR_ICON] = self.icon
                               ^^^^^^^^^
  File "/config/custom_components/speedport/device_tracker.py", line 85, in icon
    if self.is_connected:
       ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/speedport/device_tracker.py", line 75, in is_connected
    return self._device.connected
           ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'connected'
Tra2x commented 7 months ago

I have the same problem, additionally I have noticed, that I can't access the speedport homepage (in my case 192.168.2.1) not anymore

RainerBlank commented 7 months ago

Hallo,

auch ich finde die Integration klasse... Leider gibt es auch bei mir seit einem HA Update von Ende März das Problem, dass die Device Tracker für alle mobilen Geräte immer Home anzeigt.

matriphe commented 6 months ago

got the same problem. the device_tracker was never changed, even though the device was connected/disconnected to the router.

here's the log:

2024-05-21 21:24:30.116 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 414, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 168, in async_update_listeners
    update_callback()
  File "/config/custom_components/speedport/device_tracker.py", line 117, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1009, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1093, in __async_calculate_state
    shadowed_attr[ATTR_ICON] = self.icon
                               ^^^^^^^^^
  File "/config/custom_components/speedport/device_tracker.py", line 85, in icon
    if self.is_connected:
       ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/speedport/device_tracker.py", line 75, in is_connected
    return self._device.connected
           ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'connected'

The HA version:

matriphe commented 6 months ago

@Tra2x I got this error as well a couple days ago when I tried this. I think the Speedport interface (web server) was killed and crashed because it couldn't handle the request. Eventhough the web server interface crashed and killed, the router still works normally. Restarting the router will also restart the web server for the interface.

matriphe commented 6 months ago

I created a PR to fix this issue. I think the problem is in the latest SpeedPort. when the device is disconnected, it gets removed.

Unless my PR gets merged and the new version is released, you can fix it by yourself.

  1. Back up your configuration for your safety.
  2. Open File Editor (you need to install the Add-Ons via HACS, I recommend Visual Studio Code Add-Ons).
  3. Open this file (depending on your config directory) /config/custom_components/speedport/device_tracker.py.
  4. Copy the file from here: https://github.com/Andre0512/speedport/blob/33003998986884f586b824aac40ef760e4da344e/custom_components/speedport/device_tracker.py (it's pointing to my PR #18).
  5. Paste everything to the device_tracker.py and save it.
  6. Restart Home Assistant.
  7. Try by disconnecting the device from Wi-Fi, and wait a couple of second, it should change the state.
RainerBlank commented 6 months ago

@matriphe Thank you, with the file you provided the device tracker works again as expected.