-
Notifications
You must be signed in to change notification settings - Fork 185
/
bike.yaml
executable file
·40 lines (37 loc) · 978 Bytes
/
bike.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
---
#-
# _ _ _
# | |__ (_) | _____
# | '_ \| | |/ / _ \
# | |_) | | < __/
# |_.__/|_|_|\_\___|
#
#
#- from github.com/basnijholt/home-assistant-config
# Only charge for 6 hours to maximize battery lifespan
- alias: "Bike: started charging"
trigger:
platform: state
entity_id: switch.bike_charger
to: "on"
from: "off"
action:
- service: input_datetime.set_datetime
data:
entity_id: input_datetime.bike_charger_on
timestamp: "{{ now().timestamp() }}"
- service: input_datetime.set_datetime
data:
entity_id: input_datetime.bike_charger_off
timestamp: "{{ now().timestamp() + 3600 * 6 }}"
- alias: "Bike: stop charging"
trigger:
platform: time_pattern
minutes: '/1'
condition:
condition: template
value_template: "{{ states('sensor.time') == states('input_datetime.bike_charger_off')[0:5] }}"
action:
service: switch.turn_off
data:
entity_id: switch.bike_charger