-
Notifications
You must be signed in to change notification settings - Fork 0
/
automations.yaml
66 lines (61 loc) · 2.06 KB
/
automations.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
alias: Dishwasher scheduler
description: ""
trigger:
- platform: state
entity_id:
- input_button.schedule_dishwasher
id: schedule
- platform: template
value_template: >-
{% set prices =
state_attr('sensor.entsoe_average_electricity_price_today',
'prices_today') +
state_attr('sensor.entsoe_average_electricity_price_today',
'prices_tomorrow') %}
{% set intervals = 4 %}
{% set ns = namespace(bestPrice=1, bestTime=None) %}
{% for i in range(prices|length - (intervals - 1)) %}
{% set ns2 = namespace(currentPrice=prices[i]["price"]) %}
{% for interval in range(intervals) %}
{% if interval != 0 %}
{% set ns2.currentPrice = ns2.currentPrice + (prices[i+interval]["price"]) %}
{% endif %}
{% endfor %}
{% set ns2.currentPrice = ns2.currentPrice / intervals %}
{% if ns2.currentPrice < ns.bestPrice %}
{% set ns.bestPrice = ns2.currentPrice %}
{% set ns.bestTime = prices[i]["time"] %}
{% endif %}
{% endfor %}
{{ (now().strftime('%d-%m %H:%M') ==
(as_timestamp(ns.bestTime)|as_datetime|as_local).strftime('%d-%m %H:%M'))
and states('input_boolean.dishwasher_scheduled') == 'on' }}
id: run
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- schedule
sequence:
- service: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.dishwasher_scheduled
- conditions:
- condition: trigger
id:
- run
sequence:
- service: home_connect.start_program
data:
device_id: 101bf69fcbe90cea354ba978dde4a572
program: Dishcare.Dishwasher.Program.Eco50
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.dishwasher_scheduled
mode: single