Adding Thermostat controls from Smartthings via MQTT

I am trying to control my thermostat that is paired with my Smartthings Hub, so using mqtt. I have lights, switches, and power meters all running.

I just can’t find out what the correct syntax or setup would be for my config.yaml file.

Has anyone used a thermostat connected through smarttthings in their system, or could help me out?

@bigceej have you figured this out yet? I’m working on this myself…

I’m having the same issue, has anyone had any success?

Below is the code from the smartthings app, maybe that will shed some light.

"thermostat": [
    name: "Thermostat",
    capability: "capability.thermostat",
    attributes: [
        "temperature",
        "heatingSetpoint",
        "coolingSetpoint",
        "thermostatSetpoint",
        "thermostatMode",
        "thermostatFanMode",
        "thermostatOperatingState"
    ],
    action: "actionThermostat"
],
"thermostatCoolingSetpoint": [
    name: "Thermostat Cooling Setpoint",
    capability: "capability.thermostatCoolingSetpoint",
    attributes: [
        "coolingSetpoint"
    ],
    action: "actionCoolingThermostat"
],
"thermostatFanMode": [
    name: "Thermostat Fan Mode",
    capability: "capability.thermostatFanMode",
    attributes: [
        "thermostatFanMode"
    ],
    action: "actionThermostatFan"
],
"thermostatHeatingSetpoint": [
    name: "Thermostat Heating Setpoint",
    capability: "capability.thermostatHeatingSetpoint",
    attributes: [
        "heatingSetpoint"
    ],
    action: "actionHeatingThermostat"
],
"thermostatMode": [
    name: "Thermostat Mode",
    capability: "capability.thermostatMode",
    attributes: [
        "thermostatMode"
    ],
    action: "actionThermostatMode"
],
"thermostatOperatingState": [
    name: "Thermostat Operating State",
    capability: "capability.thermostatOperatingState",
    attributes: [
        "thermostatOperatingState"
    ]
],
"thermostatSetpoint": [
    name: "Thermostat Setpoint",
    capability: "capability.thermostatSetpoint",
    attributes: [
        "thermostatSetpoint"
    ]
],

that’s how i did it, and seems to work. i’ve got some input_selects to set a different temp or mode. here’s my config, although i don’t currently get the humidity state to come over, so still debugging that. “House” is the name of the thermostat device.

# House Thermostat
  - platform: mqtt
    name: House Temperature
    state_topic: "smartthings/House/temperature"
    command_topic: "smartthings/House/temperature"
    unit_of_measurement: 'F'
  - platform: mqtt
    name: Mode
    state_topic: "smartthings/House/thermostatMode"   # auto | cool | heat
  - platform: mqtt
    name: Current State
    state_topic: "smartthings/House/thermostatOperatingState"   # cooling | heating | idle
  - platform: mqtt
    name: thermostat Setpoint
    state_topic: "smartthings/House/thermostatSetpoint"
    command_topic: "smartthings/House/thermostatSetpoint"
    unit_of_measurement: 'F'
  - platform: mqtt
    name: House Humidity
    state_topic: "smartthings/House/humidity"
    unit_of_measurement: '%'

I have tried the new MQTT climate function and that seems to only half work, it does nothing to update the thermostat and does not even post the correct payloads that I’ve specified. There seem to be posts of people saying they have this working but absolutely nothing about how to get it working. Posting new data to these topics does not affect the thermostat at all.

is the thermostat device assigned in the smartthings MQTT bridge app on your phone?

add the following to your config so you can see mqtt messages in your hass log file.

logger:
  default: warning
  logs:
    homeassistant.components.mqtt: debug

what kind of device do you have?

post your config

OK, so I finally had the time to sit down and sort it out. I had to pretty much build the thermostat interface from scratch because the default MQTT Climate controls do not work with my thermostat. The reason for that is that mine doesn’t have a single target temperature, it has a separate heating and cooling target and those must be set separately. I could probably create an automation that changes the setpoint for whichever mode it is in, but then I could never use auto mode if I wanted to.

If anyone has questions about this code please just ask, sorry if the formatting got messed up. One big tip for sending payload over MQTT, make sure ON is in the code as “ON” with quotes, otherwise HASS sends True as the payload.

The MQTT topics should pretty much be the same for you, but my thermostat is named “Thermostat” which you’ll need to change to match yours in the middle of the topic. EX: smartthings/THENAMEOFYOURTHERMOSTAT/tempurature

Configuration.yaml

#These are the sensors for the temperature, humidity, current state, and battery level. One way communication

 sensor: #DO NOT DUPLICATE (only one of these should be in your configuration.yaml)
  -  platform: mqtt
    name: "East Hall Temperature"
    state_topic: "smartthings/Thermostat/temperature"
    unit_of_measurement: '°F'

  - platform: mqtt
    name: "East Hall Thermostat Current State"
    state_topic: "smartthings/Thermostat/thermostatOperatingState"   # cooling | heating | idle

  - platform: mqtt
    name: "East Hall Humidity"
    state_topic: "smartthings/Thermostat/humidity"
    unit_of_measurement: '%'

  - platform: mqtt
    name: "East Hall Thermostat Battery"
    state_topic: "smartthings/Thermostat/battery"
    unit_of_measurement: '%'
 
#This is the switch for the fan mode, auto or on.
switch: #DO NOT DUPLICATE (only one of these should be in your configuration.yaml)
  - platform: mqtt
    name: "East Hall Thermostat fan Mode"
    state_topic: "smartthings/Thermostat/thermostatFanMode"   # auto | on
    command_topic: "smartthings/Thermostat/thermostatFanMode"   # auto | on
    payload_on: "on"
    payload_off: "auto"

##This is the drop down box for the thermostat modes.
input_select: #DO NOT DUPLICATE (only one of these should be in your configuration.yaml)
  thermostat_mode:
    name: Thermostat Mode
    options:
      - "auto"
      - "off"
      - "cool"
      - "heat"
    icon: mdi:air-conditioner

#These are the sliders for setting your heating or cooling target`Preformatted text`
input_number: DO NOT DUPLICATE (only one of these should be in your configuration.yaml)
heating_target:
    name: Heating Target
    initial: 68
    min: 64
    max: 72
    step: 1

 cooling_target:
    name: Cooling Target
    initial: 76
    min: 72
    max: 78
    step: 1

automation: #DO NOT DUPLICATE (only one of these should be in your configuration.yaml)

## These two automations make sure the dropdown box and thermostat are always the same no matter where you change it.
  - alias: Set Thermostat Mode Selector
    trigger:
      -  platform: mqtt
         topic: "smartthings/Thermostat/thermostatMode"
    action:
      -  service: input_select.select_option
         data_template:
           entity_id: input_select.thermostat_mode
           option: '{{ trigger.payload }}'
      
  - alias: Set Thermostat Mode
    trigger:
      -  platform: state
         entity_id: input_select.thermostat_mode
    action:
      -  service: mqtt.publish
         data_template:
           topic: "smartthings/Thermostat/thermostatMode"
           retain: true
           payload: '{{ states.input_select.thermostat_mode.state }}'

## These two automations make sure the heating slider and thermostat are always the same no matter where you change it.
  - alias: Heating target set
    trigger:
      -  platform: mqtt
         topic: "smartthings/Thermostat/heatingSetpoint"
    action:
       -  service: input_number.set_value
          data_template:
            entity_id: input_number.heating_target
            value: '{{ trigger.payload}}'

 - alias: Set heating target
    trigger:
      -  platform: state
         entity_id: input_number.heating_target
    action:
      -  service: mqtt.publish
         data_template:
           topic: "smartthings/Thermostat/heatingSetpoint"
           retain: true
           payload: '{{ states.input_number.heating_target.state | int }}'

## These two automations make sure the cooling slider and thermostat are always the same no matter where you change it.
  - alias: Cooling target set
    trigger:
      -  platform: mqtt
         topic: "smartthings/Thermostat/coolingSetpoint"
    action:
       -  service: input_number.set_value
          data_template:
            entity_id: input_number.cooling_target
            value: '{{ trigger.payload}}'
 
 - alias: Set cooling target
    trigger:
      -  platform: state
         entity_id: input_number.cooling_target
    action:
      -  service: mqtt.publish
         data_template:
           topic: "smartthings/Thermostat/coolingSetpoint"
           retain: true
           payload: '{{ states.input_number.cooling_target.state | int }}'

group: #DO NOT DUPLICATE (only one of these should be in your configuration.yaml)
East Hall Thermostat:
  - sensor.east_hall_temperature
  - sensor.east_hall_humidity
  - input_select.thermostat_mode
  - switch.east_hall_thermostat_fan_mode
  - sensor.east_hall_thermostat_current_state
  - input_number.heating_target
  - input_number.cooling_target
  - sensor.east_hall_thermostat_battery

customize: #DO NOT DUPLICATE (only one of these should be in your configuration.yaml)
     switch.east_hall_thermostat_fan_mode:
       friendly_name: 'House Fan'
       icon: mdi:fan
     binary_sensor.bedroom_motion_detector:
       google_assistant: false
     sensor.east_hall_humidity:
       icon: mdi:water-percent
     sensor.east_hall_thermostat_battery:
       icon: mdi:battery
3 Likes

Thanks for posting this. I’m trying to implement it and am getting the following:

Failed config
General Errors:
- Component not found: cooling_target
- Setup failed for cooling_target: Component not found.
- Component not found: heating_target
- Setup failed for heating_target: Component not found.

Any idea what I’m doing wrong?

Disregard, I was missing input_number: :frowning:

I was just coming to make sure you had that line. Glad you got it working!

found a few things that weren’t working for me…I had to put /state or /cmd at the end of a lot of your topics, but other than that, it’s working like a charm! Now, to find out if I can set auto temperatures based on this…

EDIT: looks like you can, lol.

Yup, I use them in automations and scripts. Piece of advice, never hard code temperatures into automations or scripts. Your comfort zone will fluctuate so it’s best to set defaults up as sliders and then adjust those as your preferences shift. I have a bunch of sliders for default temps whether I’m away, awake, or asleep.

1 Like

Yup!! I have a fairly wide comfort level put in for now. I’ll have to take a look at scenes and automations later on, but I just wanted to see if this smartthings setup and some sort of auto temperature would play well together.

Hey, I know this is from a while ago now, but can you send me one of those automations you used for generic thermostat? Thought I had it down, apparently I missed something…

@roofuskit I found something I’m trying to fix right now - so the slider works great if it’s the only device you are using to change the temperature, but if you want to use automation, I’ve noticed it doesn’t change…at least, not the way I tried using automation. I also noticed that the thermostat mode selector doesn’t change. My solution is below

Sensors:

- platform: mqtt
  name: "Thermostat Current SetPoint"
  state_topic: "smartthings/Thermostat/thermostatSetpoint/state"
  icon: mdi:thermometer
  unit_of_measurement: "°F"

- platform: mqtt
  name: "Thermostat Current Mode"
  state_topic: "smartthings/Thermostat/thermostatMode/state" 

Automations:

alias: Get mode to target
trigger:
  - platform: event
    event_type: state_changed
    event_data:
      entity_id: sensor.thermostat_current_mode
action:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.thermostat_mode
      option: '{{ states.sensor.thermostat_current_mode.state }}'

alias: Get setpoint to target
trigger:
  - platform: event
    event_type: state_changed
    event_data:
      entity_id: sensor.thermostat_current_setpoint
action:
  - service: input_number.set_value
    data_template:
      entity_id: 
        - input_number.heating_target
        - input_number.cooling_target
      value: "{{ states.sensor.thermostat_current_setpoint.state | int }}"

Thanks for posting this. I have everything working except setting the heating and cooling targets. The sliders update but for some reason the data does not get published out to the thermostat.

Any ideas on this would be appreciated.