fmartinou / tydom2mqtt

Deltadore Tydom to MQTT Bridge
https://fmartinou.github.io/tydom2mqtt/
MIT License
98 stars 57 forks source link

[Regression] entity and sensor names don't use Tydom-defined names anymore #204

Open kcgthb opened 4 months ago

kcgthb commented 4 months ago

Hi!

It looks like after a recent update (I'm running 3.5.2), the names of the MQTT devices, entities and devices that are automatically discovered by tydom2mqtt are using generic names (like binary_sensor.localhost_techsmokedefect, binary_sensor.localhost_techsmokedefect_2, etc), instead of the customized names defined in the Tydom configuration.

For instance, a smoke detector called "Fumée Séjour" in the Tydom internal config is discovered with its Tydom name by tydom2mqtt:

2024-07-17 15:46:49,955 - tydom.MessageHandler - INFO    - Device update (id=1686131033, endpoint=1686131033, name=Fumée Séjour , type=smoke)
2024-07-17 15:46:49,956 - sensors.Sensor       - INFO    - Binary sensor created / updated : techSmokeDefect OFF

but the device and sensor created in MQTT is called localhost.techSmokeDefect as shown in the screenshot below (the unique_id correctly matches the device id from the tydom2mqtt log):

image

I believe that in previous versions, devices were named in a more recognizable way, like techsmokedefect_tydom_fumee_sejour, which made things way easier: right now, when using several devices of the same type, they're all named the exact same way with a numerical suffix (_1, _2...) and to identify them, the only way is to dig into the MQTT debug info, check the entity unique_id and match that against the tydom2mqtt logs, which contain the actual device name.

Maybe that changed in #116?

So two questions:

  1. where is that localhost part coming from, and is it really pertinent?
  2. would it be possible to revert to a more user-friendly naming convention for devices, entities and sensors, so each one can be readily identified? techsmokedefect_tydom_fumee_sejour` is much better thanlocalhost.techSmokeDefect_2`, I think.

Thank you!

kcgthb commented 4 months ago

Yes, looking back at #116, I don't really understand how it improves things... :thinking:

From what I can see, all the sensors Devices (like smoke detectors, door/window magnetic contacts...) end up having a type of "" instead of "Sensor" in MQTT.

@NathanKun could you please describe what problem those changes are expected to fix?

NathanKun commented 4 months ago

Hey,

I think the PR message is pretty clear:

better name link sensor to it's parent device instead of having a device for commands and creating a new device for sensors binary sensor: accept "ON" and "OFF" value binary sensor: fix bug that treating all string as "ON" fix creating sensor overriding parent device's model

About the "better name", if I remember correctly, I removed the parent's name from the sensor's name (not the id). For instance, In the smoke detector "my_smock_detector" device page, instead of having a sensor name "my_smock_detector_smoke_detected", it is now "smoke_detected". I've also put a screenshot in the PR to illustrate the changes.

I don't have a tydom smock detector so I can't tell if it is my PR messed it up or not. But at lease with my setup (covers, heaters...) I'm pretty happy with the changes I made.

Of cause you can always fix it yourself and submit a PR, I think the owner will be happy to merge it as soon as it make sense.

kcgthb commented 4 months ago

Thanks for the additional clarification!

For instance, In the smoke detector "my_smock_detector" device page, instead of having a sensor name "my_smock_detector_smoke_detected", it is now "smoke_detected"

I see, and this is probably fine when you only have one sensor of a given type. But the issue with this approach is that when you have multiple sensors of the same type, when you list the Entities in the Settings > Devices & Entities > Entities page, you see a list sensors that all have the same name:

smoke_detector smoke_detector_1 smoke_detector_2 smoke_detector_3 etc.

That makes it quite difficult to properly identify them, and recognize which one is which.

Having the parent's name in the sensor's name makes for a better identification of each sensor, in my opinion. But I'll defer to @fmartinou here.

I'm also not sure about removing the sensor device model: all the devices associated to binary sensors (like intrusion detection, smoke or leak detectors) now show as "Manufacturer: Delta Dore, Model: 'Unknown'" in the Settings > Devices & Entities > Devices list.

image

Isn't there a way to keep setting the sensors' model as "Sensor" without affecting the parent?

Thanks!