lawrencefoley / evergy

A simple utility that you can use to access your Evergy account and retrieve you meter readings.
MIT License
31 stars 13 forks source link

Hourly Usage #4

Closed lawrencefoley closed 3 years ago

lawrencefoley commented 4 years ago

Add the ability to retrieve hourly usage. This URL can be used to do that (note the interval parameter). There seems to be some (currently unknown) delay on the hourly data showing up.

https://www.evergy.com/api/report/usage/1111110000?interval=h&from=9/15/2020&to=9/16/2020
Conroman16 commented 3 years ago

Nice project you've got here. I was poking around with the API earlier and noticed that the mi interval gives data at 15-minute intervals. That said, the data seems to only update every 12-ish hours for me. Not sure how relevant it is, but since there's no documentation whatsoever, I figure every little bit worth noting

lawrencefoley commented 3 years ago

@Conroman16 Thank you! I appreciate the info. When I was researching this last I also remember seeing that it didn't update very often. I also haven't checked since they re-did their website last month. It might also depend on each customer's meter.

kreene1987 commented 3 years ago

Hey guys, I finally got around to getting this implemented via pyscript into HA for their new energy dashboard!

Short version I assign in input_number (0.001 step, highest number 1000) the "usage" data from -1 (0 I assume is today and seemed to stick to 0 in my testing, -1 seemed to match my "today" usage?). I take the input_number state and created a template sensor

template:
  - sensor:
      - name: "House Energy"
        state: "{{ states('input_number.evergy_usage_today') }}"
        unit_of_measurement: "kWh"
        device_class: energy
        state_class: measurement

I am wondering how often/what times the api seems to be updating. I can run a time pattern in HA to update the input_number (and therefore sensor) but don't want to hit them too hard. Maybe hourly?

Also, has any progress been made on hourly or more frequent information? I am still using "d" interval.

kreene1987 commented 3 years ago

Also thanks to @lawrencefoley for creating this. Will help my home be much more conscious of electricity usage in the future!

kreene1987 commented 3 years ago

Update, I can add the sensor that grabs since 01/01/2021 and is consistently reporting back increasing numbers each hour. HA will take the difference and apply it to "used" in my energy dashboard, so honestly this item is not needed for me as I can ping it hourly and get a new "annual use" kWh.

Pretty fantastic stuff today, very thankful!

lawrencefoley commented 3 years ago

@kreene1987 You're welcome! I'm glad that people are using this and monitoring their usage!

That's very cool. I actually just got my own Home Assistant setup a couple weeks ago and have been configuring it. I really want to create an integration with their new "Energy" component so this would be easier to use with HA. I also plan on seeing if I can get the hourly usage and find out how often it updates.

For your setup getting data since the beginning of the year - I would not hit that very often since it's pulling back every day for the year and that could put some unexpected strain on their servers. We want to be respectful since this isn't a public API. 😃

kreene1987 commented 3 years ago

@kreene1987 You're welcome! I'm glad that people are using this and monitoring their usage!

That's very cool. I actually just got my own Home Assistant setup a couple weeks ago and have been configuring it. I really want to create an integration with their new "Energy" component so this would be easier to use with HA. I also plan on seeing if I can get the hourly usage and find out how often it updates.

For your setup getting data since the beginning of the year - I would not hit that very often since it's pulling back every day for the year and that could put some unexpected strain on their servers. We want to be respectful since this isn't a public API. 😃

Gotcha. I changed it to 08/01. Luckily HA looks at a "running" value and see the difference each time it updates, so it can be any frame of time as long as it increases through the day!

If you need help feel free to message or post up and tag me!

kreene1987 commented 3 years ago

I ping each hour on the hour and here are my results over the past few days:

image

lawrencefoley commented 3 years ago

@kreene1987 What do the Xs represent in this?

kreene1987 commented 3 years ago

Sorry for not being clear. Those represent when a CHANGE in the data was reported, or corresponding usage increased. Non-X's represent a poll but no energy usage change.

lawrencefoley commented 3 years ago

Sorry for not being clear. Those represent when a CHANGE in the data was reported, or corresponding usage increased. Non-X's represent a poll but no energy usage change.

Ah, gotcha. Interesting. Was this when hitting the hourly endpoint?

kreene1987 commented 3 years ago

Sorry for not being clear. Those represent when a CHANGE in the data was reported, or corresponding usage increased. Non-X's represent a poll but no energy usage change.

Ah, gotcha. Interesting. Was this when hitting the hourly endpoint?

Actually no, I was hitting the day endpoint. I will change and see what I get!

def getUsage(self, start, end, query_scale="d")

changing to

def getUsage(self, start, end, query_scale="h")

kreene1987 commented 3 years ago

Still only getting data about every 4 hours on the hourly endpoint pinging every hour on the hour.

F13 commented 3 years ago

@kreene1987, could you provide some extra detail regarding how you integrated this into HA? Alternatively, how's the integration going @lawrencefoley? :grin: Keen to get this set up and not have to pay extra money to retrieve the data from another source (like a clamp sensor or an eagle).

kreene1987 commented 3 years ago

Hey @F13, if you check out #8 I listed most/all of what I did to get this integrated into HA.

Note that it no longer needs to have last_reset assigned and the new state class is "total_increasing": https://developers.home-assistant.io/blog/2021/08/16/state_class_total

lawrencefoley commented 3 years ago

Been recording data every so often to find out what the usage lag looks like:

data points:  49
min: 1.5 hours
max: 4.99 hours
mean: 3.12 hours
median: 3.13 hours
std deviation: 1.14 hours

I'm working on the HA integration and I've been looking for a way to set the time on data from an energy sensor in HA, but haven't had any luck. I think I'm just going to have to settle for the data to be delayed in HA a few hours.