core: SRP energy integration does not update on new data

The problem

  1. the state updates on first run after a restart but does not update on subsequent changes
  2. the sensor class is total increasing however the value returned from SRP Energy is not a total increasing signal, it represents the daily energy use. This can result in errors when the current reading is lower than the previous as it is assumed that a new cycle started in between readings.
  3. the readings provided by SRP are not always stable until later in the day, I have noticed that the 23:00 reading is adjusted a couple of times in the early morning. Not sure but I suspect it is adjusted to balance the daily number.
  4. I don’t understand why the sensor name is hardcoded to “sensor” instead of the entity name.
  5. this did work a couple of years ago.

modified sensor code sensor.txt summary of logs showing behaviour for a typical day: srp logs.xlsx

full log over last restart at 04-05 to this morning home-assistant 2022-04-06.log

What version of Home Assistant Core has the issue?

core-2022.3.8

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

SRP Energy

Link to integration documentation on our website

https://www.home-assistant.io/integrations/srp_energy/

Diagnostics information

see log file however this trend shows the issue. The raw total represents the data returned by the api, however the state of the entity is not updated

image

Example YAML snippet

No response

Anything in the logs that might be useful for us?

The logs show the data coming in from the api, however the state of the entity does not update.

Additional information

I also attached a copy of the code modifications that i made to add additional logging.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 50 (13 by maintainers)

Most upvoted comments

Can confirm this is a critical bug - the plugin is currently useless without the above fix.

Hi @richardcalgary, I’ll investigate this and keep you posted.

You can download the code from github and run as a custom component. I am running it that way myself.Richard Roberts On Dec 9, 2022, at 10:53 AM, Stephen J Anderson @.***> wrote: Is there a way to run the updated code ahead of an approved PR?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

Hi all, looks like srp just changed the api. I was finalizing the code with new sensors when the api changed today.

@pjvander SRP doesn’t provide an api for hourly data to read right now. If you query at this moment on 8/30/2022 at 4:00 PM, the returned hourly data will be for yesterday.

Home assistant can check every 10min, or every 8 hours, it will only pull up the data up to yesterday.

{
  "hourlyUsageList": [
    {
      "date": "2022-08-29T00:00:00",
      "hour": "2022-08-29T00:00:00",
      "onPeakKwh": 0,
      "offPeakKwh": 0,
      "shoulderKwh": 0,
      "superOffPeakKwh": 0,
      "totalKwh": 1.9,
      "onPeakCost": 0,
      "offPeakCost": 0,
      "shoulderCost": 0,
      "superOffPeakCost": 0,
      "totalCost": 0.27
    },
    {
      "date": "2022-08-29T01:00:00",
      "hour": "2022-08-29T01:00:00",
      "onPeakKwh": 0,
      "offPeakKwh": 0,
      "shoulderKwh": 0,
      "superOffPeakKwh": 0,
      "totalKwh": 1.9,
      "onPeakCost": 0,
      "offPeakCost": 0,
      "shoulderCost": 0,
      "superOffPeakCost": 0,
      "totalCost": 0.27
    },
    ...
    {
      "date": "2022-08-29T22:00:00",
      "hour": "2022-08-29T22:00:00",
      "onPeakKwh": 0,
      "offPeakKwh": 0,
      "shoulderKwh": 0,
      "superOffPeakKwh": 0,
      "totalKwh": 1.8,
      "onPeakCost": 0,
      "offPeakCost": 0,
      "shoulderCost": 0,
      "superOffPeakCost": 0,
      "totalCost": 0.25
    },
    {
      "date": "2022-08-29T23:00:00",
      "hour": "2022-08-29T23:00:00",
      "onPeakKwh": 0,
      "offPeakKwh": 0,
      "shoulderKwh": 0,
      "superOffPeakKwh": 0,
      "totalKwh": 3.2,
      "onPeakCost": 0,
      "offPeakCost": 0,
      "shoulderCost": 0,
      "superOffPeakCost": 0,
      "totalCost": 0.42
    }
  ],
  "hourlyReceivedList": [],
  "hourlyGenerationList": [],
  "hourlyConsumptionList": [],
  "demandList": []
}

In my example code I returned the sum of hourly data as shown above

SRP only updates the api daily. There’s not a way I know to get hourly data except after the fact. I plan on adding Hourly data as an additional attribute

On Thu, Aug 25, 2022 at 9:53 AM pjvander @.***> wrote:

It doesn’t appear that “hourly_usage” is being passed. Is that by design or did I just miss it?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/69431#issuecomment-1227525262, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ6RRU54GP277RSVY7ET5TV26QJFANCNFSM5SWDXT2A . You are receiving this because you were mentioned.Message ID: @.***>

Hi @pjvander and @richardcalgary and @dinosoup1 , I just pushed a potential update on my branch. Let me know if this works in your environment

I don’t have Dev enviroment setup so I can’t test it. Look forward to your feedback once you finish your test.

@briglx any chance that you could give us an update on your investigation, it has been over 3 months now since we have had any feedback.

did some more testing, coordinator name is just for logs, so it is not the issue. here is the latest code with with the hourly update and the addition of self._state = coordinator.data within the native method which produces image sensor.py.txt

thanks, feel free to ask if you want me to test anything or provide additional information.