Hello, I am new to HA.
I would like to retrieve the change of state of my Thermostat entity and published it on MQTT.
How can I do ?
Create an automation that triggers on the state of your thermostat and call the MQTT service that publishes it to the topic of your choice.
Plenty of existing samples on the forum.
What piece of the puzzle evades you?
Call a service, and then mqtt publish
It is the attribute fan_mode
You will need
{{ state_attr("climate.chambre_parents", "fan_mode") }}
The system has successfully updated the file automations.yaml
but without the part
{{ state_attr("climate.chambre_parents", "fan_mode") }}
- id: '1630600986202'
alias: Fan Clin
description: ''
trigger:
- platform: state
entity_id: climate.chambre_parents
attribute: fan_mode
condition: []
action:
- service: mqtt.publish
data:
topic: homeassistant/fan
qos: '1'
mode: single
- id: '1630600986202'
alias: Fan Clin
description: ''
trigger:
- platform: state
entity_id: climate.chambre_parents
attribute: fan_mode
condition: []
action:
- service: mqtt.publish
data:
payload_template: {{ state_attr("climate.chambre_parents", "fan_mode") }}
topic: homeassistant/fan
qos: '1'
mode: single
Oups
Forgot '
- id: '1630600986202'
alias: Fan Clin
description: ''
trigger:
- platform: state
entity_id: climate.chambre_parents
attribute: fan_mode
condition: []
action:
- service: mqtt.publish
data:
payload_template: '{{ state_attr("climate.chambre_parents", "fan_mode") }}'
topic: homeassistant/fan
qos: '1'
mode: single
C’est Bon
I would now like to publish all the states of my air conditioning at once
current_temperature: 23
temperature: 22
fan_mode: quiet
hvac_action: heating
swing_mode: offfriendly_name: Climatisation Chambre Parents
Can I combine all this information in the same Topic Mqtt?
To be useable for the receiver, you should send json in the payload when combining several messages.
However,
It’s not good
- id: '1630600986202'
alias: Fan Clin
description: ''
trigger:
- platform: state
entity_id: climate.chambre_parents
# attribute: fan_mode
condition: []
action:
- service: mqtt.publish
data:
topic: homeassistant/climatisation.parents_fan
payload_template: '{{ state_attr("climate.chambre_parents", "fan_mode") }}'
qos: '1'
data:
topic: homeassistant/climatisation.parents_hvac_action
payload_template: '{{ state_attr("climate.chambre_parents", "hvac_action") }}'
qos: '1'
mode: single