Thermostat to control switches

Hi,

I’m quite new to HA and after some hours trying to figure out my problem I thought it would be good idea to ask from fellow users.

I have BHT-1000 thermostat and a few DIY mini smart switches. HA runs on RPi4 with docker. I would like to add the thermostat to the wall and control the switches with it. The switches would turn electric radiators on and off. So the use case would be for ex I set the temp on the thermostat to 25C and according to the current room temp, switches would turn on or off.
The thermostat and switches are integrated with Tuya and so is my HA.

Is is possible to do something like that or have I misunderstood something?

Yeah, but exactly how depends on how your ‘set’ temperature is reported in homeassistant. For the sake of argument let’s say its reported as a sensor.

Then you’ll have a sensor reading that tells homeassistant what temperature you set and a sensor that tells you what the actual temperature is.

Then you just need an automation that triggers when the actual temperature is lower than the set temperature and actions turning the switch on, and triggers when the actual temperature is equal to or above the set temperature and actions turning the switch off.

1 Like

Maybe the generic thermostat fits your use case?

I have been trying to create automations but by default my thermostat outputs only one entity.

I also tried to create generic thermostat to HA, but again, how can I configure the target_sensor when my thermostat only has one entity?

Or is it possible to add something to the end or the entity id so I could specify between current and target temp?

OK, so “thermostat target temperature” is an attribute, so you can either:

  • replace the word ‘sensor’ with ‘climate entity attribute thermostat target temperature’ when referring to the set point temperature in my explanation above

Or

  • create a template sensor that mirrors the attribute, and use that sensor for your set point temperature
1 Like

Thank You for explanations!

Regarding my last post, I actually can see the different sensors/entities of the thermostat

Could someone please help me do these automations @anon43302295 pointed out?
“Then you just need an automation that triggers when the actual temperature is lower than the set temperature and actions turning the switch on, and triggers when the actual temperature is equal to or above the set temperature and actions turning the switch off.”

For ex, how do I create the automation to turn on the switch if current temp is lower than the set temp?

If you’re comparing one attribute with another then it’s a template trigger. You’re going to want to do it in yaml so the UI editor doesn’t mangle it, but presuming that the attributes are just lowercase and underscore separated versions of what that screenshot shows, your automation would be something like

trigger:
  platform: template
  value_template: >
    {{
      state_attr('climate.878608518caab5ebff6b', 'current_temperature')|float <= state_attr('climate.878608518caab5ebff6b', 'min_temp')|float
      or
      state_attr('climate.878608518caab5ebff6b', 'current_temperature')|float >= state_attr('climate.878608518caab5ebff6b', 'max_temp')|float 
    }}
action:
  service: "switch.turn_{{ 'on' if state_attr('climate.878608518caab5ebff6b', 'current_temperature')|float <= state_attr('climate.878608518caab5ebff6b', 'min_temp')|float else 'off' }}"
  entity_id: switch.YOUR_SWITCH
1 Like

Big thanks to @anon43302295 !!

I finally got it working, with config like this

- alias: "1k_radikad"
  trigger:
    platform: time_pattern
    minutes: "*"
  action:
    service: "switch.turn_{{ 'on' if state_attr('climate.878608518caab5ebff6b', 'current_temperature')|float <= state_attr('climate.878608518caab5ebff6b', 'temperature')|float else 'off' }}"
    entity_id: switch.bff4731249b92d671aarfz

this way I can use the Tuya app to set the desired temperature and radiators will be turned on/off by the every minute trigger according to the current temp. I’ll probably replace the every minute trigger to after every 10m so the relays would not flap on/off so frequently. I guess other way would be to create custom thermostat where I could also set the min_cycle_duration