Skip to content

Commit 964867e

Browse files
committed
blueprint: added blueprint for manual intelligent dispatch refreshes. This is the recommended way of achieving this functionality to ensure all users are not refreshing their data at the same time (1 .5 hours dev time)
1 parent b98167f commit 964867e

File tree

3 files changed

+89
-27
lines changed

3 files changed

+89
-27
lines changed

_docs/blueprints.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ This blueprint will fire a configured action when the consumption for the curren
7070

7171
This blueprint requires sensors provided by Octopus Energy Home Mini
7272

73+
## Intelligent
74+
75+
## Manual Intelligent Dispatch Refreshes
76+
77+
[Install blueprint](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgithub.com%2FBottlecapDave%2FHomeAssistant-OctopusEnergy%2Fblob%2Fdevelop%2F_docs%2Fblueprints%octopus_energy_manual_intelligent_refresh.yaml) | [Source](./blueprints/octopus_energy_manual_intelligent_refresh.yaml)
78+
79+
This blueprint will fire the [intelligent dispatches service](./services.md#octopus_energyrefresh_intelligent_dispatches) either when a sensor from another integration determines the car has been plugged in (e.g. the plug status from the [MyEnergi integration](https://github.com/CJNE/ha-myenergi)) or when the data is stale and overdue a refresh (in case the dispatch information has changed).
80+
81+
!!! warning
82+
83+
This blueprint requires you to be on an intelligent tariff and a way to determine that your car is plugged in from another integration.
84+
7385
## Wheel of Fortune
7486

7587
### Automatically spin wheel of fortune (single)
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
blueprint:
2+
name: Octopus Energy - Manual Intelligent Refresh
3+
description: Handle the refresh of intelligent dispatches automatically, while refreshing when an external car sensor is plugged in. When automatic, will use normal backoff methods in event of failure.
4+
domain: automation
5+
author: BottlecapDave
6+
7+
input:
8+
intelligent_dispatches_data_last_retrieved_sensor:
9+
name: Intelligent dispatches data last retrieved
10+
description: "The sensor that determines when intelligent dispatches data was last retrieved (e.g. sensor.octopus_energy_{{ACCOUNT_ID}}_intelligent_dispatches_data_last_retrieved). More information can be found at https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/entities/diagnostics/#intelligent-dispatches-data-last-retrieved"
11+
selector:
12+
entity:
13+
filter:
14+
domain: sensor
15+
integration: octopus_energy
16+
17+
intelligent_dispatches_sensor:
18+
name: Intelligent dispatches
19+
description: "The sensor that determines if intelligent dispatches is active (e.g. binary_sensor.octopus_energy_{{ACCOUNT_ID}}_intelligent_dispatching)"
20+
selector:
21+
entity:
22+
filter:
23+
domain: binary_sensor
24+
integration: octopus_energy
25+
26+
car_plugged_in_sensor:
27+
name: Car plugged in sensor (external)
28+
description: "The external sensor that determines if the car has been plugged in (e.g. binary_sensor.car_is_plugged_in). This sensor is provided by an integration outside of the Octopus Energy integration."
29+
selector:
30+
entity:
31+
filter:
32+
domain:
33+
- binary_sensor
34+
- sensor
35+
- input_boolean
36+
37+
car_plugged_in_sensor_state:
38+
name: Car plugged in sensor expected state
39+
description: "The expected state of the external sensor that determines if the car has been plugged in (e.g. 'on')."
40+
selector:
41+
text:
42+
43+
actions:
44+
name: Actions
45+
description: Additional actions to run after refresh
46+
default: []
47+
selector:
48+
action: {}
49+
50+
variables:
51+
intelligent_dispatches_sensor: !input intelligent_dispatches_sensor
52+
car_plugged_in_sensor: !input car_plugged_in_sensor
53+
54+
mode: queued
55+
max: 4
56+
trigger_variables:
57+
intelligent_dispatches_data_last_retrieved_sensor: !input intelligent_dispatches_data_last_retrieved_sensor
58+
triggers:
59+
- trigger: state
60+
entity_id: !input car_plugged_in_sensor
61+
to: !input car_plugged_in_sensor_state
62+
- trigger: template
63+
value_template: >
64+
{{ state_attr(intelligent_dispatches_data_last_retrieved_sensor, 'next_refresh') | as_datetime | as_local < now() }}
65+
conditions:
66+
- condition: state
67+
entity_id: !input car_plugged_in_sensor
68+
state: !input car_plugged_in_sensor_state
69+
actions:
70+
# Wait 30 seconds to give OE a chance to update the dispatches
71+
- delay: 00:00:30
72+
- action: octopus_energy.refresh_intelligent_dispatches
73+
target:
74+
entity_id: !input intelligent_dispatches_sensor
75+
- choose: []
76+
default: !input actions

_docs/services.md

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -292,33 +292,7 @@ Refreshes intelligent dispatches for a given account.
292292

293293
#### Automation Example
294294

295-
The below example is how you might refresh the dispatches when you car is plugged in, or every 3 minutes when your car is plugged in. Please note that the entity `binary_sensor.car_is_plugged_in` is not provided by the integration and should be replaced by an external source (e.g. the plug status from the [MyEnergi integration](https://github.com/CJNE/ha-myenergi) or a manual input switch that you switch on manually when you plug in your car).
296-
297-
!!! warn
298-
299-
There is a chance that the automation may fail due to the service call limit when the car is plugged in
300-
301-
```yaml
302-
mode: single
303-
alias: Refresh intelligent dispatches
304-
triggers:
305-
- trigger: state
306-
entity_id: binary_sensor.car_is_plugged_in
307-
to: on
308-
# Refresh every 3 minutes in case the schedule has changed
309-
- trigger: time_pattern
310-
minutes: /3
311-
conditions:
312-
- condition: state
313-
entity_id: binary_sensor.car_is_plugged_in
314-
state: on
315-
actions:
316-
# Wait 30 seconds to give OE a chance to update the dispatches
317-
- delay: 00:00:30
318-
- action: octopus_energy.refresh_intelligent_dispatches
319-
target:
320-
entity_id: binary_sensor.octopus_energy_{{ACCOUNT_ID}}_intelligent_dispatching
321-
```
295+
For an automation example, please refer to the available [blueprint](./blueprints.md#manual-intelligent-dispatch-refreshes).
322296

323297
## Miscellaneous
324298

0 commit comments

Comments
 (0)