The emoncms software from https://openenergymonitor.org has an app that will give you the cost of energy used based on the Agile Tariff so you can see what your effective flat rate cost is. It will be a little fiddly to set up but it does the job. As an example, for the last 30 days, if I had been on Agile, it would have cost an effective rate of 20.7p/kWh.
once you installed the Octopus integration, you can install this simple card that lists all the upcoming rates https://github.com/lozzd/octopus-energy-rates-card
If you are ok with configuring your own card using Apex Charts you could create cards like this:
Hi All, I’m new to HA and even newer to this community (first post!). There’s great info and help in this community and in this very thread but I’m struggling with figuring out how to use the agile costs to update a cost sensor and have been searching with no luck. I assume I have a common use-case (maybe not?)
To explain - I’m lucky enough to have got an octopus mini and I also have about 26 zigbee energy plugs. For all of these ‘devices’ I have utility meters for cost of day/week/month/year. I then have a template sensor for each that uses the octopus integrations ‘current’ rate sensor to give me a cost.
That allow me to have sankey charts, specific costs on my dashboard - etc.
It’s worth mentioning whilst I use the energy dashboard I don’t use it for the zigbee plugs as to my knowledge whilst it would show me a cost on the dash it doesn’t necessarily allow me to create a sensor with that cost for use elsewhere.
At the moment I’m on Octopus’ standard tariff but will be moving to agile in a few days. Ahead of this I wanted to update my template sensors (see example below) to pick up the changing agile rate through the day. I’m assuming the way I’ve built my sensors currently, would mean that the calculation would be wrong and the whole kWh measurement would be costed at the current rate rather than taking the rate at the specific point of consumption. Is this doable or have I gone down a path that leads to a dead end?
#### Computing (PS003)
- sensor:
- name: "Computing Energy Cost Daily"
unique_id: sensor.computer_power_ps003_energy_cost_daily
icon: mdi:currency-gbp
unit_of_measurement: “£”
state: >
{{(states(‘sensor.computer_power_ps003_energy_daily’) |float * `states(‘sensor.energy_rate_per_kwh’) | float )|round(2)}}
<<>>
Appreciate anyone pointing me in the right direction here.
Many thanks
Hi all, ive installed the octoblock integration and its working fantastic, thanks to all involved! my question is, does anybody know how to extract the hours and minutes only from the time given, i have the result: 2023-08-02T21:30:00 BST for best 1 hour rate but i need to program a solis inverter to charge the batteries at the lowest rate and it only accepts hours and minutes seperately. i have been searching the internet for days trying to find an answer and have come to the conclusion that my knowledge of python is non existant and this is beyond me. i do intend to start learning python but due to the rubbish summer we are having i need to start running this automation now and not in 3 months as i expected. thanks in advance.
Garyb
I’m not familiar with octoblock, but assuming the sensor you configured returns a datetime object you can use “.hour” and “.minute” to pass the inputs you need for your inverter.
This is an example of how I can print hour:minute from an octopus rate sensor:
{% set time = state_attr('binary_sensor.octopus_energy_target_dishwasher_afternoon_start_time', 'target_times')[0].valid_from %}
{{ time.hour }}:{{ time.minute }}
you can find more info at https://www.home-assistant.io/blog/2017/10/15/templating-date-time/
thanks for your reply stefano, i tried that but get an error: UndefinedError: None has no element 0
i tried replacing your binary_sensor with the octoblock sensor: sensor.octopus_1hour_time
and still get the same error, ive been reading the post The EPIC Time Conversion and Manipulation Thread! and am no closer to understanding how to achieve what i need as it is for people who already have a decent knowledge of scripting. i may have to start learning python script though it seems like a lot of effort for something that will be quite easy for some of the advanced members of this community.
what does the entity that you are getting the above information from look like?
post a screenshot of the entity from the dev tools states page showing the entity_id, it’s state and all of it’s attributes.
also if the data above comes from one the entities attributes note which attribute it is that you want to get the hours and minutes extracted from.
@gbartling, as @finity suggested we can help you if you share you sensor/entity.
Go to the Developer Tools screen, select States, in the entity field select your entity from which you are trying to extract hour and minute.
Once you selected it, you’ll be able to see something like the example I’ve attached.
Paste here the content of “State attributes”.
Based on that we should be able to guide you.
Last, as you use more and more HA it’s worth for you to spend a few hours reading the HA docs and the Jinja scripting guides. The developer tools is also a fantastic tool for anyone to master. Overtime it will save you hours of searching and attempts while allowing you to come up with nice solutions to your desires.
there are two ways you can do it.
you can either convert the state of your sensor to a datetime object then use the hour and minute method of that to get the hour and minute:
{% set time = states('sensor.octopus_4hour_time') %}
{{ strptime(time, "%Y-%m-%dT%H:%M:%S BST").hour }}
{{ strptime(time, "%Y-%m-%dT%H:%M:%S BST").minute }}
or you can just split the state string up and get the hour and minute directly:
{% set time = states('sensor.octopus_4hour_time') %}
{{ time.split('T')[1].split(':')[0] }}
{{ time.split('T')[1].split(':')[1] }}
both of those methods requires that the state is always in the same format as what you show.
if format varies then the conversions/slicing won’t work and you’ll need to use a different method.
thanks finity they both work perfectly.
typically if you reply to someone you should either press the reply button in their post or tag them (with the @ symbol). that way the person you are replying to gets a notification of the reply. otherwise they need to accidentally stumble on the reply. Like I did.
Hi All - I am on Octopus Agile and have a binary sensor that switches on during the lowest cost 3.5 hour window occurs overnight using BottlecapDave’s Octopus Energy integration, all good.
What I really want is a notification of the time this slot will start so the family can set the delay on the dishwasher manually. Unfortunately I cannot put the DW on a smart plug as it won’t start when power is restored, the main switch is momentary rather than latched.
Does anyone have ideas on how this can be done please?
TIA
something like this would work for you?
type: custom:mushroom-template-card
primary: Dishwasher cheapest hours
secondary: >-
{% set not_available = "I don't know" %}
{% set message = 'Start at' %}
{% if is_state("binary_sensor.dishwasher_morning_time_cycle", 'on') %}
{% if state_attr('binary_sensor.octopus_energy_target_dishwasher_morning_start_time', 'target_times') %}
{% set time = as_datetime( state_attr('binary_sensor.octopus_energy_target_dishwasher_morning_start_time', 'target_times')[0].valid_from | string ) %}
{{ message }} {{ as_timestamp(time) | int | timestamp_custom("%I:%M%p")}}
{% else %}
{{ not_available }}
{% endif %}
{% elif is_state("binary_sensor.dishwasher_afternoon_time_cycle", 'on')
%}
{% if state_attr('binary_sensor.octopus_energy_target_dishwasher_afternoon_start_time', 'target_times') %}
{% set time = as_datetime( state_attr('binary_sensor.octopus_energy_target_dishwasher_afternoon_start_time', 'target_times')[0].valid_from | string ) %}
{{ message }} {{ as_timestamp(time) | int | timestamp_custom("%I:%M%p")}}
{% else %}
{{ not_available }}
{% endif %}
{% elif is_state("binary_sensor.dishwasher_night_time_cycle", 'on') %}
{% if state_attr('binary_sensor.octopus_energy_target_dishwasher_night_start_time', 'target_times') %}
{% set time = as_datetime( state_attr('binary_sensor.octopus_energy_target_dishwasher_night_start_time', 'target_times')[0].valid_from | string ) %}
{{ message }} {{ as_timestamp(time) | int | timestamp_custom("%I:%M%p")}}
{% else %}
{{ not_available }}
{% endif %}
{% else %}
{{ not_available }}
{% endif %}
icon: mdi:currency-gbp
icon_color: green
hold_action:
action: none
double_tap_action:
action: none
entity: binary_sensor.octopus_energy_target_dishwasher_night_start_time
tap_action:
action: more-info
badge_color: ''
badge_icon: ''
Do you have the code for the Apex Chart?
@P6Dave see below. You just need to adjust it to use your “current_rate” sensor.
type: custom:apexcharts-card
experimental:
color_threshold: true
header:
show: true
show_states: true
colorize_states: true
title: Today Agile Export Rates
stacked: false
graph_span: 18h
span:
start: day
offset: +6h
now:
show: true
label: Now
color: black
yaxis:
- min: -10
max: 40
decimals: 1
series:
- entity: sensor.USE_YOUR_OCTOPUS_SENSOR_current_rate
type: column
name: price
color: gray
opacity: 1
stroke_width: 0
unit: p/Kw
show:
in_header: false
legend_value: false
header_color_threshold: true
color_threshold:
- value: -100
color: cyan
- value: 0
color: green
- value: 20
color: orange
- value: 30
color: red
data_generator: |
return entity.attributes.all_rates.map((entry) => {
return [new Date(entry.valid_from), entry.value_inc_vat];
});
Brilliant. Thanks very much.
i use the above and it works like a charm… very helpful as i get notified of any actions in my automation as needed. Try it out !
I’m unsure if you could turn on these devices. They normally require an input from a push-button.
I’m using Octoblock to provide the some best agile time slots for the day. But as I understand it octoblock runs from midnight for the full day calculations, but the agile prices are updated at 16:30. So any evening slots calculated will be incorrect once the new agile prices are published.