Hey all - love the new energy feature, but a simple, dumb question - how do you split a single live value in to power in/power out.
For example I have a single CT clamp on my main power feed - if it’s positive I know I’m drawing from the grid (power in), if it’s negative I know I’m exporting power (power out)
How do you take this single instant power reading and convert it into two separate sensors for the power import and power export sections of the new energy dashboard?
(same applies to home battery systems as well)
Thanks in advance!
EDIT: I can assume it’ll be a template sensor and then an integration sensor for the cumulative. I just can’t figure out the maths and how to split one into two?? if that makes any sense…
Thank you so much, thats perfect! Quite a bit of a brain bender to get your head around input sensor then the +/- sensors, then the integration cumulative sensors!!
For reference -
The input is a sensor called powermon which is a CT clamp round the main meter tail. It goes positive for import, negative for export
This provides two counters which will show the current watts going in / out of house
template:
- sensor:
- name: "Mains Power In W"
unit_of_measurement: "W"
state_class: measurement
device_class: energy
state: >
{% if (state_attr('sensor.powermon', 'MAINSINOUT') | int) > 0 %}
{{ state_attr('sensor.powermon', 'MAINSINOUT') }}
{% else -%}
0
{% endif %}
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
- name: "Mains Power Out W"
unit_of_measurement: "W"
state_class: measurement
device_class: energy
state: >
{% if (state_attr('sensor.powermon', 'MAINSINOUT') | int) > 0 %}
0
{% else -%}
{{ state_attr('sensor.powermon', 'MAINSINOUT') | int | abs }}
{% endif %}
attributes:
last_reset: '1970-01-01T00:00:00+00:00'
Finally we need to keep a running total of import/export -
Hi, how accurate is this setup?
I am about to get install some ct clamps on my system and I don’t know if one will give me the correct readings?!? Thanks