#Alright part two of the script changing
1 messages · Page 1 of 1 (latest)
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.
What do you see in the trace?
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
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.
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
Also was curious if its possible to debug better?
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?
@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.
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.
I was thinking about that approach but couldn't find an example
Sorry I missed this. I have a switch on a timer also zigbee and ha.
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
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.
Take your time. I appreciate it.
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.
Wont it only trigger once then?
Yeah, and for additional triggers of the same automation, I'd just use additional triggers on humidity and temp.
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.
But the time pattern is important, i would say more important than humidity
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.
I guess I am missing or not understanding how you are explaining it
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.
oh so when it changes it checks the state of the light
Right. Then just toggles the heater on/off based upon the state of the light.
And it's better for HA as well because it doesn't have to execute every second/minute/whatever.
Awesome
As you go through it, I can help you get some of the trickier parts done (if you want).
will do thank you, home soon
@fallen robin so I need to change the triggers in mine to match the changesi nyours?
Kinda yeah. I can write a basic automation for you in a little while for you to follow.
Sounds good, Im messing aroud now. Kinda lost
Yeah I'm going to have to wait. Sorry man
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 😣
No problem
@deft sierra Check this out. I think this is kind of what you want? https://dpaste.org/rPvRj
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.
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
No worries at all and you didn’t make me feel pushed. I just don’t like saying I will have something done and then not doing it. You’re good! Let me know how you get on and we can definitely tweak as needed.
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: {}
I understand completely
Ah, yeah, that’s sounds about right. I wasn’t sure of the logic completely.
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
That logic sounds correct to me. But, yeah, take a break and rest and come back to it. (I say that a workaholic). lol
But whats going to turn the heater off?
does ha have a python plugin? lol I could do this in 2 minutes
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
Yeah nope. I intentionally triggered it on it wouldn't turn off, forced it off now it won't turn on
Sorry. I was watching a live stream. And actually, yes. There is. Look into either AppDaemon or Pyscript.
It was more of a joke
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?
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
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