-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhottub_pump_on_every_thirty.yaml
91 lines (90 loc) · 3.66 KB
/
hottub_pump_on_every_thirty.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
automation:
- id: hottub_pump_on_every_thirty
alias: HotTub Pump on every 30
mode: restart
variables:
HoursLeft: "{{ ((as_timestamp(states.sensor.date.state + ' ' + states('input_datetime.hottub_ready_by')) - as_timestamp(now())) / 3600) }}"
DegreesLeft: "{{ (states('input_number.hottub_water_target') | int - states('input_number.hottub_water_temp') | int) }}"
trigger:
- platform: time_pattern
minutes: '/30'
seconds: '01'
- platform: homeassistant
event: start
- platform: event
event_type: automation_reloaded
- platform: state
entity_id: input_boolean.hottub_scheduled
- platform: state
entity_id: input_datetime.hottub_ready_by
- platform: state
entity_id: binary_sensor.hottub_at_or_below_max_heat_cost
action:
- choose:
# IF cheap pricing - heat
- conditions:
- condition: state
entity_id: binary_sensor.hottub_at_or_below_max_heat_cost
state: 'on'
sequence:
- service: logbook.log
data:
domain: switch
entity_id: switch.hottub_power
name: "Hot Tub"
message: "Heat for low price"
# - service: rest_command.hottub_temp_set
# data:
# hottub_api_did: !secret hottub_api_did
# hottub_water_target: 40
- service: switch.turn_on
entity_id: switch.hottub_heat
# ELIF scheduled and needs heat - heater on
- conditions: >
{{ (HoursLeft > 0) and (HoursLeft < DegreesLeft) and is_state('input_boolean.hottub_scheduled','on') }}
sequence:
- service: logbook.log
data:
domain: switch
entity_id: switch.hottub_heat
name: "Hot Tub"
message: "Heat on for schedule"
# - service: rest_command.hottub_temp_set
# data:
# hottub_api_did: !secret hottub_api_did
# hottub_water_target: "{{ states('input_number.hottub_water_target') | int }}"
- service: switch.turn_on
entity_id: switch.hottub_heat
# ELIF half hour 5 minutes filter
- conditions: >
{{ now().minute == 30 }}
sequence:
- service: logbook.log
data:
domain: switch
entity_id: switch.hottub_filter
name: "Hot Tub"
message: "Filter on"
# - service: rest_command.hottub_temp_set
# data:
# hottub_api_did: !secret hottub_api_did
# hottub_water_target: "{{ states('input_number.hottub_water_target') | int}} "
- service: switch.turn_off
entity_id: switch.hottub_power
- delay: '00:00:30'
- service: switch.turn_on
entity_id: switch.hottub_filter
# ELSE filter on for 5 mins
default:
- service: logbook.log
data:
domain: switch
entity_id: switch.hottub_filter
name: "Hot Tub"
message: "Off"
# - service: rest_command.hottub_temp_set
# data:
# hottub_api_did: !secret hottub_api_did
# hottub_water_target: "{{ states('input_number.hottub_water_target') | int}} "
- service: switch.turn_off
entity_id: switch.hottub_power