First, thank you for all the information and the help I can find on this forum.
Then, I would like to ask a question regarding power consumption. I read a lot of articles but I do not understand why it is not working.
Here my use case: I have a water pump that is using more than 350 W when it pumps water.
When there is no water to pump, the power consumption falls down to around 200 W.
I did create an automation that runs every 3 hours and cut the pump when there is no more water, meaning the power consumption is below 200 W for 10 seconds.
However, it seems my trigger with a numeric state is totally ignored.
I did many tests and even if the power consumption is below 200 or above 200, the pump stops after around 15 seconds (timeout of my trigger).
Thank you for your answer
If I remove the timeout, the pump starts and stops directly. Even if the power consumption is lower than 200, it stops without waiting the 10 seconds that HA should wait.
“around” or always actually continuously below 200 for 10 seconds?
This is what needs to occur. Make sure it is correct.
Anyway, don’t wait for long periods in automations, that can cause issues if Home Assistant is restarted or the automation is reloaded. Use two automations, this will also fix your turn off logic:
alias: WaterPump ON
description: Waterpump ON every 3 hours
trigger:
- platform: time_pattern
hours: /3
condition:
- condition: device
type: is_off
device_id: 218cfab8c4af34a35d76a2c9f5
entity_id: 258fbfc145a5b37967f19bf0d8
domain: switch
action:
- type: turn_on
device_id: 218cfab8c4af34a35d76a2c9f5
entity_id: 258fbfc145a5b37967f19bf0d8
domain: switch
mode: single
alias: WaterPump OFF
description: Waterpump OFF when power low
trigger:
- platform: numeric_state
entity_id:
- sensor.energy_socket_active_power
for:
hours: 0
minutes: 0
seconds: 10
below: 200
condition:
- condition: device
type: is_on
device_id: 218cfab8c4af34a35d76a2c9f5
entity_id: 258fbfc145a5b37967f19bf0d8
domain: switch
action:
- type: turn_off
device_id: 218cfab8c4af34a35d76a2c9f5
entity_id: 258fbfc145a5b37967f19bf0d8
domain: switch
mode: single
You could combine the two automations with a choose action but why complicate things?
Thank you, it seems to be ok now but I discover another use case : if there is no water to pump, the power consumption will never be up than 200 w and if I well understood the numeric_state trigger, it needs to be crossed once to match.
Then, if there is not water, I’ll be constantly under the threshold (200w) and the pump never stops.
Did I well understood the logic? Do you see an alternative to cover this particular situation ?
Best would be to use an actual level sensor you could put in as a condition for your turn on automation to prevent the pump turning on. If that is not possible then you can only turn it on then check the power and turn it off if required.
alias: WaterPump ON
description: Waterpump ON every 3 hours
trigger:
- platform: time_pattern
hours: /3
condition:
- condition: device
type: is_off
device_id: 218cfab8c4af34a35d76a2c9f5
entity_id: 258fbfc145a5b37967f19bf0d8
domain: switch
action:
- type: turn_on
device_id: 218cfab8c4af34a35d76a2c9f5
entity_id: 258fbfc145a5b37967f19bf0d8
domain: switch
- delay: 10 # seconds, adjust as necessary, give your pump just enough time to reach full load steady state.
- condition: numeric_state
entity_id: sensor.energy_socket_active_power
below: 200
- type: turn_off
device_id: 218cfab8c4af34a35d76a2c9f5
entity_id: 258fbfc145a5b37967f19bf0d8
domain: switch
mode: single
Note: you still need the other OFF automation too.
Thank you, it works when there is no water. The pump starts and as there is nothing to pump, it stops because the current power consumption is less than 200.
I’ll check tomorrow if everything is working well when there is water and if the second automation (Pump off) is working as expected.
Thank you for your precious help even if I don’t understand why it was not working with the trigger ;).
Your automation was waiting for the power to drop below 200 but the 15 second timeout occurred first (it took longer than 15 seconds to drop below 200).
As you did not specify: continue_on_timeout: false in your wait for trigger it just turned the pump off.
Unfortunately using that option is not a solution either as the wait for trigger would still time out and the automation would stop and your pump would never turn off.
Removing the the timeout altogether (rather than setting it to 0) should have worked but as I said above, waiting long times in automations is not good practice.
It works, thanks.
Just for my understanding, when I configure a numeric_state with a threshold to be below 200 for 10 seconds, it means that for the trigger to work, the value has to be higher than 200 and then fall down below 200 for 10 seconds, right?
if the value goes up of the configured threshold and down many times, the timer (re)starts only when the value remains below the treshold?