Status change and MQTT publication

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?

as a trigger I chose this


But what do I take for Action?

Call a service, and then mqtt publish

1 Like

I have to send the value of Fan.
But how to write this?


Replace {{ states(“select.blitzwolf_frigo_power_outage_memory”) }} with the correct entity_id

Hello
As you can see I don’t have the boxes
Payload Template
Qos

As often the advanced mode is not activated in User
image
et voila

To know the ID
image

My id is climate.chambre_parents

But the Fan ID how to find it?

It is the attribute fan_mode

You will need

{{ state_attr("climate.chambre_parents", "fan_mode") }}
1 Like

Why is the recording not kept?

Templates not supported in visual editor ? Switch to yaml

The system has successfully updated the file automations.yaml but without the part
{{ state_attr("climate.chambre_parents", "fan_mode") }}
image

- 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

1 Like

Oups
image

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


1 Like

C’est Bon :wink:

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: off

friendly_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