-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprtg.yaml
189 lines (180 loc) · 4.93 KB
/
prtg.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
homeassistant:
customize:
sensor.prtg_alarms:
icon: mdi:close-circle-outline
state_color: red
sensor.prtg_upsens:
icon: mdi:check-circle-outline
state_color: green
sensor.prtg_unknownsens:
icon: mdi:help-circle-outline
state_color: grey
sensor.prtg_warnsens:
icon: mdi:alert-circle-outline
state_color: orange
sensor.prtg_pausedsens:
icon: mdi:pause-circle-outline
state_color: blue
sensor.prtgsensors:
icon: mdi:motion-sensor
state_color: blue
sensor.prtg_script:
icon: mdi:script-text-play-outline
state_color: purple
automation.lightson:
icon: mdi:light-switch
automation.lightsoff:
icon: mdi:light-switch-off
sensor:
- platform: rest
name: PrtgSensors
resource: !secret prtg-url
params:
id: 0
apitoken: !secret prtg-api-token
json_attributes:
- Alarms
- UpSens
- WarnSens
- PausedSens
- UnknownSens
value_template: >
{% if state_attr('sensor.prtgsensors', 'Alarms')|int(0) > 0 %}
{{ state_attr('sensor.prtgsensors', 'Alarms') }} Alarms
{% elif state_attr('sensor.prtgsensors', 'WarnSens')|int(0) > 0 %}
{{ state_attr('sensor.prtgsensors', 'WarnSens') }} Warnings
{% elif state_attr('sensor.prtgsensors', 'PausedSens')|int(0) > 0 %}
{{ state_attr('sensor.prtgsensors', 'PausedSens') }} Paused
{% endif %}
- platform: template
sensors:
prtg_alarms:
friendly_name: "PRTG Alarm"
value_template: "{{ state_attr('sensor.prtgsensors', 'Alarms') | int(0)}}"
prtg_upsens:
friendly_name: "PRTG UpSens"
value_template: "{{ state_attr('sensor.prtgsensors', 'UpSens') | int(0) }}"
prtg_unknownsens:
friendly_name: "PRTG UnknownSens"
value_template: "{{ state_attr('sensor.prtgsensors', 'UnknownSens') | int(0) }}"
prtg_warnsens:
friendly_name: "PRTG WarnSens"
value_template: "{{ state_attr('sensor.prtgsensors', 'WarnSens') | int(0) }}"
prtg_pausedsens:
friendly_name: "PRTG PausedSens"
value_template: "{{ state_attr('sensor.prtgsensors', 'PausedSens') | int(0) }}"
# helper sensors for light
prtg_script:
friendly_name: "PRTG Alarm Color"
value_template: >
{% if state_attr('sensor.prtgsensors', 'Alarms')|int(0) > 0 %}
prtg_alarm
{% elif state_attr('sensor.prtgsensors', 'WarnSens')|int(0) > 0 %}
prtg_warning
{% elif state_attr('sensor.prtgsensors', 'PausedSens')|int(0) > 0 %}
prtg_paused
{% else %}
prtg_ok
{% endif %}
script:
prtg_alarm:
alias: PRTG Alarm
sequence:
- service: light.turn_on
data:
entity_id: "{{ light }}"
color_name: red
brightness: 255
flash: long
mode: single
icon: mdi:close-circle-outline
prtg_warning:
alias: PRTG Warning
sequence:
- service: light.turn_on
data:
entity_id: "{{ light }}"
color_name: orange
brightness: 127
flash: long
mode: single
icon: mdi:alert-circle-outline
prtg_paused:
alias: PRTG Paused
sequence:
- service: light.turn_on
data:
entity_id: "{{ light }}"
color_name: blue
brightness: 55
mode: single
icon: mdi:pause-circle-outline
prtg_ok:
alias: PRTG OK
sequence:
- service: light.turn_on
data:
entity_id: "{{ light }}"
color_name: green
brightness: 3
mode: single
icon: mdi:check-circle-outline
input_datetime:
lighton:
name: Turn light every weekday on at
has_date: false
has_time: true
icon: mdi:light-switch
initial: "08:00"
lightoff:
name: Turn light off at
has_date: false
has_time: true
icon: mdi:light-switch-off
initial: "17:00"
automation:
- alias: Light from PRTG
description: ""
trigger:
- platform: state
entity_id:
- sensor.prtgsensors
condition:
- condition: state
entity_id: light.noc
state: "on"
action:
service: "script.{{ states('sensor.prtg_script') }}"
data:
light: !secret noclight
mode: single
- alias: lightson
description: "Turn lights on"
trigger:
- platform: time
at: input_datetime.lighton
condition:
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
action:
- service: light.turn_on
target:
entity_id: !secret noclight
- service: "script.{{ states('sensor.prtg_script') }}"
data:
light: !secret noclight
mode: single
- alias: lightsoff
description: "Turn lights off"
trigger:
- platform: time
at: input_datetime.lightoff
action:
- service: light.turn_off
entity_id: !secret noclight
mode: single