Octopus Energy Agile Tariff

I got both running, lol.

As for Markg’s custom plugin I think he needs to do some work on how the UI displays the timezone.

It is important to remember the Python feature that means it does not recognize Z in a datetime string (when using fromISO). It must be +00:00 to be converted correctly else it will treat the datetime string as Local.

so your are saying leave it as Z time otherwise bad things happen?

Hi, i have a add a agile gauge using the following in config.yaml

sensor:

which works but the rates are one 1hr ahead?? as shown in the screen shot below:

Can anyone help me get it to show the current times rate?

Thanks

This returns the time in Local not UTC (Z).

[edit]
Put it in a template and you will see the problem

{{ now() }}

{% set ts_now = ((as_timestamp(now())/1800)|round(0,floor)|int * 1800) %}
{{ ts_now |timestamp_custom ('%Y-%m-%dT%H:%M:%SZ') }}&period_to=
{{ (ts_now + 246060) |timestamp_custom ('%Y-%m-%dT%H:%M:%SZ') }}

returns

image

[edit2]

Actually, I don’t think there is a need to change the format of the timestamp returned from `now()’ as the Octopus API will understand it (even as an integer).

[edit3]
Couple of links

1 Like

Hi Guys

Need some help to send a notification on the change of a 2hour octoblock sensor which will send the details of the 2 hour slot as and when it changes

I have Octoblock working fine so already have a display for the best 2 hour window

What i need to do is read the time of the sensor and send this as a notification when it changes

I only really want to send Date + Time of the 2Hour slot in the notification

Is this possible?

Thanks in advanced

Thanks to @badguy for the answer

- id: '1602067082491'
  alias: Notification - Best 2Hour Electricity slot
  description: ''
  trigger:
  - platform: time
    at: 09:00:00
  - platform: time
    at: '17:00:00'
  condition: []
  action:
  - service: notify.mandj
    data:
      data:
        subtitle: The best 2 hour slot
      message: 'today is at:  {{now().fromisoformat((states("sensor.octoblock_2hour_time"))[:-7]).time()}}'
      title: Electricity

Next Issue

I am unable to fire off an automation based on the 2hour slot I have created with Octoblock

I have tried the trigger as per @badguy’s documentation

- id: '1601931101432'
  alias: Laundry Appliance - Washing Machine Cheapest Slot
  description: ''
  trigger:
  - platform: template
    value_template: "{% if (states(\"sensor.date_time_iso\") + \"Z\") == (states(\"\
      sensor.octopus_2hour30min_time\")) %}\n  true\n{% endif %}\n"
  condition: []
  action:
  - type: turn_on
    device_id: 6de6d5fb7c274df5ae07ceb66923e212
    entity_id: switch.washing_machine_switch
    domain: switch
  - service: notify.mandj
    data:
      message: Washing Machine Started
  mode: single

but it never fires, not even the notification

UI automation seems to be doing funny things with the value_template and formats as above in the auotmations.yaml but looks like this in the UI

  {% if (states("sensor.date_time_iso") + "Z") == (states("sensor.octopus_1hour_time")) %}
    true
  {% endif %}

Hey @badguy I have just done a fresh install of Home Assistant after the massive learning curve from my first time. I’m getting a little better at a lot of this - slowly!
Where I had installed octocost and octoblock manually the first run, I was looking to use HACS this time for simplicity however I can’t see it listed in there!

Do I need to add a separate repository to HACS for it?

Have you installed Appdaemon yet? I’m not sure if they show up or not if that isn’t installed.
They are still in the default HACS lists (I just double checked the HACS github repository). So it should be possible to find them, they are in the “Automation” section of HACS.

Thank you -
I did some digging and found that while it was installed, the AppDaemon option wasn’t selected in the HACS integration configuration.

Then a reboot, clear cache and the Automations section in HACS appeared with both Octoblock and Octocost!
Solved now thank you!

OctopusAgile:
  region_code: E
  mpan: 1413355912003
  serial: 20L3198195
  auth: sk_live_HPsy4W7NJClQnHCfPDm5URDf
  startdate: 2020-08-24
  moneymakers:
  timers:
  run_devices:
  - energy_time: 0.5
    entity_id: 30mins
    run_before: '08:00:00'
    run_time: 0.5
  - energy_time: 1
    entity_id: 1hour
    run_before: '08:00:00'
    run_time: 1

how does one set a 30 minutes timer block? The above code makes all the timers fail however if I remove the code for the 30 minute timer that makes it work

Also I see

sensor.octopus_agile_current_rate
sensor.octopus_agile_next_rate

but is there a

sensor.octopus_agile_minimum_rate

I think you’ve found a bug. I had a issue with timers not allowing 0.5 hour slots and fixed that but must’ve missed the run_devices sensors.

This has really thrown me! I have exactly that sensor but have just had a quick look through the code and it doesn’t appear to be in there, so I’m assuming I have this as a rest sensor. I will double check when I get a chance.

I’ve raised an issue for both, will let you know when they’re sorted.

1 Like

Reminder to folks not to post API Key / MPAN / Ser number data.

Did you manage to get this working? I’m having the same issue, where everything looks great, blocks are set up and updating, but the automation never triggers…

Hi,

Sorry, forgot to post an update, I used the following in the end in a sensor

sensor:
- platform: template
  sensors:
    best1hourslot:
      friendly_name: Best 1Hour Slot
      value_template: >
        {% if states("sensor.date_time_iso") == (states("sensor.octopus_1hour_time")[:-4]) %}
          true
        {% else %}
          false
        {% endif %}

A trigger in your automation would work the same iguess, not tested as I like having a sensor I can flip

I have not tested but you can also try the following as updated by @badguy on his OctoBlock github 

  trigger:
  - platform: template
    value_template: '{% if (states("sensor.date_time_iso") + (" BST"))  == (states("sensor.octopus_1hour_time"))
      or (states("sensor.date_time_iso") + (" GMT"))  == (states("sensor.octopus_1hour_time"))
      -%} True {%- endif %}'

Thank you! I had tried the updated template from the octoblock github, but that doesn’t seem to be working for me either. I’ll give this a go :+1:

Check you have all the time_date options set in your sensor section

- platform: time_date
  display_options:
    - 'time'
    - 'date'
    - 'date_time'
    - 'date_time_utc'
    - 'date_time_iso'
    - 'time_date'
    - 'time_utc'

I have them all and not run into a date issue :slight_smile:

Just double checked, I’ve definitely got time_date set up, exactly as you have it.

The best thing to do might be to test the component parts from your automation in Developer Tools > Template within home assistant. And check they give answers like you’d expect. And substitute the 1hour_time value in place of the sensor.date_time_iso and check the if statement returns True

e.g.
image