#Alright part two of the script changing

1 messages · Page 1 of 1 (latest)

deft sierra
#
alias: Continuous Humidity and Temperature Control for Heater
description: Control heater based on humidity and temperature conditions continuously
trigger:
  - platform: time_pattern
    seconds: /1
condition: []
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: switch.outlet_grow_light_switch
            state: "on"
          - condition: numeric_state
            entity_id: sensor.lower_environment_humidity_sensor
            above: 60
          - condition: numeric_state
            entity_id: sensor.upper_environment_temperature_sensor
            below: 80
        sequence:
          - service: switch.turn_on
            entity_id: switch.outlet_heater_switch
          - service: logbook.log
            data:
              name: Heater Control
              message: >-
                Heater turned ON because humidity is above 60% and temperature
                is below 80°F (light ON).
      - conditions:
          - condition: state
            entity_id: switch.outlet_grow_light_switch
            state: "off"
          - condition: numeric_state
            entity_id: sensor.lower_environment_humidity_sensor
            above: 55
          - condition: numeric_state
            entity_id: sensor.upper_environment_temperature_sensor
            below: 75
        sequence:
          - service: switch.turn_on
            entity_id: switch.outlet_heater_switch
          - service: logbook.log
            data:
              name: Heater Control
              message: >-
                Heater turned ON because humidity is above 55% and temperature
                is below 75°F (light OFF).
      - conditions:
          - condition: state
            entity_id: switch.outlet_grow_light_switch
            state: "on"
          - condition: or
            conditions:
              - condition: numeric_state
                entity_id: 
#
sensor.lower_environment_humidity_sensor
                below: 60
              - condition: numeric_state
                entity_id: sensor.upper_environment_temperature_sensor
                above: 80
          - condition: state
            entity_id: switch.outlet_grow_light_switch
            state: "off"
          - condition: or
            conditions:
              - condition: numeric_state
                entity_id: sensor.lower_environment_humidity_sensor
                below: 55
              - condition: numeric_state
                entity_id: sensor.upper_environment_temperature_sensor
                above: 75
        sequence:
          - service: switch.turn_off
            entity_id: switch.outlet_heater_switch
          - service: logbook.log
            data:
              name: Heater Control
              message: Heater turned OFF because conditions were not met.
fallen robin
#

What do you see in the trace?

deft sierra
#

Nothing really useful

#

Choice "no action executed"

#

Im pretty new to this, from what Ive seen in the forums (some old) and here seem a lot more "straight forward", this one seems excessivly long

fallen robin
#

Eh, I would do it differently (checking every second is really excessive). But nothing stands out as to why it isn’t working though.

#

But, it’s not executing your actions because the conditions aren’t passing.

deft sierra
#

How would you do it different @fallen robin ? I mean, this is literally my first time trying this way/method so please feel free to tear it apart. Im fine with just an explanation and not example

deft sierra
#

Also was curious if its possible to debug better?

fallen robin
#

Sorry. Got pulled away for a few.

#

Let me read your automation again.

#

So, basically, you want the heater to turn on when the humidity is high and the temp is low and off when those conditions are reversed and the light is on or off?

deft sierra
#

@fallen robin dont worry, take your time, I appreciate it.

So when the light is on, I want the heater to turn on if the temperature and humidity are a certain point. When the light is off I went the temp aand the humidity to be different.
Light on: humidity > 60 and temp < 80 turn heater on until temp or humidity are outside that range. When the lights off that range changes from 60 to 50 and 80 to 70 for example.

fallen robin
#

Gotcha. Ok, give me a minute. I think I can give you something that’ll do that.

#

One more question, what toggles the light on/off?

#

Ok, so my approach would be to trigger off the temp and humidity changing rather than constantly checking them. The way I would do that is with a template trigger. 2 of them actually.

deft sierra
#

I was thinking about that approach but couldn't find an example

deft sierra
#

My ultimate goal is to have this all tied to the light. I want to create scenes that will last until I change it. If scene A is active, the light will be on a certain amount of time during the day with temp humidity settings for this scene (which are different than what we're working on now). But if it's scene B, the light will be on a different, shorter, amount of time and the settings were working on now will apply

fallen robin
#

I didn’t forget about this. I’m mobile for a few hours, but when I’m back on my desktop, I have some ideas for you.

fallen robin
#

Alright, so this is a tad bit more complex than I thought it was originally (always the case, right? lol).

#

But, what I think would be better is to have your light as the first trigger. If it toggles, check the humidity and temp and then toggle the heater switch. That would simplify a lot. You can do this with a couple of simple templates too.

deft sierra
fallen robin
#

So, something like {{ (states('sensor.humidity') | float(0)) >= 60 and (states('sensor.temperature') | float(0)) >= 80 }} returns a true/false and you can use that as a template trigger.

#

You could also use numeric_state triggers on the entities, but the template is a bit more concise imho.

#
triggers:
  - platform: state
    entity_id:
      - light.light
    from: "off"
    to: "on"
    id: "light_on"
  - platform: state
    entity_id:
      - light.light
    from: "on"
    to: "off"
    id: "light_off"
  - platform: template
    value_template: {{ (states('sensor.humidity') | float(0)) >= 60 and (states('sensor.temperature') | float(0)) >= 80 }}
    id: "humidity_temp_trigger"
#

Then with some conditions, you can have it in a single automation and not have to worry about using a time pattern, but only trigger when something changes.

deft sierra
fallen robin
#

Is it though? You're checking the state of something every second that's using processing for no reason. If you trigger on when the state changes, you're getting the same effect.

deft sierra
fallen robin
#

Ok, so, every time the humidity or temperature changes, the trigger is checked. This is done via the event bus in HA. If the temp or humidity haven't changed, there's no point in checking to see if they have. HA handles this for you automatically. There's no reason to check them manually every second or even every minute.

deft sierra
#

oh so when it changes it checks the state of the light

fallen robin
#

Right. Then just toggles the heater on/off based upon the state of the light.

deft sierra
#

makes sense

#

Yeah thats probably a better way to do it

fallen robin
#

And it's better for HA as well because it doesn't have to execute every second/minute/whatever.

deft sierra
#

Awesome

fallen robin
#

As you go through it, I can help you get some of the trickier parts done (if you want).

deft sierra
#

will do thank you, home soon

deft sierra
#

@fallen robin so I need to change the triggers in mine to match the changesi nyours?

fallen robin
deft sierra
deft sierra
#

Yeah I'm going to have to wait. Sorry man

fallen robin
#

I’m sorry. Been pulled into a few things today life-wise. I’ll get a basic one done and posted here and when you have time we can circle back. Sorry about that 😣

fallen robin
#

This one uses no templates, so pure UI. You'll have to change the entities to match yours, but that should give you a good starting point.

deft sierra
#

Hey @fallen robin I appreciate it. Sorry I wasnt trying to be an ass, I do much better with workind examples than I do RTM. I wasnt trying to push you when I was asking in automation. To me, templates make more sense overal. Ill give this a go and play around with it. Thank you

fallen robin
deft sierra
#

So as I am reading this, its going to turn the switch off if the light is off, I think I want to switch it to below?

action:
  - if:
      - condition: state
        entity_id: switch.outlet_grow_light_switch
        state: "on"
    then:
      - if:
          - condition: numeric_state
            entity_id: sensor.lower_environment_humidity_sensor
            above: 58
          - condition: numeric_state
            entity_id: sensor.upper_environment_temperature_sensor
            below: 80
        then:
          - service: switch.turn_on
            target:
              entity_id: switch.outlet_heater_switch
            data: {}
    else:
      - if:
          - condition: numeric_state
            entity_id: sensor.lower_environment_humidity_sensor
            above: 48
          - condition: numeric_state
            entity_id: sensor.upper_environment_temperature_sensor
            above: 65
        then:
          - service: switch.turn_off
            target:
              entity_id:
                - switch.outlet_heater_switch
            data: {}
fallen robin
#

Ah, yeah, that’s sounds about right. I wasn’t sure of the logic completely.

deft sierra
#

Im trying to keep everything warmer in the daytime as I am night, as things cool down I need ot let the room cool down too

#

Wait I guess above would work... Sorry Im pretty tired right now

fallen robin
#

That logic sounds correct to me. But, yeah, take a break and rest and come back to it. (I say that a workaholic). lol

deft sierra
#

does ha have a python plugin? lol I could do this in 2 minutes

deft sierra
#

So I messed something up

#

Found it, may have got it lol

deft sierra
#

Yeah nope. this is the issue I ran into when I was first messing around, I could never get the heater to switch off even when its out of range

#

Maybe toggle? But that would be wonky and templates sound better

deft sierra
#

Yeah nope. I intentionally triggered it on it wouldn't turn off, forced it off now it won't turn on

fallen robin
fallen robin
#

Ahhhh gotcha. Well, they do exist though (I use pyscript myself) 😉

#

But, post your automation. Let’s see what broke.

#

Did you get some rest?

deft sierra
#

Yeah

#

Looking at it one minute Ill paste it here

#
description: ""
trigger:
  - platform: state
    entity_id:
      - switch.outlet_grow_light_switch
    from: "off"
    to: "on"
  - platform: state
    entity_id:
      - switch.outlet_grow_light_switch
    from: "on"
    to: "off"
  - platform: state
    entity_id:
      - sensor.lower_environment_sensor_humidity
    from: null
  - platform: state
    entity_id:
      - sensor.upper_environment_sensor_temperature
    from: null
condition: []
action:
  - if:
      - condition: state
        entity_id: switch.outlet_grow_light_switch
        state: "on"
    then:
      - if:
          - condition: numeric_state
            entity_id: sensor.lower_environment_sensor_humidity
            above: 57
          - condition: numeric_state
            entity_id: sensor.upper_environment_sensor_temperature
            below: 79
        then:
          - service: switch.turn_on
            target:
              entity_id: switch.outlet_heater_switch
            data: {}
    else:
      - if:
          - condition: numeric_state
            entity_id: sensor.lower_environment_sensor_humidity
            above: 38
          - condition: numeric_state
            entity_id: sensor.upper_environment_sensor_temperature
            below: 68
        then:
          - service: switch.turn_off
            target:
              entity_id:
                - switch.outlet_heater_switch
            data: {}
mode: single
deft sierra
#

I think the problems this:

  - if:
      - condition: state
        entity_id: switch.outlet_grow_light_switch
        state: "on"
    then:
      - if:
          - condition: numeric_state
            entity_id: sensor.lower_environment_sensor_humidity
            above: 57
          - condition: numeric_state
            entity_id: sensor.upper_environment_sensor_temperature
            below: 79
        then:
          - service: switch.turn_on
            target:
              entity_id: switch.outlet_heater_switch
            data: {}

The way I read it, it will always turn it on if the lights on, never off.

#

Even then, its not triggering anymore its off

#

I need to disable the rule for now, Ill come back later