Switching on/off radiator with TRÅDFRI control, according to temperature of Aqara sensor

Hi all,
after the help I received in my first post I have installed and configured my device correctly as follows:
- Raspberry Pi 4 with HomeAssistant (last version)
- Xiaomi Aqara Smart Air Pressure sensor Zigbee
- Ikea TRÅDFRI Wireless control outlet Zigbee
Aqara and Tradfri are managed with DeConz App with ConBee II as gateway.
My goal is for tradfri to turn on/off (connected to radiator) based on conditions such as temperature and time.
I tried using the following automations, following this post.
I have activated both but it doesn’t work.
Does anyone have any suggestions?
Thanks and have a nice weekend

Here is how I set up the two automations:

#Heater OFF/ON Living Room
alias: 'Heater OFF Living Room'
description: OFF from 22.5
trigger:
  - platform: time
    at: '05:30:00'
  - platform: numeric_state
    entity_id: sensor.living_room_tdeg_and_humidity
    above: '22.5'
    for:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on
  - condition: time
    after: '05:29:00'
    before: '23:00:00'
  - condition: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    above: '22.5'
action:
  - service: switch.turn_off
    target:
      device_id: cf79d3b5eac3e08a072c73021023bc48
mode: single


alias: Heater ON Living Room
description: 'ON from 19.5° '.
trigger:
  - platform: time
    at: '05:30:00'
  - platform: numeric_state
    entity_id: sensor.living_room_tdeg_and_humidity
    below: '19.5'
condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'off'
  - condition: time
    after: '05:29:00'
    before: '23:00:00'
  - condition: numeric_state
    entity_id: sensor.soggiorno_tdeg_and_humidity
    below: '19.5'
action:
  - service: switch.turn_on
    target:
      device_id: cf79d3b5eac3e08a072c73021023bc48
mode: single

Please edit and format your post correctly. See point 11 here. How to help us help you - or How to ask a good question

Sorry. Hoping is correct now.
Thank you

You are missing a quote at the end of this:

condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on
              ^
              |

It actually shows up really well now that you have formatted your post. Look closely at which parts are red and which parts are white.

Screenshot 2021-11-28 at 00-22-04 Switching on off radiator with TRÅDFRI control, according to temperature of Aqara sensor ...

Everything to the left of the : should be white. If it isn’t it means you are missing a quote somewhere just before that.

Difficult to see here though:

  • condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on
  • condition: time

That is why formating your post is important.

There could be other issues, I haven’t looked beyond that.

Thank you Tom,
I have corrected the quote. At the moment, however, it does not seem to work. This is the logbook when I run the automation manually. Normally it has to be off.

Heater OFF Living Room has been triggered by service automation.trigger
6:05:00 PM - 2 minutes ago - Show trace
Heater OFF Living Room has been triggered by service automation.trigger
6:02:54 PM - 4 minutes ago - Show trace
Heater OFF Living Room turned on
6:02:48 PM - 4 minutes ago
Heater OFF Living Room became unavailable
6:02:48 PM - 4 minutes ago
Heater OFF Living Room turned off
6:02:48 PM - 4 minutes ago`

Running the automation manually skips the conditions and just executes the actions. You can override this default behaviour by using the Developer Tools Services page.

Hello everyone, what I have set up so far has not worked. I have set up these new automations, but they only work if I activate them manually…
I would like the system to check the temperature every hour and switch on or off if it is above or below 21 degrees.
This should work from 05:30 to 23:00 and be switched off from 23:00 to 5:30.
What am I doing wrong?

alias: 'Heater Off Living Room '
description: OFF above 21
trigger:
  - platform: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    above: '21'
    for:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - platform: time
    at: '05:30:00'
condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on'
  - condition: time
    after: '05:30:00'
    before: '23:30:00'
  - condition: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    above: '21'
action:
  - type: turn_off
    device_id: cf79d3b5eac3e08a072c73021023bc48
    entity_id: switch.on_off_plug_in_unit_1
    domain: switch
mode: single

alias: Heater ON Living Room
description: 'ON below 21 '
trigger:
  - platform: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    below: '21'
    for:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  - platform: time
    at: '05:30:00'
condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on'
  - condition: time
    after: '05:30:00'
    before: '23:30:00'
  - condition: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    below: '21'
action:
  - type: turn_on
    device_id: cf79d3b5eac3e08a072c73021023bc48
    entity_id: switch.on_off_plug_in_unit_1
    domain: switch
mode: single

Try it like this:

trigger:
  - platform: state
    entity_id: sensor.soggiorno_tdeg_e_umidita
  - platform: time
    at: '05:30:00'
  - platform: homeassistant
    event: start
condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on'
  - condition: time
    after: '05:30:00'
    before: '23:30:00'
  - condition: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    above: '21'
action:
...etc

This will check the conditions every time the sensor changes and at the beginning of your time period, in case the temperature is already above 21 when this occurs. Do likewise for the other automation. Also I added a home assistant start trigger, in case the temperature changes while home assistant is off or restarting.

Thank you Tom.
I’ll check and give feedback.

Good morning,
Yesterday I disabled the previous automations that didn’t work and set up two new ones (Living Room off > 22° & Living Room on < 19°), based on Tom’s suggestion.

alias: Living Room off > 22°
description: ''
trigger:
  - platform: state
    entity_id: sensor.soggiorno_tdeg_e_umidita
  - platform: time
    at: '05:30:00'
  - platform: homeassistant
    event: start
condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on'
  - condition: time
    after: '05:30:00'
    before: '23:30:00'
  - condition: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    above: '22'
action:
  - type: turn_off
    device_id: cf79d3b5eac3e08a072c73021023bc48
    entity_id: switch.on_off_plug_in_unit_1
    domain: switch
mode: single

alias: Living Room on < 19°
description: ''
trigger:
  - platform: state
    entity_id: sensor.soggiorno_tdeg_e_umidita
  - platform: time
    at: '05:30:00'
  - platform: homeassistant
    event: start
condition:
  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on'
  - condition: time
    after: '05:30:00'
    before: '23:30:00'
  - condition: numeric_state
    entity_id: sensor.soggiorno_tdeg_e_umidita
    below: '19'
action:
  - type: turn_on
    device_id: cf79d3b5eac3e08a072c73021023bc48
    entity_id: switch.on_off_plug_in_unit_1
    domain: switch
mode: single

I enabled them and they worked correctly until 11.30pm. Of course this morning I would have expected the radiator to be on as the temperature dropped but it wasn’t, it was off and I had to activate it manually.
Is there something wrong with the configuration?

Yes. This condition:

  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'on'

Should be:

  - condition: state
    entity_id: switch.on_off_plug_in_unit_1
    state: 'off'

For the Living Room on < 19° automation (second one).

The way you had it the radiator has to be on already for your actions to turn it on. This is not correct. The radiator has to be off, then you can turn it on (if the other conditions are met).

Hi Tom,
thanks for the feedback, I have changed from on to off and will check tomorrow morning.
Have a nice day

1 Like