Hello everyone- Maybe the question is silly but I don’t understand why it doesn’t behave as I want.
I have a temperature sensor. I need to turn on two heaters when the temperature is below 28.4 and turn it off when it is above 28.4. The issue is that there are times when it is at 29 and I don’t turn it off or it is at 27 and I never turn it on. Is it ok or is there something wrong with this. Because if it is not this, it could be another problem that I have with the relay board that momentarily loses connection. Thank you very much
####################################################
# #
# Acuario Climate #
# #
####################################################
- alias: "Turn on the aquarium heater when the temperature is below 28.4"
trigger:
- platform: numeric_state
entity_id: sensor.temperatura_plantado
below: 28.4
action:
- service: switch.turn_on
target:
entity_id:
- switch.relay_2
- switch.relay_3
- alias: "Turn off the aquarium heater when the temperature exceeds 28.4"
trigger:
- platform: numeric_state
entity_id: sensor.temperatura_plantado
above: 28.4
action:
- service: switch.turn_off
target:
entity_id:
- switch.relay_2
- switch.relay_3
You probably want to change your logic a bit. What happens when the temperature is exactly 28.4?
You may also want to take into consideration the inertia of your heater, if any.
I’d personally set 2 different temperatures to avoid “oscillation” / having your automation constantly run if youy remain close to the target temp (and prob save your heater’s life too)
Have a look at what a Schmitt triggger do to get the idea
If you know your relay board or thermometer loses connection regularly that might be the cause of your issue. Home Assistant will not resend the command if the relay board is offline, because there isn’t a second trigger event. In regards to the thermometer, I’m not 100% sure but I don’t think a numeric state trigger will fire on the change from “unknown/unavailable” to above 28.4. So, if the heaters are running and the thermometer’s signal is dropped it wouldn’t trigger the automation even if the temp is past your set point. It might be best to set auxillary triggers in case of of signal loss. Keep in mind that this is more a stop-gap than a solution, since it too is prone to the same issue if the thermometer is to blame.
You haven’t defined an automation mode, so it defaults to single. In single mode the oscillating effect might cause warnings to be created, so check your logs. Another option is to use for variables in your triggers to avoid the oscillation effect.
The following might be overkill, but it addresses the failure modes
- alias: "Turn on the aquarium heater when the temperature is below 28.4"
trigger:
- platform: numeric_state
entity_id: sensor.temperatura_plantado
below: 28.4
for:
minutes: 5
- platform: numeric_state
entity_id: sensor.temperatura_plantado
below: 27.5
- platform: state
entity_id: sensor.temperatura_plantado
from:
- 'unavailable'
- 'unknown'
condition:
- condition: numeric_state
entity_id: sensor.temperatura_plantado
below: 28.4
action:
- service: switch.turn_on
target:
entity_id:
- switch.relay_2
- switch.relay_3
- alias: "Turn off the aquarium heater when the temperature exceeds 28.4"
trigger:
- platform: numeric_state
entity_id: sensor.temperatura_plantado
above: 28.4
for:
minutes: 5
- platform: numeric_state
entity_id: sensor.temperatura_plantado
above: 29
- platform: state
entity_id: sensor.temperatura_plantado
from:
- 'unavailable'
- 'unknown'
condition:
- condition: numeric_state
entity_id: sensor.temperatura_plantado
above: 28.4
action:
- service: switch.turn_off
target:
entity_id:
- switch.relay_2
- switch.relay_3
Thank you very much for the answers. I understood everything that was explained to me and I saw that I was not evaluating well. I am going to read and try what they told me and when I have a favorable result I will publish it. Thank you