I have a sensor template to calculate power usage, the difference between what I generate with solar PV, and actual power in either direction from the grid, depending on generated level the result is either positive or negative. I want to always show as a positive integer
I have :-
- platform: template
sensors:
actual_power_usage: #generated minus total grid power
entity_id:
- sensor.shellyem_109664_channel_1_power
- sensor.shellyem_109664_channel_2_power
value_template: >-
{% set generated = states.sensor.shellyem_109664_channel_1_power.state|float %}
{% set grid = states.sensor.shellyem_109664_channel_2_power.state| float %}
{{ (generated - grid)|round(1) }}
would something like :-
{{ (INT(generated - grid))|round(1) }}
always return a positive number ??