#Turn heater on if temperature below a certain point, depending on if lights on or off

1 messages · Page 1 of 1 (latest)

haughty estuary
#

Ive read the documentation the best I can and am still running into issues. I want to check the status of the light every time a sensor changs. The more I dig into the documentation the more I get confused why this is not working.

In layman terms, iof the lights on and the temperature is below 75, turn the heater switch to on. If the lights off and the temperature is below 65, turn the heater on. In any state, if it goves above these numbers, turn the heater off.

#

This is what I believe should work:

alias: Temperature Control
description: Adjust heater based on temperature and light status
triggers:
  - event_type: zha_event
    event_data:
      device_ieee: 04:87:27:ff:fe:aa:3c:56
    trigger: event
  - event_type: zha_event
    event_data:
      device_ieee: 04:87:27:ff:fe:aa:39:b9
    trigger: event
  - event_type: zha_event
    event_data:
      device_ieee: 00:12:4b:00:2c:3a:28:19
    trigger: event
conditions: []
actions:
  - choose:
      - conditions:
          - condition: template
            value_template: |
              {{ states('light.00_12_4b_00_2c_3a_28_19') == 'on' }}
          - condition: numeric_state
            entity_id: sensor.04_87_27_ff_fe_aa_3c_56
            below: 80
        sequence:
          - data:
              ieee: 00:12:4b:00:2c:3a:c5:12
              cluster_id: 6
              command: 1
            action: zha.issue_zigbee_command
      - conditions:
          - condition: template
            value_template: |
              {{ states('light.00_12_4b_00_2c_3a_28_19') == 'off' }}
          - condition: numeric_state
            entity_id: sensor.04_87_27_ff_fe_aa_39_b9
            below: 65
        sequence:
          - data:
              ieee: 00:12:4b:00:2c:3a:c5:12
              cluster_id: 6
              command: 1
            action: zha.issue_zigbee_command
      - conditions:
          - condition: or
            conditions:
              - condition: numeric_state
                entity_id: sensor.04_87_27_ff_fe_aa_3c_56
                above: 75
              - condition: and
                conditions:
                  - condition: template
                    value_template: |
                      {{ states('light.00_12_4b_00_2c_3a:28:19') == 'off' }}
                  - condition: numeric_state
                    entity_id: sensor.04_87_27_ff_fe_aa_39_b9
                    above: 65
#

part2:

        sequence:
          - data:
              ieee: 00:12:4b:00:2c:3a:c5:12
              cluster_id: 6
              command: 0
            action: zha.issue_zigbee_command
mode: single
#

I turned it to 80 to test with hte lights on, the temperature right now is 77 so it should trigger

#

I had this, it kind of worked but the heater would never turn off:

alias: Temperature control
description: Low 60, high 70
triggers:
  - type: temperature
    device_id: 57dbd068f3a37fd49ae6c158fe7d4143
    entity_id: a48d3723d3a04730169b2441722ad156
    domain: sensor
    below: 73
    above: 50
    trigger: device
  - type: temperature
    device_id: 58b23f6d7d7eb6ae9f21c4d73ca6b704
    entity_id: 2aaa61136557ecc23bfc7e56a92d4eb8
    domain: sensor
    below: 73
    above: 50
    trigger: device
conditions:
  - condition: device
    type: is_on
    device_id: d9f01304fdba20139d0f783b31c41240
    entity_id: e7d17ac9bcc98989d9de963f6aa74feb
    domain: switch
    enabled: false
actions:
  - type: turn_on
    device_id: 75887b41474e0a17ef4c7a528d3c6b11
    entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
    domain: switch
mode: single
#

I lost where I can find the device_id so I went to what I saw here and started using IEEE instead

tardy vector
#

You should give your lights and sensors some reasonable/readable entity ids, it would be much more readable. Using raw zha_events as triggers for a sensor is pretty unusual too.

signal charm
#

The logic is pretty simple
Triggers:
Trigger 1 on temperature sensor state change
Trigger 2 on light state change
Actions:
Variable - target_temperature = "{{75 if states('lights') | bool else 65}}"
If temperature sensor < target_temperature - turn on
Else - turn off

You might want to add some hysteresis to it so it's not constantly ping-ponging back and forth, or make it be below/above the set point for X minutes or something but that's the core of the logic

haughty estuary
haughty estuary
tardy vector
#

Just a state trigger w/ your entity id.

haughty estuary
#

When I get home I'll see if I can find it in the docs. Thank you

tardy vector
#

Are you trying the visual automation editor? Should be pretty straightforward.

haughty estuary
#

The gui kept on falling for me, but I haven't tried it since... V12?

#

I believe at the time it couldn't handle and statements or nested

#

I could easily do this in Python but was struggling with getting it setup

haughty estuary
signal charm
#

Whoever told you that was an idiot

haughty estuary
#

Lol

signal charm
#

had to do something a little weird with the numeric state check, rather than state > target_temperature, checks state - target_temperature > 0 - you could also substitute in the variable template directly here if you want, I just prefer splitting it out

haughty estuary
#

@signal charm Im in the gui now but dont see ways to chain things. I hve it setup so:
when my lower env tmperature changes and its above 50 but below 80 and if the lights on, turn on the heater. But I am not seeing where I can add an else or more details

#

I have two sensors right now, one lower and one upper. I am just going to use the lower atm to see if I can make it easier to understand

signal charm
#

Use an if action block in the "then do" section rather than the "and if" section

#

The condition section is there to prevent the automation running and I generally try to avoid using it

haughty estuary
#

Alright

#

So in the "then do" section, dont use conditions either? Or were you specifiying just dont do it in the "and if" section"?

#
alias: New automation
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.lower_environment_sensor_temperature
  - trigger: numeric_state
    entity_id:
      - sensor.lower_environment_sensor_temperature
    below: 75
conditions: []
actions:
  - if:
      - condition: device
        type: is_on
        device_id: d9f01304fdba20139d0f783b31c41240
        entity_id: e7d17ac9bcc98989d9de963f6aa74feb
        domain: switch
    then:
      - type: turn_on
        device_id: 75887b41474e0a17ef4c7a528d3c6b11
        entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
        domain: switch
    else:
      - if:
          - condition: device
            type: is_off
            device_id: d9f01304fdba20139d0f783b31c41240
            entity_id: e7d17ac9bcc98989d9de963f6aa74feb
            domain: switch
          - type: is_temperature
            condition: device
            device_id: 57dbd068f3a37fd49ae6c158fe7d4143
            entity_id: a48d3723d3a04730169b2441722ad156
            domain: sensor
            above: 0
            below: 65
        then:
          - type: turn_on
            device_id: 75887b41474e0a17ef4c7a528d3c6b11
            entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
            domain: switch
        else:
          - type: turn_off
            device_id: 75887b41474e0a17ef4c7a528d3c6b11
            entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
            domain: switch
  - if:
      - type: is_temperature
        condition: device
        device_id: 57dbd068f3a37fd49ae6c158fe7d4143
        entity_id: a48d3723d3a04730169b2441722ad156
        domain: sensor
        above: 79
    then:
      - type: turn_off
        device_id: 75887b41474e0a17ef4c7a528d3c6b11
        entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
        domain: switch
mode: single
#

maybe that if will do it, the current temp is 78 in there, I want to see if it will turn on and warm it up a degree then turn off

#

Is there a way to add comments so I know whats what? The device / entity_id is rather confusing

signal charm
#

Try to not use device ones if you can. E.g switch.turn_on/off works directly on an entity_id so is much more readable

haughty estuary
#

The gui I mean, so how should I edit it out to make it more reliable? I am not sure how or where I would change this out in the gui, unless you mean edit it in the yaml

#

And (sorry for all the questions, doing my best here), when would you want to use a device_id instead of switch?

tardy vector
signal charm
haughty estuary
#

Oh damn I see it now

#

Would it be better to use the switch option too to se if my lights on or off?

#
alias: New automation
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.lower_environment_sensor_temperature
  - trigger: numeric_state
    entity_id:
      - sensor.lower_environment_sensor_temperature
    below: 77
conditions: []
actions:
  - if:
      - condition: device
        type: is_on
        device_id: d9f01304fdba20139d0f783b31c41240
        entity_id: e7d17ac9bcc98989d9de963f6aa74feb
        domain: switch
    then:
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          device_id: 75887b41474e0a17ef4c7a528d3c6b11
    else:
      - if:
          - condition: device
            type: is_off
            device_id: d9f01304fdba20139d0f783b31c41240
            entity_id: e7d17ac9bcc98989d9de963f6aa74feb
            domain: switch
          - type: is_temperature
            condition: device
            device_id: 57dbd068f3a37fd49ae6c158fe7d4143
            entity_id: a48d3723d3a04730169b2441722ad156
            domain: sensor
            above: 0
            below: 65
        then:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              device_id: 75887b41474e0a17ef4c7a528d3c6b11
        else:
          - type: turn_off
            device_id: 75887b41474e0a17ef4c7a528d3c6b11
            entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
            domain: switch
  - if:
      - type: is_temperature
        condition: device
        device_id: 57dbd068f3a37fd49ae6c158fe7d4143
        entity_id: a48d3723d3a04730169b2441722ad156
        domain: sensor
        above: 77
    then:
      - action: switch.turn_off
        metadata: {}
        data: {}
        target:
          device_id: 75887b41474e0a17ef4c7a528d3c6b11
mode: single
haughty estuary
signal charm
#

change the target to the actual switch, rather than the device

#

and for the on/off - that's why i suggested using the template "{{ 75 if states('light.my_lights_entity_id') | bool(false) else 65 }}"

#

But you can use a simple state check instead if you prefer

haughty estuary
#

I just want it to work and understand the suggested solution

signal charm
#
condition: state
entity_id: binary_sensor.test_rs_latch
state: "on"
haughty estuary
#

The heater is connected to a switch

signal charm
#

ok

#

what don't you understand

haughty estuary
#

You said change the target to the actual switch. I'm trying to understand in the gui where I am going wrong and how to correct it

#

And I apologize if I seem dense. Not trying to be

#

I appreciate your help

signal charm
#
      - action: switch.turn_off
        metadata: {}
        data: {}
        target:
          device_id: 75887b41474e0a17ef4c7a528d3c6b11 < delete this line
          entity_id: <whatever your switch entity id is (the human readable one not the UUID gibberish)> < add this line
haughty estuary
#

So I have to do that in the yaml or did I miss something in the gui

signal charm
#

you don't have to do it in the yaml - if you are in the UI just use the entity selector rather than the device selector

haughty estuary
#

Ok

#

I'll go back and try to fix it here soon. Thank you again

signal charm
#

no worries

#

just one of those things you need to get used to when using a new tool

haughty estuary
#

👍

#
alias: New automation
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.lower_environment_sensor_temperature
  - trigger: numeric_state
    entity_id:
      - sensor.lower_environment_sensor_temperature
    below: 77
conditions: []
actions:
  - if:
      - condition: device
        type: is_on
        device_id: d9f01304fdba20139d0f783b31c41240
        entity_id: e7d17ac9bcc98989d9de963f6aa74feb
        domain: switch
    then:
      - action: switch.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: switch.outlet_heater_switch
    else:
      - if:
          - condition: device
            type: is_off
            device_id: d9f01304fdba20139d0f783b31c41240
            entity_id: e7d17ac9bcc98989d9de963f6aa74feb
            domain: switch
          - type: is_temperature
            condition: device
            device_id: 57dbd068f3a37fd49ae6c158fe7d4143
            entity_id: a48d3723d3a04730169b2441722ad156
            domain: sensor
            above: 0
            below: 65
        then:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.outlet_heater_switch
        else:
          - type: turn_off
            device_id: 75887b41474e0a17ef4c7a528d3c6b11
            entity_id: fdf1f4f6c68df0f6cbad0e32aed127b3
            domain: switch
  - if:
      - type: is_temperature
        condition: device
        device_id: 57dbd068f3a37fd49ae6c158fe7d4143
        entity_id: a48d3723d3a04730169b2441722ad156
        domain: sensor
        above: 77
    then:
      - action: switch.turn_off
        metadata: {}
        data: {}
        target:
          entity_id: switch.outlet_heater_switch
mode: single
#

It looks like I missed one but cant find it in the gui

#

After this Ill try and figure out the template suggestion. My biggest concern right now is this is going to turn on when I need to go here in like 30 minutes and it will just cook my plants. I may disable it for the time being

haughty estuary
#

Alright I need to run. I didn't see anything I missed but more suggestions welcome. I disabled it for now