Hi, do you still have the same situation as you had in April here? Please check in your /dev-state page if you have negative values for one/more of your 3 sensors.
If so, please reread my answer I gave you in April here. If you still can’t figure it out, let me help you step by step. But first you have to know for each sensor in what situation it gives you a positive value and when a negative value.
Pls check the unit of all power sensors you have as input. They should be defined and be equal to each other.
Don’t mix unit_of_measurement: 'Watt' with unit_of_measurement: 'W', because the card see them as unequal. Nor mix kW with W, etc.
Seems correct to me. I you still get the error, check for leading or trailing spaces in your unit_of_measurement definition. If there is a 'W ' and the others are 'W' then it’s not going to work.
If that’s not the case, please check if your card is really using this three sensors. You can check that using the debug mode. In the dev console of your browser you can see information about what sensors the card has parsed out of your card definition. More info about debug mode is here: https://github.com/gurbyz/custom-cards-lovelace/wiki/Before-submitting-an-issue-report, see step 3.
If you can’t find the error doing this, please share the complete output of the debug logging here.
In a offgrid installation, where there is no any grid source, Could I simply replace the grid entity with my battery entity? This way I will have how much energy my panels are putting in my battery, and how much energy my loads are getting out of my batteries.
What do you think?
Of course, a real battery integration will be great
Is there any way to use this when the grid power production is a negative value? I have two seperate ways to retrieve data for solar, grid energy use and energy to the grid via powerwall2 and fronius sensors, but both provide a negative value for energy going to the grid.
Either sensor ( in this case sensor.pw2_house_now and sensor.fronius_house_usage) give a positive value for grid usage (power draw) or a negative number for grid production (grid feed in).
If a sensor for power handles both consuming from the grid and producing to the grid, you can use grid_power_entity. You should skip the separate input parameters grid_power_consumption_entity and grid_power_production_entity.
Default polarity for this grid_power_entity is: “positive values for producing to the grid”, but you can set production_is_positive: false if you want to swap the polarity.
Edit: I am having difficulty with the configuration. I have this, but config y’all check states there is an error but doesn’t give me a line etc just a question mark ?
I have:
grid_power_entity;
friendly name: ‘Grid power meter’
unit of measurement: ‘W’
value_template; >-
{{ (1000 * (states(“sensor.pw2_grid_now”) | float | int }}
Please use the </>-button in the editor when pasting code. Then the rest is able to see the indents.
I see a ; (after value_template) that should be a :. And there are 3 “(” but only one “)”. The number of parenthesis open vs close should match. Also making it first a float and then an int doesn’t make sense to me. Pls try:
{{ (1000 * (states(“sensor.pw2_grid_now”))) | int }}
EDIT3: And friendly_name should have an underscore in it.
EDIT4: And the ; after grid_power_entity should be a :
Ok thanks for all that. I did this on my phone while at the airport so some of the formatting wasn’t accurately reflected to what I had. The brackets and float were a issue. O will have another play when I stop travelling.
I have a powerwall 2 battery. This is something I would like to implement. How would you do this if the same sensor (in this case power to house or power to the grid) with a positive and negative value (negative to grid) are the values I have to work with? The battery values are along the same lines (positive and negative values) for charging and discharging.
For showing the card i meanwhile use the state_switch and a template sensor.
e3dc_pv_batt_power_stat:
value_template: >
{% if states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int > 0 %}
sun
{% elif states('sensor.e3dc_pv_total') | int == 0 and states('sensor.e3dc_battery_power') | int < 0 %}
batt
{% elif states('sensor.e3dc_pv_total') | int > 0 and states('sensor.e3dc_battery_power') | int < 0 %}
sun_batt
{% else %}
sun
{% endif %}