Generic_thermostat activate heat using mqtt

I would like to activate Heat mode using mqtt for a generic thermostat

I dont see any mqtt topics being published by the generic thermostat.

what is the mqtt command to activate the heat mode just like it can be done using the UI?

thank you

  - platform: generic_thermostat
    unique_id: thermostat_dormitorio
    name: Termostato Habitacion Dormitorio
    heater: switch.habitacion_dormitorio_radiador
    target_sensor: sensor.habitacion_dormitorio_temperatura
    min_temp: 15
    max_temp: 22
    ac_mode: false
    target_temp: 19
    cold_tolerance: 0.3
    hot_tolerance: 0
    min_cycle_duration:
      seconds: 5
    keep_alive:
      minutes: 3
    initial_hvac_mode: "off"
    away_temp: 15
    precision: 0.1

While Home Assistant can both send and receive MQTT payloads, MQTT is not the normal method for communicating internally. If you want, you can set up an automation with an MQTT trigger and the desired climate service call(s) using whatever topic and payload you want.

Thank you Didgeridrew, that did the trick.

How about publishing via mqtt the current status of the heat mode?

the reason I want to do it via mqtt is cause I have a small LCD on the wall which I want to give control of the thermostat by pressing a button in the lcd. this lcd is a esp32, so I need mqtt

thanks

You can publish to any topic by using the mqtt.publish service call.

Service Call Automation example
trigger:
  - platform: state
    attribute: hvac_action
    entity_id: climate.termostato_habitacion_dormitorio
    not_to:
      - unknown
      - unavailable
condition: []
action:
  - service: mqtt.publish
    data:
      topic: your/topic
      payload: >-
        {"mode": {{ trigger.to_state.attributes.hvac_action }} } 

But to control something in HA from an external device using MQTT payloads you need the opposite, you need an automation that triggers on receipt of an MQTT message and calls the appropriate climate service.

trigger:
  - platform: mqtt
    topic: "your/topic/hvac_mode"
    payload: "cool"
condition: []
action:
  - service: climate.set_hvac_mode
    target:
      entity_id: climate.termostato_habitacion_dormitorio
    data:
      hvac_mode: "{{ trigger.payload }}"
1 Like

great! the command to turn on and off works.

the trigger and value not working. i get this message

Error: Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘to_state’

alias: Baño arriba - termostato - publish state
description: ""
trigger:
  - platform: state
    attribute: hvac_mode
    entity_id: climate.termostato_bano_arriba
condition: []
action:
  - service: mqtt.publish
    data:
      topic: casa/baño_arriba/state
      payload: "{\"mode\": {{ trigger.to_state.attributes.hvac_mode }} } "
mode: single

Sorry, the correct attribute is hvac_action not hvac_mode… I’ve corrected the previous post.

1 Like