Replies: 20 comments 47 replies
-
Hi @thekayman - there are two of the three already for 5 minute energy. The suggestion to have a self-consumed solar sensor is a good one and I'll look into it. Let me know if I've misunderstood anything.
Please stay tuned. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@thekayman - Try adding this code as a sensor to your solar_analytics.yaml. Please let me know if you find any issues. btw, it was more complicated than expected as the new kWh options in HA confuse the calculations and display - hence the calcs from the source data, not the derived sensors (i.e. sa_todays_energy_consumed_total - (sa_todays_energy_generated_total - sa_todays_energy_exported).
|
Beta Was this translation helpful? Give feedback.
-
Couldn't help myself ... here's some more ...
|
Beta Was this translation helpful? Give feedback.
-
WOW!!! I wish I had your skills! I have also just added in the above 3 extra sensors and will test / report back. the main reason I wanted the live data for the below 3 sensors is so I can trigger automations based on usage. I.e. if generating enough and not consuming all the solar than turn the AC on colder and when consuming too much back off etc. Also sometimes if i have dishwasher and ac on and I want to know if I have enough spare solar to turn on washing machine, at the moment I have to fire up solar analytics and check there but if it was all in HA with live data that would be awesome! generation to grid (export) |
Beta Was this translation helpful? Give feedback.
-
Hi @thekayman You're welcome - you can buy me a coffee if you think there's value in my work. https://www.buymeacoffee.com/peter24x7 For triggering things on/off based on the excess of generated energy or not you could simply use the sa_import_export_power sensor. It can jump up and down by the minute depending on what's going on in your house or clouds passing by. As such you may wish to set a minimum on and off interval so you don't over work your equipment. A good point regarding the release note in the source yaml - will do. Lastly there is a release 5 coming, but I'm trying to iron out one more problem. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Just noticed that sensor.sa_todays_generated_consumed_percentage and sensor.sa_todays_consumed_generated_percentage defaults to a high number digits of precision. i.e. mine show 26.5707636979056% and 44.4950113775599%. Might be useful to define decimal places to 1 or 2 places, i.e. 26.6% / 44.5% |
Beta Was this translation helpful? Give feedback.
-
I have gone through and grabbed all the sensors / templates in your code and dumped them here with my explanations (Hope I understood them correctly) I thought you might want to add it into the documentation, I thought it might be a easy way for all to reference the available sensors and what they do, just finding ways to give something back. sa_status - Shows the status of site (updated every hour) sa_todays_energy_total_net_cost - Reports the net cost (imported cost minus exported revenue) sa_todays_air_conditioner_total - Used if you have monitoring on certain SA Channels |
Beta Was this translation helpful? Give feedback.
-
Hi @thekayman and @Roving-Ronin - the new Lovelace ability to change power sensors from Watts to kilo-Watts has been doing my head in; it's clearly not fully implemented and despite much effort I could not fix issues with the sa_live_site_data REST get sensor. I recommend avoiding any issues by keeping your power sensors as Watts for the time being. I've otherwise done a number of additions and fixes as follows. The whole new (but DRAFT) code block is as per this link - #12 (comment) . I'll be testing it myself for another week, but feel free to test too please. Let me know how you go.
|
Beta Was this translation helpful? Give feedback.
-
The issue I was seeing by setting the 3x power sensors sa_generation_power, sa_consumption_power and sa_import_export_power to kW can be seen in the following HA History views - depending on how I coded the error recovery of sa_live_site_data I would either get a blank/gap power sensor state, or a zero state, at 0 minutes of the hour. Have you seen the same? I simply fixed it by changing the sensor units back to W. The trigger is the way SA responds to the sa_live_site_data get at the 0th minute of the hour with no data (see image below). Normally it's defined to provide the last 6x minutes but this doesn't happen at the start of the hour - first there's a blank, then 1 minute's data, then the 2nd up until the 6th minute when things then operate the same until the end of the hour. If the code is working correctly then the "unknown" get should result in no change in the 3x power sensors which just doesn't happen for me with the power sensors set to kW. |
Beta Was this translation helpful? Give feedback.
-
Surprisingly, and without changing the REST get call, the contents of the sa_live_site_data response now seems to have changed to 6 intervals of data 5 seconds apart, not 1 minute apart. The functioning, fortunately, doesn't change (i.e. just extract the latest consumed/generated data at the end of the array). This REST get is not in the Solar Analytics published API so maybe it's not unreasonable for it to change without warning. Nonetheless a strange coincidence to be reviewing in/around the time of the change. |
Beta Was this translation helpful? Give feedback.
-
I changed consumption to W and left generation to kW, The W doesnt have the dips. |
Beta Was this translation helpful? Give feedback.
-
Hi @thekayman and @Roving-Ronin - I've needed to make a minor fix to the two new percentage solar used sensors. See comments in code and the screen shots that follow. In short, 1] there was the potential to get strange and very large % numbers at midnight when the SA sensors reset to zero, and 2] the percentages could be negative sometimes due to a small current draw from the inverter (e.g. on start-up). Again the strange behaviour of the HA Lovelace unit setting came into play here and continues to confuse the situation further.
|
Beta Was this translation helpful? Give feedback.
-
Another related problem fixed; this one applying to the sa_todays_energy_import_rate and sa_todays_energy_export_rate sensors which were found to be sometimes spiking at midnight as the day's total kWh reset to zero (or near zero in the first minutes). Just thinking about these sensors, they presume that sa_todays_energy_imported and sa_todays_energy_exported are both set in HA Lovelace to kWh (not their default Wh). If they were in Wh then the results will be incorrect. Again this whole Lovelace sensor unit matter continues to do my head in.
|
Beta Was this translation helpful? Give feedback.
-
Hi @thekayman and @Roving-Ronin - your thoughts please - default to zero (as coded above), or default to None (proposed as below)? I'm inclined to go with None. I recently discovered another non-numeric sensor state "none" - defined with "Unknown" and "Unavailable" as follows:
Firstly it looks like I've been using Unavailable in some cases when I should have been using Unknown. Secondly, I feel "None" should be used for sa_todays_generated_consumed_percentage, sa_todays_consumed_generated_percentage, sa_todays_energy_import_rate and sa_todays_energy_export_rate rather than defaulting to 0.0 when the sensor state value is undefined. For example, for
And the resulting output looks like the following - in effect a data gap from midnight (when the senor resets) to the point where generation actually starts occurring - which is when this sensor actually becomes meaningful.
|
Beta Was this translation helpful? Give feedback.
-
Hi @Roving-Ronin, @thekayman and anyone else following this thread, Per my note above regarding redoing the REST gets as RESTful sensors, the code has now been substantially restructured and now almost 1,000 lines. It is functionally the same as previous versions regarding sensor naming and functioning. As a bonus, the sensor unit matter (as selected w/i Lovelace) is also no longer an issue. If you use SA for monitoring EV charging you will note some included bonus sensors that show the breakdown of EV charging energy by generated and imported sources with percentages. I've been doing my own testing over the last week and everything seems to be working as expected. If you could do the same and let me know of any problems I hope to finally finish and publish this release for the benefit of others. I hope this is all useful to you. Thank you for your help. Chrs, Peter UPDATED 15-APR-23 MINOR FIX TO sa_data_by_5min_meter_reset. UPDATED 11-APR-23 WITH FIXES AS NOTED IN THE COMMENTS DOWN BELOW PLUS SENSOR IN SUPPORT OF AN APEX-CHART CARD (INSTALLED VIA HACS) OF RECENT ENERGY USAGE BY CHANNEL NOTE THE HEADER TEXT ALSO INCLUDE ADVICE FOR UNGRADING FROM A PREVIOUS VERSION OF THIS CODE.
|
Beta Was this translation helpful? Give feedback.
-
Hi @Roving-Ronin and @thekayman - sorry couldn't help myself over Easter and added another 200 lines of code (updated as marked in the source above) to generate near realtime energy (shown as 5min average power in kW). You will need the APEX Charts (apexcharts-card) add-on installed via HACS. Once installed, create a new Lovelace Apex Charts card and cut/copy the code below and it should start working without too many issues. You will need to edit the code to suit your channel set-up. Note: due to HA limitations the timespan is limited to a history of 2h20m (or 28x 5 minute intervals) due to the 255 character size limit of sensor state data.
|
Beta Was this translation helpful? Give feedback.
-
Hi @thekayman - not sure why the "display precision" is not working as expected where you should be able to set the number of decimal places regardless of the source. Strange too that it provides 7 digits decimal places when each of the source sensors (e.g. sa_data_by_5min_energy_consumed_total which is in turn sa_todays_energy_consumed_total) have a
Regarding the average daily unit rate sa_todays_energy_import_rate and sa_todays_energy_export_rate (as mentioned above) these are just the total $ as calculated by the HA EM divided by the total kWh as provided by the SA code. Is your HA EM configured with the correct $/kWh rates (which may be down to 3 to 4 decimal places on your bill - and may have peak/off-peak/shoulder times)? Do the daily total kWh in HA for sa_todays_energy_consumed_total and sa_todays_energy_generated_total match the corresponding numbers in the Solar Analytics Usage page? I'm otherwise not sure what the issue could be. My energy $/kWh rates from Amber vary every 5 mins and my SA daily bill calculations are better than +/-5% accurate on a daily basis (see images below). Given the likely interval timing and measurement discrepancies between my smart meter and my Solar Analytics calculations, I think this is quite good. Even better I'm able to provide 5 minutely updates on my daily energy cost and EV charging costs, neither of which are provided by Amber on their website (i.e. previous day totals only). From HA energy manager - where $4.61 / 17.85 = $0.258/kWh matching the Amber average rate at $0.26/kWh (below): From Amber (noting my rates include 100% GreenPower at ~5c/kWh): Happy to have a Google hangout or other online call to review further if you like. |
Beta Was this translation helpful? Give feedback.
-
Hi @Roving-Ronin and @thekayman - Release 5 has now been published for the benefit of others. Thank you for all your contributions and help with testing and debugging. The 3-phase version of the code is also included (with minor comment edits to that provided above) in the repository as <solar_analytics_3phase.yaml>. I will shortly close this discussion thread and a new one can be opened for any future work. |
Beta Was this translation helpful? Give feedback.
-
Is there any way to have the live or 5 min sensor to show seperate data such as
generation to grid (export)
generation to house consumption (solar usage)
grid to house (import)
Beta Was this translation helpful? Give feedback.
All reactions