I have an automation that should be triggered when the value of a P1 meter changes.
To be more specific it’s the value of sensor.p1_meter_5c2faf0c3986_active_power
The Huawei integration updates that value every 10 seconds.
However the automation is not triggered.
alias: Nieuwe automatisering
description: ""
trigger:
- platform: numeric_state
entity_id:
- sensor.p1_meter_5c2faf0c3986_active_power
above: 50
condition: []
action:
- action: notify.mobile_app_iphone_van_lode
metadata: {}
data:
message: test
title: Testen
mode: single
That’s interesting. I created an automation similar to yours and in my testing, I cannot get my power sensor to trigger the automation either.
Has the value of that sensor dropped below 50 and then gone above it? I am wondering if the trigger doesn’t fire unless the state is below it and then goes above it?
So far, my sensor hasn’t gone below the trigger and then gone above it. When I created the automation, the sensor was above the ‘trigger above’ limit and hasn’t gone below it.
That’s the only thing I can think of.
alias: test num state
description: ""
trigger:
- platform: numeric_state
entity_id:
- sensor.emporia_vue_utility_power_meter_instant_watts
above: 500
condition: []
action:
- action: notify.pushover_hass
data:
message: watts over 500
title: test power
mode: single
Edit: Possibly putting a large number as the below trigger may force it to evaluate the sensor state regardless? I have a 100 A service on a 240 split phase line which i think totals out to 240V x 100A = 24 000W, so I should never see over 24000. I tried adding this as the below trigger, but it still does not trigger the automation. My sensor is updated every 15 seconds.
The only other thing I can think of is, the sensor is passing xxx W as a string, so it never triggers a numerical state? Could possibly use a template sensor to cast it to an int in that case.
{{ states('sensor.emporia_vue_utility_power_meter_instant_watts') }} outputs 1815 wihtout the W, so one would assume it’s a numeric state, but its not.
{% if states('sensor.emporia_vue_utility_power_meter_instant_watts') is number %}
watts sensor is a number
{%- else -%}
watts sensor is not a number
{% endif %}
It needs to be cast to an int or float:
{% if states('sensor.emporia_vue_utility_power_meter_instant_watts')|int is number %}
watts sensor cast to int is a number
{%- else -%}
watts sensor cast to int is not a number
{% endif %}
I forgot to mention that randomly the automation in my first post is triggered.
So must the value to trigger the automation be higher or below a specific number ?