Yeah mine too, I came back here to see if there were anyone else with the missing electric consumption figures from th previous day and also I lost the unit pricing for half hourly slots but managed to get that back working again.
So will the electric consumption figures come back again once Octopus puts their clocks forward! Or do we need to do something about the 48/47 time slots in the equation?
Yes itās somewhat annoying. Iāve logged into my api & all the data is there to be pulled but using the code above it doesnāt work with yesterdays useage anymore. I am still able to access the agile rates though.
Interestingly I noticed my data broke after GMT ā BST switchover as well. When I viewed what the API returned I could see it brought back 30mins of the next day data as well as the previous day. Meant to post the changes I made earlier but can see others have already solved it.
Iāve started looking into the idea of making a dedicated Octopus integration (partly to increase my HA knowledge and learn python). Although if someone has already built one thereās no point in me reinventing the wheel (or should it be invertibrate, lol)
Another peculiar issue Iāve noticed is that from the early hours until around 7am, the data from the Octopus API goes to effectively zero, which is messing up my nice graphs! Any ideas why this happens?
I asked the same question a little while ago. It appears that in the early hours of the morning the Octopus API only returns partial data for the day before, often seems to fix up around around in the morning (today for me it was nearly 0846 when it was ok, but I do only query every 2 hours.
Iāve implemented a fix (similar to other examples in this thread) which checks the ācountā of results from the API query and only updates the sensor if count equals 48.
Iām having a problem getting data into HA. I think it must be to do with my āAuthorizationā because it works if I use a browser directly.
My REST Sensor:
- platform: rest
name: Octopus Electricity consumption yesterday
resource_template: >
{% set mpan = states('input_text.octopus_electricity_mpan') %}
{% set serial = states('input_text.octopus_electricity_serial') %}
{% set date = as_timestamp(now() - timedelta(days = 1)) | timestamp_custom('%Y-%m-%d') %}
https://api.octopus.energy/v1/electricity-meter-points/{{ mpan }}/meters/{{ serial }}/consumption/?period_from={{ date + 'T00:00:00' }}&period_to={{ date + 'T23:59:59' }}
headers:
Authorization: !secret octopus_api
value_template: "{{ value_json.results | sum(attribute='consumption') | round(3) }}"
unit_of_measurement: 'kWh'
json_attributes:
- "results"
If I take the āresource_templateā and paste it into āDevTools, Templatesā and then copy the result into a browser it works after asking me for my userid. I provide it with my api key and it returns all the correct data.
My !secret octopus_api looks something like this sk_live_0NGZz1S8aqhzx3WrMfmKg6lE
The error I get is:
Template variable warning: 'dict object' has no attribute 'results' when rendering '{{ value_json.results | sum(attribute='consumption') | round(3) }}'
Has anyone managed to get a figure for āusage so far todayā?
Using this:
{% set date = as_timestamp(now()) | timestamp_custom('%Y-%m-%d') %}
https://api.octopus.energy/v1/electricity-meter-points/{{ mpan }}/meters/{{ serial }}/consumption/?period_from={{ date + 'T00:00:00' }}&period_to={{ date + 'T23:59:59' }}
I only get the first half an hour returned, irrespective of what period_to that I use.
Omitting period_from and period_to (which returns a default of 100 results) like this:
{% set date = as_timestamp(now()) | timestamp_custom('%Y-%m-%d') %}
https://api.octopus.energy/v1/electricity-meter-points/{{ mpan }}/meters/{{ serial }}/consumption/
returns the first half an hour of today and then details for the previous 99 half hours.
My Question to however is, has anyone managed to get this setup with the new Energy monitoring recently introduced?
I think it something to do with the values on the sensors but Iām not 100% sure, any help getting this sorted would be appreciated
Hey Joe, yes Iāve managed to get the information into the Energy tab of HA using this āUtility Meter - Home Assistantā Utility Meter - Home Assistant which I pointed at a sensor adding electricity and gas consumption together and set to Daily.
The only problem is it displays yesterdayās data today, which I canāt seem to fix and suspect needs a change in a future release.
Actually I just went and changed it to separate Daily Electricity and Daily Gas utility monitors I had set up. This allows me to add a fixed rate charge to them, and the Energy tab adds the consumption together for me.