Solar Analytics API integration into HA Energy Management

You’re welcome Daniel. Thank you for the feedback. I presume you managed to get all your Solar Analytics channels reporting 5 minute energy updates, and also managed to complete the set-up in the HA Energy configuration.

Yes, that’s correct. My Solar Analytics setup doesn’t have many channels, I must’ve gotten the barebones package :frowning:. Do you guys have energy monitoring clamps on your hot water circuits, etc?

I will need to check the values against the SA dashboard tomorrow, as mine is a 3-phase system and I saw some mention in this thread about the 3-phase numbers being out of whack.

Hi Daniel - 3-phase will consume 3-channels just for general consumption. If you’re using a 6-channel SA device then you’ll have another 3-channels including your solar-PV (maybe 1 channel for each phase).
The numbers being “out of whack” should be fixed as described above - where data with decimal point values are used for the daily sum (before rounding the total to an integer). The numbers you see in HA should be the exactly same as in the SA portal (and the SA data download).

1 Like

Just a quick thank you Peter… I’d hacked together a sensor for my airconditioning load but really had no idea how it worked. Have just set up the package and, once I corrected some user entry errors, it’s working beautifully.

1 Like

Is anyone else finding that restarting HA results in the energy management dashboard showing the subsequent hour’s totals as if they are for the whole preceding day… therefore incorrectly inflating the dashboard’s cumulative totals?

Easy to see the hours after three restarts this morning.

I’ve done my best to work it out… but failed so far. I thought I had found it when I saw that device_class in the yaml was with quotes in relation to sensors - eg device_class: "energy"
but elswhere without quotes - device_class: energy.

But I removed all quotes and doesn’t seem to have made any difference.

Now testing with my Fronius Inverter as the source of the data for the dashboard. Perhaps the problem is with HA or my setup rather than with the SA integration.

Edit… so far it looks like the Fronius integration works well with the energy dashboard. Will keep testing to be sure.

further to my query immediately above… I have just noticed this https://github.com/PeterH24x7/-Solar-Analytics-integration-for-Home-Assistant-Energy-monitoring/issues/6

That looks a lot like what I’m seeing. Rougly eyeballing the graph, it looks like the spurious figures are about equal to the whole of the preceding day’s figures plus a little bit for that hour… ie same as the issue I’m describing.

and further reading here Energy Integration Spike - #23 by petro suggests that the problem may be that, when restarting (or otherwise unavailable) the sensor is briefly recorded as zero (which is the case when it’s viewed in history).

It seems that an availability statement of some sort (if that’s the jargon) in the yaml might be the solution… but at present that’s beyond my skills.

Hi @ddwdiot - I am in the midst of testing a solution to the issue listed on git-hub. I hope to have an updated solution in the next week. Once I’ve finished some prelim testing (i.e. nothing is broken), I will post the updated “solar_analytics.yaml” code under the issue on git-hub if you’re interested in testing it out too.

Thanks Will definitely be checking that out.

Meanwhile, I’m stumbling around with the availability template… which seems like it might be the answer to my particular issue. But I won’t keep posting unless I find something useful.

I wasn’t aware of the availability template. My solution rather deals with any “unavailable” rest platform get sensor by simply preserving the previous state and attributes of the template sensor data. Given your interest I’ve posted the ‘beta’ solution to the issue on git-hub.

Thanks again Peter. Seems like my problem is a little different to yours… ie yours is rare and perhaps random whereas I see mine every time I restart HA. Not sure if others have the same experience… perhaps I restart more often than others.

Others who might be at my basic skills level, can read about availability here Template - Home Assistant. Following is how it looks in just one of the sensors. Just one extra line in the code four up from the bottom.

  - platform: template
    sensors:
      sa_todays_energy_consumed_total:
        friendly_name: Total Energy Consumed
        unit_of_measurement: "Wh"
        value_template: "{{ states.sensor.sa_data_by_5min.attributes.data | rejectattr('energy_consumed', 'equalto', None) | sum(attribute='energy_consumed') | int }}"
        icon_template: mdi:home-lightning-bolt-outline
        device_class: energy
        availability_template: "{{ states.sensor.sa_data_by_5min.attributes.data | rejectattr('energy_consumed', 'equalto', None) | sum(attribute='energy_consumed') | int}}"
        attribute_templates:
          state_class: total_increasing
          time_stamp: "{{ states.sensor.sa_data_by_5min.state }}"

Here is what it looks like in the sensor history chart… before and after the yaml change which was done about 9 am. Your beta solution would produce a smoother chart (without the gap) but I don’t think the result will be different on the HA Energy Management dashboard.

Will report back if any problems over next few days of monitoring and please note that I can’t vouch for this as a solution for others.

No probs. I only restart my HA about once a week but I do note that some sensors have a period of being “unknown” until they first update. In case it helps I’ve replaced the
!= "unavailable"
with
not in ("unavailable", "unknown")
See updates on git-hub.

The fixes for the failed data gets have now been published as an updated solar_analytics.yaml on github.

1 Like

Thanks for this. I wonder if you could add unique ids to these which would allow UI changes such as hiding, moving rooms. I guess it can be same as the name?

image

I don’t have any oven integration on my SA. I guess all I really need is

So I would hide/disable the rest and move rooms.

Hi Peter - Great work, I have set this up very effectively in my system.

Query - Is there a sensor that shows lifetime compensation instead of just daily?

@aussie1497 - this has been done. See latest release 5 on github for this and many more enhancements.

@SimoHDK - have a look at the latest release. Total cost is provided by the HA energy management function. This integration does not otherwise retrieve any cost/compensation data from Solar Analytics. I use the Amber energy integration and am able to calculate 5 minutely updated imported and generated costs for charging my car, heating-cooling and hot-water generation. Please get in contact if you would like further ideas.

Please note Release 5 of the code has been published on github. There and many enhancements and extra sensors. See …

Hey Peter,

Awesome work on this, I picked up your original code in December 2021? and only just now seeing all the updates.
With the SA data for Aircon, Electric car etc, is that coming from SA or you assigning a separate entity to it?

Hi @hyboi1 - sorry just saw your question now. I’m no longer actively monitoring this thread because it’s practically closed. For future matters I suggest you add to the discussion on github - specifically the release 5 discussion -

The energy usage for the EV, AC, hot water, stove oven all come via the solar analytics API. I’m not sure what you mean by “or you assigning a separate entity to it”?

Rgds, Peter

All your data like Energy Total Net Cost, EV, water, etc
I don’t get that from my SA. Is it sth else you bought?
Not sure if it’s due to the solar analytics 3G shutdown forcing buying the 4G dongle and installing again.

I got the basics in the energy tab from b4 and that’s it.