Sensor values not showing/pickable in energy setup

I can help you with those sort of template sensors. Provide the entity ids and states when charging and discharging. Use the states from Developer Tools → States. Not the “translated” pretty states shown In dashboards.

I have a single sensor that accounts for the battery activity.

sensor.battery_power_activity value is W, I’ve now created
sensor.battery_power_activity_energy for the energy tracking

it’s positive for discharging and negative for charge
there is a second topic that either reads “charge” , “discharge” or “idle” to match.
the topic/sensor is a NodeRed flow that either gets a 0, 1 or 2 and I then create a topic with the above values that I can show on dashboard.

G

In configuration.yaml:

template:
  - sensor:
      - name: Battery Charge Power
        device_class: power
        state_class: measurement 
        unit_of_measurement: W
        state: >
          {% if states('sensor.battery_power_activity')|float(0) >= 0 %}
            {{ states('sensor.battery_power_activity') }}
          {% else %}
            0
          {% endif %}
        availability: "{{ has_value('sensor.battery_power_activity') }}"

      - name: Battery Discharge Power
        device_class: power
        state_class: measurement 
        unit_of_measurement: W
        state: >
          {% if states('sensor.battery_power_activity')|float(0) < 0 %}
            {{ states('sensor.battery_power_activity')|abs }}
          {% else %}
            0
          {% endif %}
        availability: "{{ has_value('sensor.battery_power_activity') }}"

Delete your existing Riemann sum sensor for the battery and create two new ones from these two sensors.

Do a config check before restarting home assistant. I’ve been known to make stupid mistakes at this time of night. :slight_smile:

incorporated… and you had no errors…
lets leave it a bit to see how it “populates” with data,

G

ps. whats the time that side,
where are you located
I’m from South Africa.
Stay in a little coastal town called Jeffreysbay on the East Coast.

morni!ggg…
little update, I changed how I source the data, to a much better/faster/stable source now…
but… I’m currently showing power coming in from grid… while I don’t have grid supply atm (South African Load shedding), and only showing power going into battery, nothing coming out, even over night, when we had load shedding at which time we would only have been on the batteries.

I did check the logic of battery positive and negative flow, so thats def correct, at quick look your template looks correct, but can’t say for sure.

G
Screenshot 2023-08-17 at 12.59.03|351x500



G

Hi Tom.

Had a little double disaster my side. first was a NodeRed upgrade that broke something, well it seems after the upgrade none of my flows was there… initial attempt to fix was to restore the backup before the upgrade, did not work… restored a full system backup, so no flows, eventually found them… but by this time discovered allot of the work we did here… seems to have been an innocent bystander. (for some reason after running the google backup integration for like 5 yrs with no problems, ever, i missed that it simple did not run the last 8 weeks).

I have some sensors in my configuration.yaml thats defined as integrations… remember we did them together, need to figure out where they data come from and then my energy tab, well the values are like one decimal off, and they seem to be the integrations from the configuration.yaml that i can’t find source from.

if you have some time, appreciate if we can unpack and rebuild some.

G