vanackej / risco-mqtt-local

Provide Risco alarm system integration to Home assistant using local TCP communication (no cloud required) and MQTT
MIT License
24 stars 11 forks source link

mqtt auto discovery problem #11

Closed kkmaslowski closed 2 years ago

kkmaslowski commented 2 years ago

Hi. Zones with polish letters (ą,ę, etc) and other characters like dot (.) cannot be autoregistered. I see warning in Home Assistant log and entity is not added:

2022-01-13 10:05:05 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Received message on illegal discovery topic 'homeassistant/binary_sensor/Garaż/11/config'
2022-01-13 10:16:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Received message on illegal discovery topic 'homeassistant/binary_sensor/P.Klary/8/config'

I think that for auto configuration object_id should be based on unique_id like risco-alarm-panel-1-zone-7, not the current name of zone (P.Franka): 2022-01-13 10:16:21 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/binary_sensor/P.Franka/7/config: b'{"availability":{"topic":"riscopanel/alarm/status"},"unique_id":"risco-alarm-panel-1-zone-7","payload_on":"1","payload_off":"0","device_class":"motion","qos":1,"state_topic":"riscopanel/alarm/1/sensor/7/status","json_attributes_topic":"riscopanel/alarm/1/sensor/7","name":"P.Franka"}'

See: https://www.home-assistant.io/docs/mqtt/discovery/#discovery-topic <object_id>: The ID of the device. This is only to allow for separate topics for each device and is not used for the entity_id. The ID of the device must only consist of characters from the character class [a-zA-Z0-9_-] (alphanumerics, underscore and hyphen). This will allow adding partitions with any name.

vanackej commented 2 years ago

I made inclusion of zone label in discovery topic name optional. Disabled by default. Try 0.3.3

kkmaslowski commented 2 years ago

Works good, thanks for quick fix