Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speedport Smart 4 Plus: device_tracker Probleme seit 26.03.24 #16

Open
Fr35h-RS opened this issue Apr 1, 2024 · 7 comments
Open

Speedport Smart 4 Plus: device_tracker Probleme seit 26.03.24 #16

Fr35h-RS opened this issue Apr 1, 2024 · 7 comments

Comments

@Fr35h-RS
Copy link

Fr35h-RS commented Apr 1, 2024

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
Copy link
Author

Fr35h-RS commented Apr 7, 2024

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'

@Fr35h-RS Fr35h-RS closed this as completed Apr 7, 2024
@Fr35h-RS Fr35h-RS reopened this Apr 7, 2024
Copy link

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
Copy link

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
Copy link
Contributor

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:

  • Core:2024.5.4
  • Supervisor: 2024.05.1
  • Operating System: 12.3
  • Frontend: 20240501.1

@matriphe
Copy link
Contributor

@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
Copy link
Contributor

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 Handle AttributeError #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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants