A quick approach to mqtt in Home Assistant:
For light:
Code
light:
- platform: mqtt
schema: template
name: "switch1"
unique_id: "shellypro4pm-XXXXXXXXXXXX-switch-0"
command_topic: "shellypro4pm-XXXXXXXXXXXX/rpc"
command_on_template: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 0, "on": true}}'
command_off_template: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 0, "on": false}}'
state_topic: "shellypro4pm-XXXXXXXXXXXX/status/switch:0"
state_template: "{% if value_json.output %}on{% else %}off{% endif %}"
json_attributes_topic: "shellypro4pm-XXXXXXXXXXXX/status/switch:0"
qos: 1
Alles anzeigen
for switch:
Code
switch:
- platform: mqtt
name: "switch1
unique_id: "shellypro4pm-XXXXXXXXXXXX-switch-1"
command_topic: "shellypro4pm-XXXXXXXXXXXX/rpc"
payload_on: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 1, "on": true}}'
payload_off: '{"id": 1, "src":"homeassistant", "method": "Switch.Set", "params": {"id": 1, "on": false}}'
state_topic: "shellypro4pm-XXXXXXXXXXXX/status/switch:1"
value_template: "{{ value_json.output }}"
state_on: 'true'
state_off: 'false'
json_attributes_topic: "shellypro4pm-XXXXXXXXXXXX/status/switch:1"
qos: 1
Alles anzeigen
On shelly mqtt web config: Generic status update over MQTT: ENABLE
Hope it helps.