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

Only "is_present" and "is_home" sensors are being set in HomeAssistant via MQTT #1019

Open
4 of 7 tasks
jcss2503 opened this issue Mar 14, 2025 · 14 comments
Open
4 of 7 tasks
Labels
bug 🐛 Something isn't working next release/in dev image 🚀 This is coming in the next release or was already released if the issue is Closed.

Comments

@jcss2503
Copy link

Is there an existing issue for this?

The issue occurs in the following browsers. Select at least 2.

  • Firefox
  • Chrome
  • Edge
  • Safari (unsupported) - PRs welcome
  • N/A - This is an issue with the backend

Current Behavior

Only the sensors "is_present" and "is_home" present the correct info in HomeAssistant. Other sensors like "mac_address" or "last_ip" show "unknown" value. I have checked that HomeAssistant receive the info via MQTT but the entities attributes are not updated

Image

Image

Expected Behavior

The attributes has to be updated

Steps To Reproduce

All applications and plugins are at the latest version

app.conf

docker-compose.yml

What installation are you running?

Production (netalertx)

app.log

No response

Debug enabled

  • I have read and followed the steps in the wiki link above and provided the required debug logs and the log section covers the time when the issue occurs.
@jcss2503 jcss2503 added the bug 🐛 Something isn't working label Mar 14, 2025
jokob-sk pushed a commit that referenced this issue Mar 14, 2025
@jokob-sk
Copy link
Owner

Hi @jcss2503 ,

This should be fixed in the next release. It would be great if you could test this. Can you please switch to the netalertx-dev docker image (backup everything at first or, ideally spin up a separate container with a separate db and config), in about 15 minutes (or after the last action finishes) from now?

Thanks in advance,
j

@jokob-sk jokob-sk added the next release/in dev image 🚀 This is coming in the next release or was already released if the issue is Closed. label Mar 14, 2025
@jcss2503
Copy link
Author

I have tested the change:

  • Backup Devices in NetAlertX
  • Delete Devices in NetAlertX
  • Stop NetAlertX docker
  • Change to dev brach in docker compose
  • Delete HomeAssistant NetAlertX devices and Entities
  • Restart HomeAssistant
  • Start NetAlertX

I have wait for 1h, NetAlertX discover again all my network but this time no devices are being added to HomeAssistant. Logs in MosquitoBroker HA shows that the connection via MQTT are correct (user/password combination is correct)-

@jokob-sk
Copy link
Owner

Hi @jcss2503 ,

Could you try to clear the MQTT objects from Integrations -> Plugins -> MQTT? Only new objects are synced over.

More info here: https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/_publisher_mqtt/

@jcss2503
Copy link
Author

jcss2503 commented Mar 15, 2025

Hi j

Cleared all objects from MQTT Plugins and repeated all the process. Same result. I went back to the production version of NetAlertX, clean every thing and deveces are populated to HA but again attributes keep not updated.

Let me know if I can make some other checks

Thanks!

@jokob-sk
Copy link
Owner

Hi @jcss2503 ,

Could you please post your log file entries of some MQTT samples from the dev version, such as:

10:36:00 [MQTT] Existing, skip Device Name: Net - AP OLD
10:36:00 [MQTT] Existing, skip Device Name: Net - AP OLD
10:36:00 [MQTT] Existing, skip Device Name: Net - AP OLD
10:36:00 [MQTT] Sending MQTT topic: system-sensors/binary_sensor/mac_80_2a_a8_13_3e_4e/state
10:36:00 [MQTT] Sending MQTT message: {"is_present": "OFF"}
10:36:00 [MQTT] Existing, skip Device Name: Net - AP OLD
10:36:00 [MQTT] Sending MQTT topic: system-sensors/device_tracker/mac_80_2a_a8_13_3e_4e/state
10:36:00 [MQTT] Sending MQTT message: away
10:36:00 [MQTT] Sending MQTT topic: system-sensors/device_tracker/mac_80_2a_a8_13_3e_4e/attributes
10:36:00 [MQTT] Sending MQTT message: {"last_ip": "192.168.1.22", "is_new": "0", "vendor": "None", "mac_address": "80:2a:a8:13:3e:4e", "model": "Net - AP OLD", "last_connection": "2025-01-06T09:01:45+10:05", "first_connection": "2022-02-12T22:05:00+10:05", "sync_node": "", "group": "", "location": "", "network_parent_mac": "d0:21:f9:b4:ca:0b", "network_parent_name": "Net - Switch - POE"}
10:36:01 [MQTT] Existing, skip Device Name: Net - Switch - Study
10:36:01 [MQTT] Existing, skip Device Name: Net - Switch - Study
10:36:01 [MQTT] Existing, skip Device Name: Net - Switch - Study

Please note the log shoudl contain messages in this format when tehy are sent to MQTT:

10:56:34 [MQTT] Sending MQTT message: {"last_ip": "192.168.1.167", "is_new": "0", "vendor": "Motorola Mobility LLC a Lenovo Company", "mac_address": "6c:97:6d:7b:4a:43", "model": "Phone - Moto 82", "last_connection": "2025-03-16T10:52:30+10:05", "first_connection": "2022-11-03T00:05:00+10:05", "sync_node": "", "group": "Security", "location": "", "network_parent_mac": "d0:21:f9:8c:59:f9", "network_parent_name": "Net - AP"}

If you only see [MQTT] Existing, skip Device Name then these entries are not sent to the broker.

Alternatively try setting up a new empty install fro the dev container only and test it there if you can.

@jcss2503
Copy link
Author

jcss2503 commented Mar 16, 2025

This is the log with dev brach.

02:06:01 [Plugin utils] ---------------------------------------------
02:06:01 [Plugin utils] display_name: MQTT publisher
02:06:01 [Plugins] Executing: python3 /app/front/plugins/_publisher_mqtt/mqtt.py
02:06:02 MQTT In script
02:06:02 [Database] Opening DB
02:06:03 [MQTT] Connected to broker
02:06:03 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "03c3100fbf0814c59eea416ccdf2e89c"}
02:06:03 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||03c3100fbf0814c59eea416ccdf2e89c
02:06:03 [MQTT] Publishing sensor number 0
02:06:03 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/online/config
02:06:03 [MQTT] Sending MQTT message: {"name": "online", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.online}}", "unique_id": "netalertx_sensor_online", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-check"}
02:06:06 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "55495776a42ce203e01c80c049858f80"}
02:06:06 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||55495776a42ce203e01c80c049858f80
02:06:06 [MQTT] Publishing sensor number 1
02:06:06 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/down/config
02:06:06 [MQTT] Sending MQTT message: {"name": "down", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.down}}", "unique_id": "netalertx_sensor_down", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-cancel"}
02:06:09 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "9385c45fec599590cc29c9170e3dd09c"}
02:06:09 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||9385c45fec599590cc29c9170e3dd09c
02:06:09 [MQTT] Publishing sensor number 2
02:06:09 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/all/config
02:06:09 [MQTT] Sending MQTT message: {"name": "all", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.all}}", "unique_id": "netalertx_sensor_all", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi"}
02:06:12 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "285c8338005158c02abddea20e984057"}
02:06:12 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||285c8338005158c02abddea20e984057
02:06:12 [MQTT] Publishing sensor number 3
02:06:12 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/archived/config
02:06:12 [MQTT] Sending MQTT message: {"name": "archived", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.archived}}", "unique_id": "netalertx_sensor_archived", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-lock"}
02:06:15 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "2e3a348abe95f1c8ea6aeca613423ef3"}
02:06:15 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||2e3a348abe95f1c8ea6aeca613423ef3
02:06:15 [MQTT] Publishing sensor number 4
02:06:15 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/new/config
02:06:15 [MQTT] Sending MQTT message: {"name": "new", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.new}}", "unique_id": "netalertx_sensor_new", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-plus"}
02:06:18 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "637b74780fdfd103d8df0d7337c68f47"}
02:06:18 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||637b74780fdfd103d8df0d7337c68f47
02:06:18 [MQTT] Publishing sensor number 5
02:06:18 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/unknown/config
02:06:18 [MQTT] Sending MQTT message: {"name": "unknown", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.unknown}}", "unique_id": "netalertx_sensor_unknown", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-alert"}
02:06:21 [Plugins] Output: [plugin_helper] reading config file
02:06:02 MQTT In script
02:06:02 [Database] Opening DB
02:06:03 [MQTT] Connected to broker
02:06:03 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "03c3100fbf0814c59eea416ccdf2e89c"}
02:06:03 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||03c3100fbf0814c59eea416ccdf2e89c
02:06:03 [MQTT] Publishing sensor number 0
02:06:03 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/online/config
02:06:03 [MQTT] Sending MQTT message: {"name": "online", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.online}}", "unique_id": "netalertx_sensor_online", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-check"}
02:06:06 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "55495776a42ce203e01c80c049858f80"}
02:06:06 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||55495776a42ce203e01c80c049858f80
02:06:06 [MQTT] Publishing sensor number 1
02:06:06 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/down/config
02:06:06 [MQTT] Sending MQTT message: {"name": "down", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.down}}", "unique_id": "netalertx_sensor_down", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-cancel"}
02:06:09 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "9385c45fec599590cc29c9170e3dd09c"}
02:06:09 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||9385c45fec599590cc29c9170e3dd09c
02:06:09 [MQTT] Publishing sensor number 2
02:06:09 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/all/config
02:06:09 [MQTT] Sending MQTT message: {"name": "all", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.all}}", "unique_id": "netalertx_sensor_all", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi"}
02:06:12 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "285c8338005158c02abddea20e984057"}
02:06:12 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||285c8338005158c02abddea20e984057
02:06:12 [MQTT] Publishing sensor number 3
02:06:12 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/archived/config
02:06:12 [MQTT] Sending MQTT message: {"name": "archived", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.archived}}", "unique_id": "netalertx_sensor_archived", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-lock"}
02:06:15 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "2e3a348abe95f1c8ea6aeca613423ef3"}
02:06:15 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||2e3a348abe95f1c8ea6aeca613423ef3
02:06:15 [MQTT] Publishing sensor number 4
02:06:15 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/new/config
02:06:15 [MQTT] Sending MQTT message: {"name": "new", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.new}}", "unique_id": "netalertx_sensor_new", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-plus"}
02:06:18 [Plugin utils] 💬 INFO - Object not found {"Plugin": "MQTT", "Watched_Value3": "637b74780fdfd103d8df0d7337c68f47"}
02:06:18 [MQTT] New sensor entry (name|mac|hash) : (NetAlertX||637b74780fdfd103d8df0d7337c68f47
02:06:18 [MQTT] Publishing sensor number 5
02:06:18 [MQTT] Sending MQTT topic: homeassistant/sensor/netalertx/unknown/config
02:06:18 [MQTT] Sending MQTT message: {"name": "unknown", "state_topic": "system-sensors/sensor/netalertx/state", "value_template": "{{value_json.unknown}}", "unique_id": "netalertx_sensor_unknown", "device": {"identifiers": ["netalertx_sensor"], "manufacturer": "NetAlertX", "name": "NetAlertX"}, "icon": "mdi:wifi-alert"}
02:06:21 [MQTT] Sending MQTT topic: system-sensors/sensor/netalertx/state
02:06:21 [MQTT] Sending MQTT message: {"online": 33, "down": 0, "all": 33, "archived": 0, "new": 33, "unknown": 1}
02:06:21 [MQTT] Estimated delay: 480s (8.0min)


Seems that no device message is sent...

@jokob-sk
Copy link
Owner

Hi @jcss2503 ,

Seems like the messages are sent.

I don't see an issue in your log. Do you have MQTT_SEND_DEVICES enabled?

I would recommend you to use the same config for MQTT you used before, here are my sample settings which seem to work fine. Please check all the MQTT settings one by one.

Image

@jcss2503
Copy link
Author

jcss2503 commented Mar 17, 2025

I have done a completly fresh installation with the configuration you have suggested but I doesn't work in my environment. It's strange that in the Plugin objects only have this:

Image

Seems that the devices are not created, I tried deleting all the devices and discovering all again but nothing changed

@jokob-sk
Copy link
Owner

Can you try to increase the timeout of the script and to change disabled to e.g. after scan?

Image

@jokob-sk
Copy link
Owner

Also, can you let me know teh answer to this?

Do you have MQTT_SEND_DEVICES enabled?

@jcss2503
Copy link
Author

Yep!

Image

jokob-sk pushed a commit that referenced this issue Mar 17, 2025
@jokob-sk
Copy link
Owner

Thanks for confirming!

Just realized I had a debugging statement uncommented that would short-circuit the MQTT execution for faster testing. I removed it so it should work again.

fe722a5

If you re download the netalertx-dev image in about 15 min it should work again.

Thanks fir testing and the patience!

@jcss2503
Copy link
Author

In the target!!!

Image

No worries, developing software for the community is marvellous endeavour. Congratullations!

@jokob-sk
Copy link
Owner

Great - just keeping it open for others to see until the next release :)

@jokob-sk jokob-sk reopened this Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working next release/in dev image 🚀 This is coming in the next release or was already released if the issue is Closed.
Projects
None yet
Development

No branches or pull requests

2 participants