forked from romquenin/home-assistant-config-fr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer_diffuseur.yaml
executable file
·147 lines (133 loc) · 4.65 KB
/
timer_diffuseur.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
############################################################
## ##
## TIMER ##
## ##
############################################################
input_datetime:
only_time_for_timer:
name: Input datetime pour timer
has_date: false
has_time: true
timer:
timer_diffuseur:
input_number:
timer_diffuseur_seconds:
name: Seconds
initial: 0
max: 60
min: 0
step: 1
timer_diffuseur_minutes:
name: Minutes
initial: 0
max: 60
min: 0
step: 1
script:
timer_diffuseur_start:
sequence:
- service: timer.start
data_template:
entity_id: timer.timer_diffuseur
duration: '00:{{ states.input_number.timer_diffuseur_minutes.state | int }}:{{ states.input_number.timer_diffuseur_seconds.state | int }}'
timer_diffuseur_cancel:
sequence:
- service: timer.cancel
data:
entity_id: timer.timer_diffuseur
timer_diffuseur_start_input_datetime:
sequence:
- service: timer.start
data_template:
entity_id: timer.timer_diffuseur
duration: "{{ states.input_datetime.only_time_for_timer.state }}"
- service: switch.turn_on
data_template:
entity_id: switch.huiles_essentielles
automation:
- alias: 'Timer terminé'
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.timer_diffuseur
action:
- service: switch.turn_off
entity_id: switch.huiles_essentielles
- service: persistent_notification.create
data:
title: "Compte à rebours du diffuseur est terminé"
message: "C'est terminé!"
###Carte Timer https://forum.hacf.fr/t/carte-timer/725###
- alias: timer_diffuseur_mise_a_jour_pour_les_secondes
initial_state: off
id: 'timer_diffuseur_mise_a_jour_pour_les_secondes'
trigger:
platform: time_pattern
seconds: "/1"
condition:
action:
- service: homeassistant.update_entity
entity_id: sensor.timer_diffuseur_temps_restant_int
- service: python_script.ecrire_etat_entite
data:
entity_id: 'sensor.timer_diffuseur_temps_restant'
state: "{{states('sensor.timer_diffuseur_temps_restant_int')}}"
- alias: 'activation_desactivation_automation_timer_diffuseur_mise_a_jour_pour_les_secondes'
#Permet d'activer la mise à jour de l'entité sensor.timer_1h_temps_restant
trigger:
platform: state
entity_id: timer.timer_diffuseur
condition:
action:
- choose:
- conditions:
#Le timer n'est pas démarré
- condition: state
entity_id: timer.timer_diffuseur
state: "idle"
sequence:
- service: automation.turn_off
entity_id: automation.timer_diffuseur_mise_a_jour_pour_les_secondes
- conditions:
#Le timer est démarré
- condition: state
entity_id: timer.timer_diffuseur
state: "active"
sequence:
- service: automation.turn_on
entity_id: automation.timer_diffuseur_mise_a_jour_pour_les_secondes
- conditions:
#Le timer est en pause
- condition: state
entity_id: timer.timer_diffuseur
state: "paused"
sequence:
- service: automation.turn_off
entity_id: automation.timer_diffuseur_mise_a_jour_pour_les_secondes
default:
- service: automation.turn_off
entity_id: automation.timer_diffuseur_mise_a_jour_pour_les_secondes
sensor:
- platform: template
sensors:
timer_diffuseur_temps_restant_int:
friendly_name: "Timer End"
value_template: >
{% if is_state("timer.timer_diffuseur", "active") %}
{{ ( as_timestamp(state_attr('timer.timer_diffuseur', 'finishes_at')) | int - (now().timestamp()) | int ) | timestamp_custom('%M:%S', False) }}
{% elif is_state("timer.timer_diffuseur", "paused") %}
En pause
{% else %}
Non démarré
{% endif %}
attribute_templates:
icon: mdi:clock-fast
- platform: template
sensors:
#Temps restant du timer timer.timer_1h_temps mis à jour par le script python
timer_diffuseur_temps_restant:
friendly_name: 'Timer diffuseur : Temps restant'
value_template: ""
attribute_templates:
icon: 'mdi:clock-fast'