That is not my api code. I edited a few letters before I posted it
Thanks Guy,
I’d tried to pull each piece a part but as I’m still learning how this coding works, it’s been a bit slow! Interestingly, my 1hour Octopus time sensor is showing Z instead of GMT as your screen shot shows. Why would this be the case? I’ve read enough to know this is important, but not enough to know how to resolve it The final statement is not showing True (i.e. it’s false / blank) however returns True when i change “2020-11-09T22:00:00 GMT” to “2020-11-09T22:00:00Z”
2020-11-09T14:26:00 BST
2020-11-09T22:00:00Z
2020-11-09T14:26:00 GMT
2020-11-09T22:00:00Z
The penny has dropped!! Timezones were disabled in the octoblock apps.yaml (which is the default i think?), and as soon as I changed it the code worked and confirmed True… lets give the automation another shot tonight! Thanks for the help to just about everyone on this thread, as I’ve read all through it and picked up hints and tips, and especially Guy for the octoblock (and Octocost code)
Glad you got it working. I’ll be quite pleased if we do get rid of daylight savings soon - it seems to be getting talked about now. It also seems to cause so many issues with technology.
Home assistant is great, but it’s not so much a learning curve, as a brick wall you have to climb up to start with. It does give you loads of power to do what you want though.
I’m really new to HomeAssistant (and coding in general, infrastructure is my thing!). I’ve installed Octocost via HACS and just put the sample/example lovelace config in to see what it showed, however my usage is way off - it’s showing 167kwh per month whereas I’m nearer 450 in reality.
I’m sure I’m doing something daft, but if anyone can point me in the right direction I’d appreciate it. I have my start date set as below (got from the email from Octopus confirming I went live)
Thanks in advance
Hi Dan, for missing usage data it is probably that Octopus Energy have had a problem getting the data from the DCC, as Octocost just pulls it directly from the API. If the cost is wrong, it’s probably this issue - https://github.com/badguy99/octocost/issues/7 I haven’t got time to look at it at the moment, but basically if there is any missing usage data, the wrong usage amount can be multiplied by the wrong cost, as it just processes them as a list, rather than checking the times for each match.
Hi @badguy. I don’t think it’s missing data - I use the OctopusWatch app and I’ve manually checked that there are no days missing right back to 15th July (it seems to only show 4 months history). Even if the previous 3 months were completely missing it wouldn’t explain the low level it’s showing. (3 months missing, 4 months present, my figures in Hass are <30% of actual)
Monthly data shows usage from the 1st of the month, rather than 30 rolling days.
Ah okay, thank you - just me misunderstanding the calcs / sensors
Hi all, very new to HA and will be getting Octopus Agile when I move house in the new year.
I have tried to use the first sensor code at the start of this thread but it doesn’t seem to work due to Entity is non-numeric?
What I am trying to get to is 2 cards. 1 shows the current electricity price and the other the next price. Similar to how @mcon has his.
Can anyone point me in the right direction for the information/code required for this. Any assistance here is greatly appreciated.
This is quite useful, although I’ve found that the gas cost calculation appears to be incorrect. The gas consumption you get back from Octopus is in m3, not kw, so an additional calculation is needed. Here’s the calculation from my bill.
- Your energy usage is calculated from your gas
consumption using a standard industry formula:
Units Consumed (Cubic Metres)
× Volume Correction (for temperature & pressure)
× Calorific Value (energy in each m3
of gas)
÷ 3.6 (convert from joules)
≈ Usage (in kWh)
For you:
149.2 × 1.02264 × 39.3†
÷ 3.6 = 1666.7
Hey all. Just dipping my toes in both agile and home automation/assistant.
I’ve managed to get some data coming in and getting smart plugs to turn on/off etc. with @badguy codes.
As for the automation side of things, how do I trigger it? In the automations section I guess - but the template code does that go in the apps.yaml or not? If so how do I reference it in the automations page - or do I pop the code into a template trigger there? And does it turn the device off after the 1 hour (as an example) or do I need to code a timer or something a bit posher?
End goal is to code my dishwasher/tumble/washing machine to run at cheapest times daily - however if they aren’t primed (tumble has a dial to turn) no worries.
Hi all,
Just setting up my HA with Agile.
@badguy, I’m using your Octoblock app and I was wondering if there is a way to make the times display in a more user friendly format such as HH:MM?
I’ve spent some time looking at templates etc but not managed to get anywhere.
Cheers,
Carl
The time templating is a bit evil to get working
but say you have:
{{states("sensor.octopus_3hour_time")}}
which gives:
2020-12-11T20:00:00 GMT
You can do:
{{now().fromisoformat((states("sensor.octopus_3hour_time"))[:-7]).time()}}
to get the following instead:
20:00:00
- platform: template
sensors:
best3hourtime:
friendly_name: Best 3Hour Time
value_template: >
{{now().fromisoformat((states("sensor.octopus_best3hour_time"))[:-7]).time()}}
@badguy/@matthewjporter - thanks both.
I can get the template working in the template part of the Developer Tools, but I can’t get it to appear on a card. If I use your code @matthewjporter I get a no card type configured error.
Sorry, I’m just getting started here and finding my way.
you can do a card like:
- content: >-
<center> <h1> {{ states('sensor.time') }} </h1> <h3> {{
strptime(states('sensor.date'), '%Y-%m-%d' ).strftime("%A, %d %B %Y") }}
</h3> </center>
type: markdown
This does a card that shows date and time, but hopefully you get the idea
@badguy/@matthewjporter, thanks both. I’ve got the template sensor working now.
Getting there with understanding how this all works.
Does anyone have this working without using appdaemon or custom components?
I just want the rates from the API displayed like the rates card but i dont want to install and setup the custom component? Is that possible with just using restful sensors?
I think it would be possible for you to massage the rates from a restful component into the rates card, but it’d probably be more hassle than it’s worth.
If it helps, the custom component is now installable through HACS, thanks to anthonyangel, you just need to add the repo to HACS.