EliasKotlyar / Xiaomi-Dafang-Hacks

4.16k stars 1k forks source link

Discovered MQTT entities with a name that is equal to the device name #1870

Closed TheZoker closed 6 months ago

TheZoker commented 11 months ago

Description

After updating Home Assistant to version 2023.8.0 I've got the following warning.

Discovered MQTT entities with a name that is equal to the device name

This stops working in version 2024.2.0. Please address before upgrading. Some MQTT entities have an entity name equal to the device name. This is not expected. The entity name is set to null as a work-a-round to avoid a duplicate name. Please inform the maintainer of the software application that supplies the affected entities to fix this issue.

List of affected entities:

switch.dafang_rtsp_server switch.dafang_motion_send_telegram switch.dafang_ir_led switch.dafang_motion_send_emails switch.dafang_motion_detection switch.dafang_ir_filter switch.dafang_auto_night_detection switch.dafang_blue_led switch.dafang_yellow_led switch.dafang_recording camera.dafang_motion_snapshot sensor.dafang_light_sensor switch.dafang_night_mode binary_sensor.dafang_motion_sensor cover.dafang_move_up_down switch.dafang_motion_tracking cover.dafang_move_left_right switch.dafang_timelapse

according tho this link https://developers.home-assistant.io/blog/2023-057-21-change-naming-mqtt-entities/ they made some changes to the MTTQ entries naming.

Additional information: https://community.home-assistant.io/t/psa-mqtt-name-changes-in-2023-8/598099

BandBxx commented 11 months ago

+1

broyuken commented 11 months ago

Yes it seems like there will need to be some changes made to the mqtt discovery naming convention to align with HAs naming.

TheZoker commented 11 months ago

This PR should fix the issue: https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/pull/1871

Please test it and let me know if the issue is fixed. Thanks!

Andoramb commented 10 months ago

Right, this will impact everyone with HA and MQTT enabled

jmtatsch commented 10 months ago

Should be fixed on beta branch

jonwaland commented 8 months ago

other than installing the beta, what is required to clean it all up?

jmtatsch commented 8 months ago

restart camera, restart HA

jonwaland commented 8 months ago

have power cycled cameras, and restarted HA. no change:

2023-10-31 15:12:21.811 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT entity name starts with the device name in your config {'name': 'dafang2 Motion Sensor', 'unique_id': '7811dc7a24d3-motion-sensor', 'device': {'identifiers': ['7811dc7a24d3'], 'connections': [['mac', '78:11:dc:7a:24:d3']], 'manufacturer': 'Xiaomi', 'model': 'Dafang', 'name': 'dafang2', 'sw_version': 'null - beta - null'}, 'state_topic': 'myhome/dafang2/motion', 'device_class': <BinarySensorDeviceClass.MOTION: 'motion'>, 'payload_on': 'ON', 'payload_off': 'OFF', 'payload_not_available': 'offline', 'qos': 0, 'force_update': False, 'encoding': 'utf-8', 'payload_available': 'online', 'availability_mode': 'latest', 'enabled_by_default': True}, this is not expected. Please correct your configuration. The device name prefix will be stripped off the entity name and becomes 'Motion Sensor'

Hostname: | DAFANG2 -- | -- Model: | Xiaomi Dafang Firmware date: | null Firmware Branch: | beta Firmware Commit: | null ( No update available) Kernel Version: | #21 PREEMPT Thu Oct 19 11:38:16 CST 2017 Bootloader Version: | U-Boot 2013.07 (Jul 05 2018 - 13:33:27) Local Time: | Mon Nov 6 17:25:39 EST 2023 System Uptime: | 7d, 2h, 05m Load Average: | 3.08, 2.46, 2.39
jmtatsch commented 8 months ago

Likely the update tool failed somehow and you dont have the latest version. Beta and Master are on the same level now. Try with a fresh folder checkout from git. You can keep your config folder because nothing changed there for a while I think.

reefland commented 8 months ago

@jonwaland - I had the same issue yesterday trying to figure this out. The commit "null" is the clue something is wrong.

I ssh into each of my cameras and had:

cd /system/sdcard/

cat VERSION
{"date":"null","repo":"/","branch":"master","commit":"null"}

Same null message you had. Not sure when this stopped working. I created a GitHub token (classic type) for the cams to use for updates as the default (anonymous maybe?) seems to be rate limited and was silently failing.

Ran the update script with my github ID & token I created for the cams to use:

./autoupdate.sh -u reefland:<git_hub_token>

And I saw the 1st line, it was updating to the latest commit:

epo has changed. Upgrade to last commit cd80244
autoupdate.sh is up to date.
run.sh is up to date.
uEnv.bootfromnand.t20l.txt is up to date.
uEnv.bootfromnand.txt is up to date.
uEnv.bootfromsdcard.t20l.txt is up to date.
uEnv.bootfromsdcard.txt is up to date.
bin/README.md is up to date.

...

stopping /system/sdcard/controlscripts/telegram-bot
stopping /system/sdcard/controlscripts/telnet_server
stopping /system/sdcard/controlscripts/timelapse
--------------- Updating files ----------
---------------    Reboot    ------------
A reboot is needed, do you want to reboot now?
[Y]es or [N]o
Y

After rebooting the camera:

cd /system/sdcard/

cat VERSION
{"date":"2023-11-05T12:03:16Z","repo":"EliasKotlyar/Xiaomi-Dafang-Hacks","branch":"master","commit":"cd80244"}

You can see the config/entity name changes reflected in MQTT Explorer within seconds if you have that. After upgrading each camera, bounced HA and warning message was gone.

jonwaland commented 8 months ago

upgraded and rebooted cameras - restarted HA - no error - thanks @reefland !

TheZoker commented 6 months ago

I think this error can be closed now