To do this, the Topic from this plugin needs to be in the format: <discovery_prefix>/<component>/<object_id>/config
where:
<discovery_prefix> : The prefix for the discovery topic, e.g. indigo
<component> : One of the supported MQTT components, eg. binary_sensor or light
<object_id> : The ID of the device where we could use the Indigo Device ID
See: https://www.home-assistant.io/docs/mqtt/discovery/
In the Indigo MQTT Broker Device config, we could set the Topic in the Device Publishing Template as:
- Code: Select all
indigo/light/{{deviceId}}/config
Based on haavarda's work with dimmable devices, we would need to make the template Payload as:
- Code: Select all
{‘name’: ‘{{name}}’, ‘unique_id’: ‘{{deviceId}}’,’state_topic’: ‘indigo/devices/{{deviceId}}/update’,’command_topic’: ‘indigo/devices/{{deviceId}}/command/set’,’brightness_state_topic’: ‘indigo/devices/{{deviceId}}/update’,’brightness_command_topic’: ‘indigo/devices/{{deviceId}}/command/brightness’,’state_value_template’: ‘{{ “on” if value_json.states.onOffState == "True" else "off" }}’,’brightness_value_template’: ‘{{value_json.states.brightnessLevel}}’,’qos’: 0,’payload_on’: ‘on’,’payload_off’: ‘off’}
Message 1508 received on indigo/light/1121785643/config at 12:28 PM:
{‘name’: ‘Dining Room Desk Light’, ‘unique_id’: ‘1121785643’,’state_topic’: ‘indigo/devices/1121785643/update’,’command_topic’: ‘indigo/devices/1121785643/command/set’,’brightness_state_topic’: ‘indigo/devices/1121785643/update’,’brightness_command_topic’: ‘indigo/devices/1121785643/command/brightness’,’state_value_template’: ‘’,’brightness_value_template’: ‘’,’qos’: 0,’payload_on’: ‘on’,’payload_off’: ‘off’}
QoS: 0 - Retain: false
To get MQTT Discovery to work and automatically create devices in Home Assistant, I would need my Home Assistant configuration.yaml file to be similar to:
- Code: Select all
# MQTT Broker
mqtt:
broker: localhost
port: 1883
username: whatever
password: foobar
discovery: true
discovery_prefix: indigo
mqtt_eventstream:
publish_topic: homeassistant
subscribe_topic: indigo/devices/#
{{ “light” if value_json.states.hasOwnProperty(“brightnessLevel”) else “binary_sensor” }}
But this does not work.
Also, by modifying the Device Publishing Template, it appears to change every message sent from Indigo to Home Assistant. I was hoping perhaps as the name "Device Publishing Template" suggests that the Plugin would send out a list of all the Indigo devices that would then be modified by this template and then separately send out device update status messages as needed separately so that the device states, etc. are not filtered-out by the template and reach Home Assistant.
Please can you help me out here so that I can achieve this somehow?