dbuezas / icsee-ptz

44 stars 7 forks source link

integration can"t create binary entity #10

Closed uowis closed 10 months ago

uowis commented 11 months ago

the connexion is good, but :

Logger: homeassistant.components.binary_sensor
Source: custom_components/icsee_ptz/binary_sensor.py:62
Integration: Capteur binaire ([documentation](https://www.home-assistant.io/integrations/binary_sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+binary_sensor%22))
First occurred: 07:24:11 (8 occurrences)
Last logged: 10:56:09

Error while setting up icsee_ptz platform for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/icsee_ptz/binary_sensor.py", line 49, in async_setup_entry
    [
  File "/config/custom_components/icsee_ptz/binary_sensor.py", line 50, in <listcomp>
    Alarm(hass, entry, channel)
  File "/config/custom_components/icsee_ptz/binary_sensor.py", line 62, in __init__
    assert self._attr_unique_id  # set by ICSeeEntity
AssertionError
uowis commented 11 months ago

image

dbuezas commented 11 months ago

Re-logins are on purpose, the keep alive function in the library doesn't work well, particularly while watching alarms. The integration actually logs in a new connection before login out the old one to avoid missing alarms

dbuezas commented 11 months ago

It seems like you have an issue with unique ids. Try removing and reading the camera, maybe something went wrong with the migration from the older version

dbuezas commented 10 months ago

Please try v4.0.0. I'm sorry but you'll need to re-add all cameras yet again (I haven't fully wrapped my mind about migrations yet), but this is hopefully the last time this is necessary.

sc16me commented 10 months ago

Unfortunately version 4.0.0 doesn't work either. There is no motion object. I have a camera and a HA server on different networks. Communication between them by Wireguard (level 3 OSI, IP only)

Logger: homeassistant.components.select Source: helpers/device_registry.py:297 Integration: Выбор (documentation, issues) First occurred: 21:18:24 (2 occurrences) Last logged: 21:18:24

Error adding entities for domain select with platform icsee_ptz Error while setting up icsee_ptz platform for select Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 619, in _async_add_entity device = dev_reg.async_get(self.hass).async_get_or_create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 519, in async_get_or_create connections = _normalize_connections(connections) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1075, in _normalize_connections return { ^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1076, in (key, format_mac(value)) if key == CONNECTION_NETWORK_MAC else (key, value) ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 297, in format_mac if len(to_test) == 17 and to_test.count(":") == 5: ^^^^^^^^^^^^ TypeError: object of type 'NoneType' has no len()

Logger: homeassistant.components.switch Source: helpers/device_registry.py:297 Integration: Выключатель (documentation, issues) First occurred: 21:18:24 (2 occurrences) Last logged: 21:18:24

Error adding entities for domain switch with platform icsee_ptz Error while setting up icsee_ptz platform for switch Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 619, in _async_add_entity device = dev_reg.async_get(self.hass).async_get_or_create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 519, in async_get_or_create connections = _normalize_connections(connections) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1075, in _normalize_connections return { ^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1076, in (key, format_mac(value)) if key == CONNECTION_NETWORK_MAC else (key, value) ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 297, in format_mac if len(to_test) == 17 and to_test.count(":") == 5: ^^^^^^^^^^^^ TypeError: object of type 'NoneType' has no len()

Logger: homeassistant.components.binary_sensor Source: helpers/device_registry.py:297 Integration: Бинарный сенсор (documentation, issues) First occurred: 21:18:24 (2 occurrences) Last logged: 21:18:24

Error adding entities for domain binary_sensor with platform icsee_ptz Error while setting up icsee_ptz platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 619, in _async_add_entity device = dev_reg.async_get(self.hass).async_get_or_create( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 519, in async_get_or_create connections = _normalize_connections(connections) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1075, in _normalize_connections return { ^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 1076, in (key, format_mac(value)) if key == CONNECTION_NETWORK_MAC else (key, value) ^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/device_registry.py", line 297, in format_mac if len(to_test) == 17 and to_test.count(":") == 5: ^^^^^^^^^^^^ TypeError: object of type 'NoneType' has no len()

dbuezas commented 10 months ago

Oh I see. I'm still using the mac address to identify the device, so HA can add other entities that may come from the router (like internet access). In your case, the system fails to grab the mac address and that results in an undefined value used.

I'll add an extra check to not do that if the mac address is None.

dbuezas commented 10 months ago

By the way, isn't this also breaking other integrations? I took the pattern from integrations in the HA core.

dbuezas commented 10 months ago

Please give v4.0.1 a try and let me know

sc16me commented 10 months ago

Please give v4.0.1 a try and let me know

Thank you! Everything seems to be working well now! There are no errors in HA-Corе. And I don't see any problems with other integrations either.

dbuezas commented 10 months ago

Yes! Success!

uowis commented 10 months ago

it's good for me too ! Congratulation