tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
292 stars 48 forks source link

[Bug] 2023.9.X missing system and diagnostic sensors #300

Closed alexanderznamensky closed 11 months ago

alexanderznamensky commented 11 months ago

After upgrading to HA 2023.9.0 + master branch, I have missed following sensors:

Home Assistant 2023.9.0 Supervisor 2023.08.3 MikroTik FW 6.49.10

NyvenZA commented 11 months ago

Same issue. None of my Mikrotik info is working.

HA-TB303 commented 11 months ago

Some here, seems to be a bug related to the new version of HA.

I am on ROS 7.11.2, HA 2023.9.0 and Mikrotik integration v2.1.2.

fotis3d commented 11 months ago

Same here also. After the latest HA update.

I have 2 Mikrotiks lost the sensors too.

EvgveneSV commented 11 months ago

Same issues. Have few devises with ROS 7.11.2 and 7.9.1

NyvenZA commented 11 months ago

Updated to 2023.9.1 and still not working.

tomaae commented 11 months ago

I dont have this issue on master branch: image Check HA log and integration diagnostics. if there is nothing, we will need to look at debugs.

aurelmarius commented 11 months ago

No problem here also... image

brezuicabogdan commented 11 months ago

I have the same issue with ROS 7.11.2, HA 2023.9.0 plugin version 2.1.2. I tried uninstalling and re-installing the plugin besides rebooting both the Mikrotik device and HA.

I noticed these errors in teh HA logs ... maybe it can help debugging

homeassistant | 2023-09-09 20:34:10.358 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '1A:FD:74:C3:85:A7-wifi-devices-24ghz')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi-devices-24ghz', 'identifiers': {('mac', '1A:FD:74:C3:85:A7-wifi-devices-24ghz')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information. homeassistant | 2023-09-09 20:34:10.358 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '1A:FD:74:C3:85:A8-wifi-guests-5ghz')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi-guests-5ghz', 'identifiers': {('mac', '1A:FD:74:C3:85:A8-wifi-guests-5ghz')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information. homeassistant | 2023-09-09 20:34:10.358 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '1A:FD:74:C3:85:A9-wifi-guests-24ghz')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi-guests-24ghz', 'identifiers': {('mac', '1A:FD:74:C3:85:A9-wifi-guests-24ghz')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information. homeassistant | 2023-09-09 20:34:10.359 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '18:FD:74:C3:85:A7')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi1', 'identifiers': {('mac', '18:FD:74:C3:85:A7')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information. homeassistant | 2023-09-09 20:34:10.359 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '18:FD:74:C3:85:A8')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi2', 'identifiers': {('mac', '18:FD:74:C3:85:A8')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information. homeassistant | 2023-09-09 20:34:10.360 ERROR (MainThread) [homeassistant.components.update] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mikrotik_router', 'HD808EFE1DZ')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan hAP ax^2', 'identifiers': {('mikrotik_router', 'HD808EFE1DZ')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information. homeassistant | 2023-09-09 20:34:10.360 ERROR (MainThread) [homeassistant.components.update] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mikrotik_router', 'HD808EFE1DZ')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan hAP ax^2', 'identifiers': {('mikrotik_router', 'HD808EFE1DZ')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

aurelmarius commented 11 months ago

I have the same issue with ROS 7.11.2, HA 2023.9.0 plugin version 2.1.2. I tried uninstalling and re-installing the plugin besides rebooting both the Mikrotik device and HA.

I noticed these errors in teh HA logs ... maybe it can help debugging

`homeassistant | 2023-09-09 20:34:10.358 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '1A:FD:74:C3:85:A7-wifi-devices-24ghz')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi-devices-24ghz', 'identifiers': {('mac', '1A:FD:74:C3:85:A7-wifi-devices-24ghz')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

homeassistant | 2023-09-09 20:34:10.358 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '1A:FD:74:C3:85:A8-wifi-guests-5ghz')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi-guests-5ghz', 'identifiers': {('mac', '1A:FD:74:C3:85:A8-wifi-guests-5ghz')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

homeassistant | 2023-09-09 20:34:10.358 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '1A:FD:74:C3:85:A9-wifi-guests-24ghz')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi-guests-24ghz', 'identifiers': {('mac', '1A:FD:74:C3:85:A9-wifi-guests-24ghz')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

homeassistant | 2023-09-09 20:34:10.359 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '18:FD:74:C3:85:A7')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi1', 'identifiers': {('mac', '18:FD:74:C3:85:A7')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

homeassistant | 2023-09-09 20:34:10.359 ERROR (MainThread) [homeassistant.components.switch] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mac', '18:FD:74:C3:85:A8')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan wifi2', 'identifiers': {('mac', '18:FD:74:C3:85:A8')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

homeassistant | 2023-09-09 20:34:10.360 ERROR (MainThread) [homeassistant.components.update] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mikrotik_router', 'HD808EFE1DZ')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan hAP ax^2', 'identifiers': {('mikrotik_router', 'HD808EFE1DZ')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.

homeassistant | 2023-09-09 20:34:10.360 ERROR (MainThread) [homeassistant.components.update] mikrotik_router: Not adding entity with invalid device info: Invalid device info {'configuration_url': 'http://192.168.1.1', 'connections': {('mikrotik_router', 'HD808EFE1DZ')}, 'default_manufacturer': 'MikroTik', 'default_model': 'hAP ax^2', 'default_name': 'router.lan hAP ax^2', 'identifiers': {('mikrotik_router', 'HD808EFE1DZ')}, 'sw_version': '7.11.2 (stable)', 'via_device': ('mikrotik_router', 'HD808EFE1DZ')} for 'mikrotik_router' config entry: device info needs to either describe a device, link to existing device or provide extra information.`

Upgrade plugin to master branch.

brezuicabogdan commented 11 months ago

Thanks - this worked

fotis3d commented 11 months ago

How do we upgrade to master branch ?

artpcpl commented 11 months ago

HACS Screenshot - 10 09 2023 , 13_46_42

hippieua commented 11 months ago

same bug on 2.1.2 I see all data in downloaded diagnostic file, but they are not shown in HA after updating to master - problem solved

tomaae commented 11 months ago

this issue cannot show up on 2.1.2 and 2023.9.X, its something completely different.

fotis3d commented 11 months ago

@artpcpl thanks

Worked for me also on "master". Should we stay on master though ?

tomaae commented 11 months ago

its fine to stay on master until next version is released. thats the only option if you need integration working in the mean time.

fotis3d commented 11 months ago

@tomaae ok gr8 thanks a lot ;)

emilianogetino commented 11 months ago

If I change to the master version, will any configuration be lost? Or will everything stay the same as it was? thank you.

fotis3d commented 11 months ago

@emilianogetino everything will stay the same. At least for me did ;)

tomaae commented 11 months ago

some uid will change, still have to fix that one.

hippieua commented 11 months ago

this issue cannot show up on 2.1.2 and 2023.9.X, its something completely different.

I noticed it after updating to 2023.9.1, Im not sure if it was working on 2023.9.0, but on latest 2023.8.x it was working correctly

I tried reintalling, reinitializing, reconfiguring nothing helped, only switch to master

i noticed the the only record it could create in HA - were related to device_tracker domain.

but in debug i could see all data. config_entry-mikrotik_router-136de2ca81680c3da3f4c244e6a0420b.json.txt

tomaae commented 11 months ago

I can see system sensors there and available.

hippieua commented 11 months ago

yes, that what I am talking about. But in HA there was 0 sensors and switches available. Only related to device tracker

bonsi001 commented 11 months ago

I have the same issue as [hippieua]. On HA there was 0 sensors and switches available. Only related to device tracker On 2023.9.0 And on 2023.9.1 2.1.2 ROS 7.11.2

tomaae commented 11 months ago

This is about master branch, not 2.1.2

alexanderznamensky commented 11 months ago

after update to 2.1.3 issue is still existing: image

image

Эта ошибка возникла в пользовательской интеграции.

Logger: aiohttp.server Source: custom_components/mikrotik_router/diagnostics.py:21 Integration: Mikrotik Router (documentation, issues) First occurred: 09:34:20 (1 occurrences) Last logged: 09:34:20

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 31, in headers_middleware response = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle result = await handler(request, **request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/diagnostics/init.py", line 249, in get data = await info.config_entry_diagnostics(hass, config_entry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/mikrotik_router/diagnostics.py", line 21, in async_get_config_entry_diagnostics "data": async_redact_data(controller.data, TO_REDACT), ^^^^^^^^^^^^^^^ AttributeError: 'MikrotikData' object has no attribute 'data'

tomaae commented 11 months ago

run it in debug, so we can see whats wrong. also upload diagnostics data.

0xa51f commented 11 months ago

this problem only exists for me with RouterOS 6 (works fine with RouterOS 7)

tried master branch and 2.13

unable to download diagnostics

image

debug logs attached:

home-assistant_2023-09-13T11-51-47.065Z.log

tomaae commented 11 months ago
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 586, in state
    numerical_value = int(value)
                      ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'unknown'

I see, this is probably related to https://developers.home-assistant.io/blog/2023/08/23/sensor-updates/ There is probably more to this issue, since it reports unknown. But first have to solve this.

Diagnostics not working is another issue. Have to look into that.

alexanderznamensky commented 11 months ago

After update to Home Assistant 2023.9.2 (Supervisor 2023.09.2, MikroTik FW 6.49.10):

  1. Logger: homeassistant.components.sensor Source: components/sensor/init.py:593 Integration: Сенсор (documentation, issues) First occurred: 09:14:24 (2 occurrences) Last logged: 09:14:24

Error adding entities for domain sensor with platform mikrotik_router Error while setting up mikrotik_router platform for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 586, in state numerical_value = int(value) ^^^^^^^^^^ ValueError: invalid literal for int() with base 10: 'unknown'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 589, in state numerical_value = float(value) ^^^^^^^^^^^^ ValueError: could not convert string to float: 'unknown'

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

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state state, attr = self._async_generate_attributes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 771, in _async_generate_attributes state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 593, in state raise ValueError( ValueError: Sensor sensor.mikrotik_hap_ac_cpu_temperature has device class 'temperature', state class 'measurement' unit '°C' and suggested precision '0' thus indicating it has a numeric value; however, it has the non-numeric value: 'unknown' (<class 'str'>)

  1. Logger: homeassistant.components.device_tracker Source: custom_components/mikrotik_router/device_tracker.py:72 Integration: Устройство для отслеживания (documentation, issues) First occurred: 09:14:24 (1 occurrences) Last logged: 09:14:24

Error while setting up mikrotik_router platform for device_tracker Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/mikrotik_router/device_tracker.py", line 110, in async_setup_entry await async_add_entities(hass, config_entry, dispatcher) File "/config/custom_components/mikrotik_router/device_tracker.py", line 89, in async_add_entities await async_update_controller( File "/config/custom_components/mikrotik_router/device_tracker.py", line 72, in async_update_controller data = coordinator.data[entity_description.data_path]


TypeError: 'NoneType' object is not subscriptable

Thanks!
tomaae commented 11 months ago

yes, thats exactly same error message as above.

alexanderznamensky commented 11 months ago

tomaae, thanks for your excelent work! Now it is perfect - all sensors are working!

Thanks indeed!

tomaae commented 11 months ago

perfect