I have a sensor I read from my solar inverter setup in HA which shows a history of W over time. I’d like to create a card on my dash for a set time range each day (overnight) to see how many watts add up (tracking overnight watering on my well usage which pull from the batteries) so I can optimize for efficiency or determine if I need more battery storage. Can someone please point me in the right direction for how to do this? I’ve looked at a number of things like history stats but don’t know how to do it for watts measurements, since the example was for time and I’m still learning HA. Thank you.
Use the Riemann Sum (Integral) Helper to convert your power sensor to energy used.
Feed the energy sensor to a Utility Meter Helper to measure the energy per day.
Or if you want a different time period than a day use the Utility meter tariff feature (one tariff for the time you are interested in, one for all other times):
Since the sensor from my inverter provides continuous watt values instead of an on/off state, what would the automation condition be? i.e mine is not this:
action:
- if:
- condition: state
entity_id: binary_sensor.peak_rate
state: 'on'
mine would be…see question mark below, unless I don’t use the state condition
action:
- if:
- condition: state
entity_id: binary_sensor.peak_rate
state: '?'
According to your original request:
You would use a time condition. Or triggers.
e.g. using one tariff for day
and one tariff for night
, switched in the evening and in the morning.
trigger:
- platform: time
at: "18:00" # Adjust as needed
id: night
- platform: time
at: "06:00" # Adjust as needed
id: day
action:
- service: select.select_option
target:
entity_id:
- select.energy_from_grid_daily
data:
option: >
{{ trigger.id }}
Thanks, I failed to mention I’m stuck at the automation for setting up the two tariffs? At your guide here How to use Utility Meter Tariffs to conditionally measure things under here:
2) Write an automation to choose which sensor gets to accumulate energy based on your binary sensor state:
mine would be different since it’s not binary…see question mark(s) below
- id: to be determined (TBD)
alias: 'TBD'
trigger:
- platform: state
entity_id: sensor.eg4_3_total_output_active_power
action:
- if:
- condition: state
entity_id: sensor.eg4_3_total_output_active_power
state: '?' # should this be ON/OFF or something like accumulating values or ?
then:
- service: select.select_option
target:
entity_id:
- select.wssk_load # wssk is well, shop, studio, kitchen,
data:
option: 'From Battery'
else:
- service: select.select_option
target:
entity_id:
- select.wssk_load
data:
option: 'From Solar'
But I think I’m going to need what you posted for setting up the final card in the dash.
No. What I wrote above is an automation to switch tariffs at night.
So I did the automation like you said but when I click on my Utility Meter, it does not change the tariff? I created two tariffs, From Battery, From Solar, the automation has two trigger ids, From Battery, From Solar, the automations.yaml has the template for trigger.id. But the tariff doesn’t change From Battery when the automation time triggers.
Share your automation. That is what changes the tariff, not “clicking on the utility meter”.
trigger:
- platform: time
at: '18:30:00'
id: From Battery
- platform: time
at: 06:44:00
id: From Solar
condition: []
action:
- service: select.select_option
target:
entity_id: select.wssk_load
data:
option: >
{{ trigger.id }}
mode: single
Wouldn’t clicking on the utility meter show what the selected tariff is?
Wait I think I know what the problem is…when I was testing I used the time from my PC, but HA is running on a thin client I’m connected to via visual code. When I manually changed the tariff in the utility meter a log entry stated it was changed 3 minutes ago, did it again, same thing, time must be off…let me test with 3 min offset.
Automation looks good. Can you go to developer tools → States and find your utility meter select entity, then copy the attributes from the right hand column and paste them here.
EDIT: hang on are you triggering the automation manually or waiting until one of the times?
Manual triggering wont have a {{ trigger.id }}
so the automation cant set the select option.
attributes:
options: From Battery, From Solar
friendly_name: WSSK Load Utility Meter
I was triggering the automation waiting for one of the time frames
EDIT: IT WORKS the time offset was the problem…I added the Time and Date integration so I could see the time on the device running HA, my pc is ahead 3 minutes. Once I waited for the offset and had the trigger set for a time, then clicked on the utility meter it showed the tariff that should have been changed to by the automation.
I’m not sure why it is not changing tariff then. That all looks correct.
In developer tools → states does the select entity change state?
One more thing that may help. If you want sunrise to sunset instead of fixed times for measuring night you could use those as triggers for night / day instead. With offsets if needed (e.g. sunset + 30 minutes to sunrise -30 minutes).
Or you could create a binary sensor that switches state based on power going into or out of your battery.
Here is what is going on so far. If you want to skip to the question it is after the 2 graphs at the bottom.
Since I started the Integral Jul 17 @ ~4am it looks to be accumulating correctly. I have it set to minutes and trapezoid, will determine later if those are best settings for accuracy. The flatlines I believe are caused by heat affecting the rs232 isolator I have between the solar inverter and the M5 Atom lite receiving the data via wombatt custom code shared on diysolarforum and github…still need to work that problem out. But it looks like the slope is maintained somehow beyond my understanding at the moment.
WSSK Integral Total Load Sensor
Below is the utility meter which appears to be switching the tariff properly at the times specified in the automation, from what I have observed from Solar Assistant (SA) when solar harvest ends/starts and battery starts//ends. SA was a good start for me, but I’d like to us HA for more data study.
WSSK Load Utility Meter
Here are the two tariff graphs. I have a few issues I don’t know how to fix, namely they reset at midnight, and the heat dropout mentioned above.
WSSK Load From Battery
WSSK Load From Solar
Can you point me in the direction on where to look to fix the midnight reset? I don’t think it is the sensor from the inverter since reports a continual watt use based on load, or the Integral because that is showing accumulation (i.e. no reset). Unless it is the:
Periodically resetting (option in the tariff)
Enable if the source may periodically reset to 0, for example at boot of the measuring device. If disabled, new readings are directly recorded after data inavailability.
which I have enabled…I thought is would reset upon selection.