mqtt-home / miele-to-mqtt-gw

Apache License 2.0
10 stars 2 forks source link

MQTT auto discovery #136

Open philipparndt opened 1 year ago

philipparndt commented 1 year ago

Add MQTT auto discovery, so that Home Assistant can detect the devices.

See: https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery

cvc90 commented 1 year ago

Hi! I think there are many similar applications that can serve as an example, such as PS5-MQTT or Docker2MQTT.

I think this part of esphome Wiki can help you better understand MQTT message conversion.

I hope I can help you with this information, if you need anything else, let me know and I'll be happy to help you.

I show you an example of the information extracted from MQTT Explore

Example "Topic" ps5-mqtt/id_device --> (name_app/id_device)

{"power":"AWAKE","device_status":"online","activity":"idle"}

Example "auto discovery" homeassistant/sensor/id_device/activity/config --> (prefix_discovery/type/id_device/activity/config)

{"availability":[{"topic":"ps5-mqtt/name_device","value_template":"{{ value_json.device_status }}"}],"unique_id":"name_device_activity_ps5mqtt","state_topic":"ps5-mqtt/id_device","name":"PS5 activity","device":{"manufacturer":"Sony","model":"Playstation 5","name":"PS5","identifiers":["id_device"],"connections":[["ip","192.168.0.xx"]],"sw_version":"xxxxxxx"},"enabled_by_default":true,"json_attributes_topic":"ps5-mqtt/xxxxxx","value_template":"{{ value_json.activity }}"}

Example "Topic" docker2mqtt/Docker2MQTT/MIELE-GW/memory_usage/state --> (name_app/name_app/device-docker/memory_usage/state)

0.02

Example "auto discovery" homeassistant/sensor/docker2mqtt/docker_Docker2MQTT_MIELE-GW_memory_usage --> (prefix_discovery/type/name_app/name_app_device-docker_memory_usage/state)

{"availability_topic":"docker2mqtt/Docker2MQTT/MIELE-GW/lwt","device":{"identifiers":["docker_Docker2MQTT_MIELE-GW"],"manufacturer":"docker2mqtt","model":"docker","name":"docker_Docker2MQTT_MIELE-GW"},"name":"docker_Docker2MQTT_MIELE-GW_memory_usage","payload_available":"Online","payload_not_available":"Offline","platform":"mqtt","state_topic":"docker2mqtt/Docker2MQTT/MIELE-GW/memory_usage/state","unique_id":"docker_Docker2MQTT_MIELE-GW_memory_usage"}

Component entities can be:

Surely most are better suited to "Sensor" but they do not have to be all "Sensor".

cvc90 commented 1 year ago

@philipparndt Hi, any news? Do you need help with more examples or to prove something?

philipparndt commented 1 year ago

Hi @cvc90 I'm currently low on time to implement this but I think the examples should help ;)