Hi there. Brand new to HA and this forum so please forgive if the is posted in the wrong place.
I am using the Enphase envoy integration but it does not let me access the net input/output to the grid only sensor.envoy_xxxx_current_power_production or envoy_xxxx_current_power_consumption.
As the trigger i want is net input output to the grid which is equivalent to the difference between the two, can anyone tell me how I say if (power production > power consumption) or alternatively if (production-consumption > 0) as I can only seem to set up triggers to compare a device entity with a fixed value, not with another device entity. Sorry if this is basic but like I say: newbeeee.
Many thanks in advance!
use the 3 dots in the upper right to enter yaml mode, and replace the fixed value by a template
You also test templates with the developer tools /template’s f.e.:
{% set my_test_json = {
"t1": 25.123,
"t2": 24.1}
%}
{{ my_test_json.t1 > my_test_json.t2 }}
= true
(just used some variables, but you can just use your sensors)
Thanks so much for trying to help me. I really appreciate it.
Trouble is as I don’t know this programming language at all, I have no idea how to integrate what you’re telling me into my own trigger… As, 30 years ago, I was a C programmer, this is making me feel pretty dumb. Could you please spell it out for me?
Here’s my existing trigger, and what I need to do is replace the 999 with sensor.envoy_122043xxxxxx_current_power_consumption
alias: Export stopper
description: ""
trigger:
- type: power
platform: device
device_id: 4620b49cdac7774c1ea06bexxxxxxxx
entity_id: sensor.envoy_122043xxxxxx_current_power_production
domain: sensor
above: 999
for:
hours: 0
minutes: 0
seconds: 15
condition: []
action:
- type: turn_on
device_id: d063248882340d94033xxxxxxxxx
entity_id: switch.chauffe_eau_cuisine_socket_1
domain: switch
mode: single
You need to use a template trigger
Should be something like this:
automation:
trigger:
- platform: template
value_template: "{{ states('sensor.envoy_122043xxxxxx_current_power_production') > states('sensor.envoy_122043xxxxxx_current_power_consumption')}}"
for:
seconds: 15
And Yaml is NOT a programming language; it is a way to write a configuration (like json)…
Wow thanks. I feel like I’m trying to learn Korean in an afternoon.
I tried this but got this not-ver-explanatory error message…
“Message malformed: extra keys not allowed @ data['automation”
alias: Eau chaud when export
Description: ""
automation:
trigger:
- platform: template
value_template: "{{ states('sensor.envoy_122043xxxxx_current_power_production') > states('sensor.envoy_122043xxxxx_current_power_consumption')}}"
for:
seconds: 15
condition: []
action:
- type: turn_on
device_id: d063248882340d94033176xxcccc
entity_id: switch.chauffe_eau_cuisine_socket_1
domain: switch
mode: single
Please format code properly for the forum like you did the first time: surround it with three backticks or use the </> button.
Remove the automation:
line, and change the value_template
to compare numbers not strings (with float
filter):
alias: Export stopper
trigger:
- platform: template
value_template: "{{ states('sensor.envoy_122043xxxxxx_current_power_production')|float(0) > states('sensor.envoy_122043xxxxxx_current_power_consumption')|float(0) }}"
for: "00:00:15"
action:
- service: switch.turn_on
entity_id: switch.chauffe_eau_cuisine_socket_1
Thankyou! I did try, but something mucked up because I was doing it on an ipad I think.
And thanks for your suggestion which was accepted by the editor. Now have to test to see if it works!
Will let you know.