reptilex / tesla-style-solar-power-card

Home assistant power card mimicking the one tesla provides for the powerwall app.
221 stars 59 forks source link

Problem: displaying 0 W from the grid to the house when the photovoltaic system is not producing and the battery is in energy saving mode. #136

Open Fullmetal11 opened 1 year ago

Fullmetal11 commented 1 year ago

Hello, I configured the card and in ordinary conditions with the photovoltaic system in production everything works regularly: the energy drawn from the grid is displayed correctly as well as the absorption of the house, see image with 294 W from the grid and 384 to home. I encountered a problem: when the photovoltaic system does not produce (at night) and the battery is in energy saving mode (activated when the charge drops below 5%) all the displayed values ​​correspond to 0 W, even if the house is drawing energy from the grid, as can be seen from the image below: energy from the grid to house 2678 W, showing 0. Screenshot_20221203-191005 Screenshot_20221205-125534

reptilex commented 1 year ago

You have a configuration issue. Did you refer to the documentation? You need positive sensors or at least template sensors if you don't have them.

Fullmetal11 commented 1 year ago

All my sensors return positive values, as the documentation refer. I noticed that the problem arises because when the battery enters in energy save mode the associated sensor returns the state "unavaiable" (I see it from developer tools - states) and this causes the problem. In fact, if I manually set 0 to all the battery sensors in "unavaiable" values, the card works well again. How can I make this automatic?

reptilex commented 1 year ago

Create templates in your sensor configuration if not already there and add an if like so (be aware this is not a sensor of the card, just a template example):

      heating_counter_daily:
        friendly_name: Heating Daily Usage
        value_template: >-
          {% if not is_state("sensor.heating_meter_counter", "unavailable") %}
            {{ (state_attr('sensor.heating_meter_counter','total') | float / 1000) | round(3) }}
          {% else %}
            0.00
          {% endif %}
        unit_of_measurement: "kWh"
Fullmetal11 commented 1 year ago

At the moment I solved with an automation that sets the sensor value to 0 (by a pyton script) every time a battery sensor goes unavaiable and it it seems to work. When I have a little more time I will try to modify the configuration file in which the sensors are present. Thank you!