forked from romquenin/home-assistant-config-fr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysteme.yaml
executable file
·117 lines (109 loc) · 3.62 KB
/
systeme.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
############################################################
## SENSOR ##
############################################################
sensor:
- platform: systemmonitor
resources:
- type: last_boot
- type: memory_use_percent
- type: process
arg: octave-cli
- type: processor_use
- type: memory_free
- type: disk_use_percent
arg: /
- type: disk_free
arg: /
- platform: filesize
file_paths:
- /config/home-assistant_v2.db
- platform: version
name: version
- platform: time_date
display_options:
- 'time'
- 'date'
- platform: uptime
name: Uptime
scan_interval: 60
- platform: command_line
name: CPU Temp
scan_interval: 60
unit_of_measurement: °C
command: >-
if [ -e /sys/class/thermal/thermal_zone0/temp ]
then cat /sys/class/thermal/thermal_zone0/temp
fi
value_template: >-
{% if value != '' %}
{{ value | multiply(0.001) | round }}
{% else %}
unknown
{% endif %}
- platform: template
sensors:
ha_uptime:
friendly_name: 'Uptime'
icon_template: mdi:home-assistant
value_template: >-
{% set up_time = as_timestamp(now()) - as_timestamp(states('sensor.uptime')) %}
{% if up_time == 0 %}
Démarrage...
{% else %}
{% set minutes = (up_time // 60) | int %}
{% set hours = (minutes // 60) %}
{% set days = (hours // 24) %}
{% set weeks = (days // 7) %}
{% set minutes = (minutes % 60) %}
{% set hours = (hours % 24) %}
{% set days = (days % 7) %}
{% macro phrase(value, name) %}
{%- set value = value %}
{{- '{} {}{}'.format(value, name, end) if value | int > 0 else '' }}
{%- endmacro %}
{% set text = [ phrase(weeks, 's'), phrase(days, 'j'), phrase(hours, 'h'), phrase(minutes, 'min') ] | select('!=','') | list | join(', ') %}
{% set last_comma = text.rfind(',') %}
{% if last_comma != -1 %}
{% set text = text[:last_comma] + ',' + text[last_comma + 1:] %}
{% endif %}
{{ text }}
{% endif %}
############################################################
## SCRIPT ##
############################################################
script:
'reboot_ha':
alias: '[Systeme] Redémarrer'
sequence:
- data: {}
service: homeassistant.restart
############################################################
## AUTOMATION ##
############################################################
automation:
- alias: '[Démarrage] Système'
initial_state: on
trigger:
- platform: homeassistant
event: start
action:
- delay:
seconds: 10
- service: automation.trigger
entity_id: automation.input_select_mis_a_jour_par_harmony
- delay:
seconds: 5
- service: script.turn_on
entity_id: script.create_all_automations_group
- service: script.turn_on
entity_id: script.create_all_scripts_group
- delay:
seconds: 120
- service: python_script.set_state
data_template:
entity_id: group.all_scenes
state: Liste
- service: python_script.set_state
data_template:
entity_id: group.all_scripts
state: Liste