I’m finding it quite difficult to understand a lot of the advanced settings around Octopus Agile automatons etc etc, but have managed to get a basic display of the 30min rates from my own electric meter sensor.
Time Price
{%- set results = state_attr('sensor.octopus_energy_electricity_19lxxxxxxx_11zzzzzzzzzzz_current_rate', 'rates') %}
{%- for record in results %}
{%- set ts = as_timestamp(record.from) %}
{%- set ts_now = ((as_timestamp(now())/1800)|round(0,'floor')|int * 1800) %}
{%- if ts >= ts_now %}
{{ ts|timestamp_custom ('%H:%M', local=true)
}} {{
record.rate }}
{%- endif %}
{%- endfor %}
The card above simply shows the rates on the dashboard, but is enough for me for now
I’d like to achieve is a simple automation, turn ON a device when the current rate is below a certain amount, and turn it OFF if it goes above.
I’ve read until my head is spinning! I came up with what I thought would be a basic script to do this, but it doesn’t work. Could anyone point me in the right direction?
I have an automation for my car charger that does exactly this. It looks at the current rate and if it’s below the number I set (0.20 for example) then HA enables the charger. Another automation turns it off when the rate goes up.
I also discovered whilst trying different approaches that if I just remove the ‘attribute’ from my example above it also works, I thought attribute ‘rate’ was needed, but it isn’t and is what causes the condition to fail. Also as I can see from your example the rate is in £, so the decimal point needed for pence.
Thanks for you help, now working for me one way or the other.
Hi, I’m trying to achieve exactly what you are, but with a lock/unlock on my EV charger (as it’s in plug and charge mode; only unlock when specified Agile rate is met, then lock again if rate goes above specified rate).
However, after reading this thread and trying to create an automation, the trigger isn’t happening automatically to change the state of my lock. I have to run the automation manually for it to change state.
How did you make that template? Sorry I’m not vastly experienced in Home Assistant and trying to work out how you did stage 1 “this is the template”. Where do you go in Home Assistant to make that template please?
Did you work this out? I have eventually by doing this:
Using file editor add new file. Call it sensors.yaml and it will sit in config folder. This needs pasting into it with your Octopus entity sensor for current rate instead of the bold below:
Then add this single line to the existing configuration.yaml under scene: !include scenes.yaml
sensor: !include sensors.yaml
Restart HA and now you will find a new sensor in entities called Octopus Current Half Hour aka octopus_current. This is the ‘sensor’ you specify when writing any automations such as above. Finally this worked for me as the built in Octopus ‘sensor’ couldn’t trigger anything, so now my immersion turns on below 10p, off above 10p etc etc
Since we’re on the subject, it’s nice to automate when a price drops ‘below’ a static value, however how would you add a sensor or something to iterate over the rates and set its value to the lowest rate for the day? That would be extremely useful for my Dishwasher automation so I don’t need to keep checking the rates manually and updating its ‘below’ threshold.
assuming you installed the octopus energy integration, you can open the integration screen and click “add entry”. I pasted here an example of one of my entities “octopus_energy_target_water_heater_morning_schedule” that I use to warm up the boiler water before we wake up.
The entity is set up so that it finds the 3 cheapest 30 minutes slots between the set start and end time.
In the integration doc you can find more details about all the options to define your entity.
Once you created the entity in your HA you can find a new binary_sensor available.
You can use the new binary sensor to define an automation trigger, this is one of my triggers:
Then I add conditions if you have any or I leave it blank.
And last in the actions I add the device I want to turn on, and any other action I want to perform like changing the value of a State.
I hope this helps you so you don’t need to check anymore what are the cheapest time slots
That’s awesome! Thank you for sharing that, I never knew it had this built in. That’s simplified my automation. I ended up using the current rate as a trigger and the following template in my “condition”:
This worked in the sense that at the exact cheapest rate for the day it will run, but not ideal when that’s usually around mid-day - especially for a dishwasher so you’re waiting for it to run.
I’m a bit lost in this one too and would appreciate a bit of help. I have the correct time in the binary sensor but I’m not absolutely clear on how to write the value part of the automation.
From the example given above it’s
{% if states('binary_sensor.octopus_energy_target_dishwasher') %} True
Is that right? if so, is the "== ‘on’ " in the example above just checking it isn’t already on?
EDIT: Just tried it, with the “if” it wants an else but I haven’t got any else to put in :-). Removing the if it fails with states being an unknown tag
DOUBLE EDIT: The editor doesn’t complain now it looks like this
Hi @owen_a,
I’ve just set up my dishwasher automation this week, just like you pointed out is not great if it runs when you need it.
To avoid that I created three sensors, this is the set of triggers I used to turn it on:
@GeoffUK, hopefully I understood what you are trying to do …
I suppose you want to create a Trigger for an automation based on an Octopus Agile Target event.
If that is the case you should create something like this: