the Integration is what I use in the energy dashboard
Now in order to create a sensor to use for return to grid, I thought that I can take the Solar-Total Consumption=Solar return, the issue being when the Solar is less than the Total Consumption, the value of the sensor is negative. How can I create a template sensor that only considers positive values?
I’ve tried all sorts. | abs just turns the value from a negative to a positive and I can’t seem to get this approach working either
'- sensor:
- name: “Grid return calc”
unit_of_measurement: “W”
device_class: power
state_class: measurement
state: “{{ (states(‘sensor.2_solar_channel_1_power’) | float) - (states(‘sensor.2_solar_channel_2_power’) | float)}}”
sensor:
- name: “Grid return”
unit_of_measurement: “W”
device_class: power
state_class: measurement
state: >
{% set x = state(‘sensor.grid_return_calc’) | float %}
{% if is_number(x) and x | float > 0 %}
states(‘sensor.grid_return_calc’) | float )
{% endif %}’
As I said in the initial question to the comunity, I have a Shelly monitoring consumption on my consumer board and one monitoring the generation from my solar array.
I’ve created a template sensor to calculate the total power consumed from the Grid
Grid = Total consumption (Shelly 1) - Solar Power (Shelly 2)
The second Sensor that I was having trouble in creating was the Grid Return Sensor, How much power am I pushing back to the grid from the solar array. Again I created a sensor
‘- sensor:
- name: “Grid Return”
unit_of_measurement: “W”
device_class: power
state_class: measurement
state: >
{% if states(“sensor.grid”) | float >=0 %}
0
{% else %}
{% set returned = states(“sensor.2_solar_channel_1_power”) | float - states(“sensor.2_solar_channel_2_power”) | float %}
{{ returned }}
{% endif %}’
The issue that I was having is that the Energy Dashboard doesn’t recoginse negative values So here I have used the logic
If the Grid Power is greater than Zero, I’m using power from the grid and also whatever solar I am generating, so the return to Grid is Zero
If the Grid Power is Less than Zero, then I am generating more power than I’m using so do the calculation Solar Power-Total Consumption = Grid Returned. This returns a positive value
I can then use this sensor as part of the integration sensor
'- platform: integration
source: sensor.grid_return
name: grid_return_kwh_new
unit_prefix: k
round: 2
method: left ’
This information could help me, but I cannot understand the explanation, the names of the entities do not match the guidelines.
I may be misunderstanding (especially since English is not my native language), but if possible could you review the content and explain which entity is “Shelly 1” and which is “Shelly 2”?