SRP Energy Integration not working

Update the SRP Energy sensor to be recognized by energy management as a power meter.

only 23 34 of us use this, since its only arizona, hopefully somethign changes though, i cannot get any energy stuff to work. even after following all the advice on the forums.

Yes Please!

are you able to pull energy usage from SRP? i cannot get it to work.

i can see my usage from srp, it is hard to decipher what its doing though, and i cannot get the new energy stuff working at all.

Im not sure what the deal is except the energy stuff is a mess still. imo

2 Likes

I was hoping to see this integration with the new power/energy settings also.

However, right now the integration itself doesn’t seem to work for me. I can get a value back, but it is not my hourly usage, and it won’t change/refresh unless I trigger a refresh on the component. For example, right now the value I am getting back is 60.90 kWh, which doesn’t match up with any usage that I can find in any report I run on the SRP site. It certainly is not my usage from the last hour. It is also too high to be current usage for today. It doens’t match up with usage over the last 24 hours. I have tried adding up various hours over various time periods, and I cannot get 60.9 kWh, no matter what values/days/hours I use.

I have tried extracting the data based on how the API extracts it (https://myaccount.srpnet.com/myaccountapi/api/usage/hourlydetail?billaccount=123456789&beginDate=08-22-2021&endDate=08-23-2021), but I get an error saying “Cookie authentication requires an anti-forgery token.” (I use my account number, not 123456789.)

I use the EZ-3 Time of Use plan, and set the integration to use Time of Use (I tested without and then I just get “unknown”). What values do other people using the srpenergy component get? Do you get a value indicating usage for the last hour? last day? something else?

I am motivated to contribute to making the SRP Energy integration more operational. I want to be able to get measurements on the entity sensor.srp_energy_usage. I also want the SRP Energy Integration to be compatible with the Energy Management feature.

Time to contribute to the Home Assistant Community. How do we help?

1 Like

pretty much the same here. Nothing matches up and I cant figure out what its actually doing or how its pulling the data at such random intervals, usually its once a day I get some odd usage numbers.

its to bad too, cause the srp website actually gives alot of information. Im using the M-power box. so I can actually see it by looking at the box.

This does me 0 good though:

@fiftys , It appears that you were able to get SRP Integration to at least contribute a value to the Energy Management to plot something. I have been unsuccessful in even achieving this. If you would share that step, it will help as we figure this out.

In my research, I found that SRP provides some documentation of their API python class.
https://srpenergy-api-client-python.readthedocs.io/_/downloads/en/latest/pdf/
https://srpenergy-api-client-python.readthedocs.io/en/latest/module.html

I reviewed the srp_energy sensor.py code and the current Home Assistant SRP integration uses these defined python classes. However, Home Assistant only queries the data once a day resulting in a usage value for the previous 24 hours as a single value of energy in kWh. I am not sure when the update query occurs, however I am speculating that may be established from when the user installed the SRP integration and every 24 hours after that. This may explain the randomness in the updates. Others more familiar with the asynchronous details of the Home Assistant operations may be able to explain further.

 start_date = datetime.now() + timedelta(days=-1)
 end_date = datetime.now()
 with async_timeout.timeout(10):
      hourly_usage = await hass.async_add_executor_job(
            api.usage,
            start_date,
            end_date,
            is_time_of_use,
      )
      ...

I believe that additional development of the SRP Integration can take advantage of more of the data that SRP provides. More work to do to research how to achieve this.

1 Like

here is my recent data, i tried turning on debug logging however the integration doesn’t provide any messages. The time would likely change whenever the system reboots.

image
update at image
next update at image
next update image
image
image

hope that helps

My expectation is that the integration should provide:

  1. hourly data for the previous day
  2. a sum of the previous day

I don’t understand how we could insert the data into the history file with the correct time.
The integration can easily sum the data and return an appropriate value for the previous period, the user needs to be able to specify the period, along with the update frequency.

sample of what is supposed to be returned based on the api documentation
Get the hourly usage for a given day.
'>>> from srpenergy.client importSrpEnergyClient

accountid = ‘your account id’
username = ‘your username’
password = ‘your password’
client = SrpEnergyClient(accountid, username, password)
start_date = datetime(2018, 9, 19, 0, 0, 0)
end_date = datetime(2018, 9, 19, 23, 0, 0)>>>usage = client.usage(start_date, end_date)
print(usage)[
(‘9/19/2018’, ‘12:00 AM’, ‘2018-09-19T00:00:00-7:00’, ‘1.2’, ‘0.17’),
(‘9/19/2018’, ‘1:00 AM’, ‘2018-09-19T01:00:00-7:00’, ‘2.1’, ‘0.30’),
(‘9/19/2018’, ‘2:00 AM’, ‘2018-09-19T02:00:00-7:00’, ‘1.5’, ‘0.23’),
…(‘9/19/2018’, ‘9:00 PM’, ‘2018-09-19T21:00:00-7:00’, ‘1.2’, ‘0.19’),
(‘9/19/2018’, ‘10:00 PM’, ‘2018-09-19T22:00:00-7:00’, ‘1.1’, ‘0.18’),
(‘9/19/2018’, ‘11:00 PM’, ‘2018-09-19T23:00:00-7:00’, ‘0.4’, ‘0.09’

just in case it helps here is the actual hourly data from SRP’s web site ( the sept 6 total of 21.4 matches the total for sept 5th):

Usage date Interval Total kWh
8/30/2021 12:00 AM 0.2
8/30/2021 1:00 AM 0.6
8/30/2021 2:00 AM 0.5
8/30/2021 3:00 AM 0.5
8/30/2021 4:00 AM 0.3
8/30/2021 5:00 AM 0.7
8/30/2021 6:00 AM 0.9
8/30/2021 7:00 AM 0.6
8/30/2021 8:00 AM 0.8
8/30/2021 9:00 AM 0.7
8/30/2021 10:00 AM 0.6
8/30/2021 11:00 AM 1.1
8/30/2021 12:00 PM 1.1
8/30/2021 1:00 PM 1.3
8/30/2021 2:00 PM 1.8
8/30/2021 3:00 PM 2
8/30/2021 4:00 PM 1.6
8/30/2021 5:00 PM 1.3
8/30/2021 6:00 PM 1
8/30/2021 7:00 PM 0.9
8/30/2021 8:00 PM 0.6
8/30/2021 9:00 PM 0.7
8/30/2021 10:00 PM 0.6
8/30/2021 11:00 PM 0.6
8/31/2021 12:00 AM 0.4
8/31/2021 1:00 AM 0.2
8/31/2021 2:00 AM 0.5
8/31/2021 3:00 AM 0.3
8/31/2021 4:00 AM 0.2
8/31/2021 5:00 AM 0.5
8/31/2021 6:00 AM 1
8/31/2021 7:00 AM 0.7
8/31/2021 8:00 AM 0.8
8/31/2021 9:00 AM 0.4
8/31/2021 10:00 AM 0.7
8/31/2021 11:00 AM 0.9
8/31/2021 12:00 PM 1.5
8/31/2021 1:00 PM 1.9
8/31/2021 2:00 PM 0.9
8/31/2021 3:00 PM 0.9
8/31/2021 4:00 PM 0.8
8/31/2021 5:00 PM 0.8
8/31/2021 6:00 PM 0.7
8/31/2021 7:00 PM 0.5
8/31/2021 8:00 PM 0.6
8/31/2021 9:00 PM 0.3
8/31/2021 10:00 PM 0.3
8/31/2021 11:00 PM 0.2
9/1/2021 12:00 AM 0.3
9/1/2021 1:00 AM 0.2
9/1/2021 2:00 AM 0.2
9/1/2021 3:00 AM 0.2
9/1/2021 4:00 AM 0.3
9/1/2021 5:00 AM 0.6
9/1/2021 6:00 AM 0.7
9/1/2021 7:00 AM 0.6
9/1/2021 8:00 AM 0.6
9/1/2021 9:00 AM 0.5
9/1/2021 10:00 AM 0.5
9/1/2021 11:00 AM 0.5
9/1/2021 12:00 PM 0.6
9/1/2021 1:00 PM 0.7
9/1/2021 2:00 PM 1.2
9/1/2021 3:00 PM 1.2
9/1/2021 4:00 PM 1.1
9/1/2021 5:00 PM 1.2
9/1/2021 6:00 PM 1.1
9/1/2021 7:00 PM 0.7
9/1/2021 8:00 PM 0.4
9/1/2021 9:00 PM 0.4
9/1/2021 10:00 PM 0.3
9/1/2021 11:00 PM 0.5
9/2/2021 12:00 AM 0.3
9/2/2021 1:00 AM 0.4
9/2/2021 2:00 AM 0.2
9/2/2021 3:00 AM 0.3
9/2/2021 4:00 AM 0.2
9/2/2021 5:00 AM 0.5
9/2/2021 6:00 AM 0.7
9/2/2021 7:00 AM 0.7
9/2/2021 8:00 AM 0.6
9/2/2021 9:00 AM 0.5
9/2/2021 10:00 AM 0.5
9/2/2021 11:00 AM 0.6
9/2/2021 12:00 PM 0.7
9/2/2021 1:00 PM 1.3
9/2/2021 2:00 PM 1.3
9/2/2021 3:00 PM 1.3
9/2/2021 4:00 PM 1.6
9/2/2021 5:00 PM 1.1
9/2/2021 6:00 PM 1.1
9/2/2021 7:00 PM 0.8
9/2/2021 8:00 PM 0.3
9/2/2021 9:00 PM 0.5
9/2/2021 10:00 PM 0.5
9/2/2021 11:00 PM 0.3
9/3/2021 12:00 AM 0.5
9/3/2021 1:00 AM 0.2
9/3/2021 2:00 AM 0.2
9/3/2021 3:00 AM 0.3
9/3/2021 4:00 AM 0.2
9/3/2021 5:00 AM 0.6
9/3/2021 6:00 AM 0.6
9/3/2021 7:00 AM 0.7
9/3/2021 8:00 AM 0.6
9/3/2021 9:00 AM 0.5
9/3/2021 10:00 AM 0.6
9/3/2021 11:00 AM 0.7
9/3/2021 12:00 PM 0.9
9/3/2021 1:00 PM 1
9/3/2021 2:00 PM 1.3
9/3/2021 3:00 PM 1.7
9/3/2021 4:00 PM 1.9
9/3/2021 5:00 PM 1.5
9/3/2021 6:00 PM 1.3
9/3/2021 7:00 PM 0.8
9/3/2021 8:00 PM 0.3
9/3/2021 9:00 PM 0.6
9/3/2021 10:00 PM 0.5
9/3/2021 11:00 PM 0.5
9/4/2021 12:00 AM 0.2
9/4/2021 1:00 AM 0.2
9/4/2021 2:00 AM 0.4
9/4/2021 3:00 AM 0.4
9/4/2021 4:00 AM 0.2
9/4/2021 5:00 AM 0.5
9/4/2021 6:00 AM 0.7
9/4/2021 7:00 AM 0.7
9/4/2021 8:00 AM 0.6
9/4/2021 9:00 AM 0.6
9/4/2021 10:00 AM 0.4
9/4/2021 11:00 AM 0.7
9/4/2021 12:00 PM 1.2
9/4/2021 1:00 PM 1.1
9/4/2021 2:00 PM 1.7
9/4/2021 3:00 PM 1.8
9/4/2021 4:00 PM 1.8
9/4/2021 5:00 PM 1.9
9/4/2021 6:00 PM 1.2
9/4/2021 7:00 PM 0.9
9/4/2021 8:00 PM 0.8
9/4/2021 9:00 PM 0.5
9/4/2021 10:00 PM 0.6
9/4/2021 11:00 PM 0.2
9/5/2021 12:00 AM 0.5
9/5/2021 1:00 AM 0.2
9/5/2021 2:00 AM 0.5
9/5/2021 3:00 AM 0.2
9/5/2021 4:00 AM 0.2
9/5/2021 5:00 AM 0.8
9/5/2021 6:00 AM 0.7
9/5/2021 7:00 AM 0.7
9/5/2021 8:00 AM 0.6
9/5/2021 9:00 AM 0.5
9/5/2021 10:00 AM 0.7
9/5/2021 11:00 AM 0.9
9/5/2021 12:00 PM 1
9/5/2021 1:00 PM 1.2
9/5/2021 2:00 PM 1.4
9/5/2021 3:00 PM 2.3
9/5/2021 4:00 PM 2.1
9/5/2021 5:00 PM 2
9/5/2021 6:00 PM 1.4
9/5/2021 7:00 PM 1.1
9/5/2021 8:00 PM 0.7
9/5/2021 9:00 PM 0.6
9/5/2021 10:00 PM 0.6
9/5/2021 11:00 PM 0.5
9/6/2021 12:00 AM 0.4
9/6/2021 1:00 AM 0.3
9/6/2021 2:00 AM 0.5
9/6/2021 3:00 AM 0.2
9/6/2021 4:00 AM 0.4
9/6/2021 5:00 AM 0.5
9/6/2021 6:00 AM 0.7
9/6/2021 7:00 AM 0.7
9/6/2021 8:00 AM 0.6
9/6/2021 9:00 AM 0.4
9/6/2021 10:00 AM 0.7
9/6/2021 11:00 AM 1
9/6/2021 12:00 PM 0.9
9/6/2021 1:00 PM 1.3
9/6/2021 2:00 PM 1.5
9/6/2021 3:00 PM 1.9
9/6/2021 4:00 PM 2
9/6/2021 5:00 PM 1.9
9/6/2021 6:00 PM 1
9/6/2021 7:00 PM 1.1
9/6/2021 8:00 PM 0.7
9/6/2021 9:00 PM 0.6
9/6/2021 10:00 PM 0.6
9/6/2021 11:00 PM 0.3
1 Like

I dont remember doing anything special to get the data in, just make sure the srp integration entity has these options in customization.

edit: This was apparently a bug fixed in a recent core update. Working once a day, kind of.

even more confusing now.

I didnt change anything and now I have no data, and i see this one the energy config screen…

however, the entity is still reporting a daily total. and also the cost sensor i made is working…

- platform: template
  sensors:
    daily_energy_cost:
      friendly_name: SRP Daily Cost
      unit_of_measurement: "USD"
      value_template: "{{ states('sensor.srp_energy_usage')|float * states('input_number.cost_per_kwh')|float}}"

cost

at this point im about 3 clicks away from giving up on it. lol

@richardcalgary403 Yes, the hourly data is available from SRP API, however the current SRP Integration implementation simply sums the hourly energy consumption to a total day usage. See the code below, looping through the for loop accumulating the hourly values.

This sensor should be able to get upgrades with some development.

with async_timeout.timeout(10):
                hourly_usage = await hass.async_add_executor_job(
                    api.usage,
                    start_date,
                    end_date,
                    is_time_of_use,
                )

                previous_daily_usage = 0.0
                for _, _, _, kwh, _ in hourly_usage:
                    previous_daily_usage += float(kwh)
                return previous_daily_usage

thanks.

Wouldn’t be more useable if we simply loaded the hourly data into history?

Is it possible to backdate the data as it gets loaded into history?

If HASS happens to request an update at 6:30 am the data will get stored at approximately 6:30 on the current day but will actually represent the 24 hour period ending at midnight the day before. Thus you would expect the number to match up with SRP’s daily totals offset by one day.

This seems like something the devs should probably consider adding, there are A LOT of electricity companies that report accurate data but on 1 day delay, mine included.

I’m also willing to help contribute to this, I’m one of the 31 people using this! Setting the custom attributes as suggested by @fiftys didn’t work for me unfortunately.

I just started looking at this as well. Energy Management in Home Assistant - Home Assistant mentions that most existing energy integrations have been updated to support energy management but I’m not sure if this one in particular was. I’m trying to find an example of another energy provider integration that was for sure updated to do some comparisons. Anyone know of one that was recently updated?

someone should just ask the codeowner lol

“codeowners”: ["@briglx"],