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

MQTT auto discovery #136

Open
philipparndt opened this issue Jun 10, 2023 · 3 comments
Open

MQTT auto discovery #136

philipparndt opened this issue Jun 10, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@philipparndt
Copy link
Member

philipparndt commented Jun 10, 2023

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

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

  • Can someone provide examples, for topics/payload that we should send?
  • What entity component should we use? Sensor?
@cvc90
Copy link

cvc90 commented Jun 13, 2023

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:

  • Sensor
  • Switch
  • Binary_sensor
  • Button

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

@cvc90
Copy link

cvc90 commented Jun 20, 2023

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

@philipparndt
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants