-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sensor.yaml
230 lines (197 loc) · 10.8 KB
/
sensor.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
- platform: rest
name: sv01pro_sensor
resource: "http://192.168.10.157:7125/printer/objects/query?heater_bed&motion_report&extruder&print_stats&toolhead&display_status&temperature_sensor%20mcu_temp&temperature_sensor%20raspberry_pi&output_pin%20caselight"
json_attributes_path: "$.result.status"
json_attributes:
- heater_bed
- extruder
- print_stats
- toolhead
- display_status
- motion_report
- 'output_pin caselight'
- 'temperature_sensor mcu_temp'
- 'temperature_sensor raspberry_pi'
value_template: >-
{{ 'OK' if ('result' in value_json) else None }}
force_update: true
scan_interval: 5
# Adding an API key is only necessary while using the [authorization] component
# and if Home Assistant is not a trusted client
# headers:
# x-api-key: 123456789abcdefghijklmno
#
- platform: rest
scan_interval: 15
name: klipper_preview_path
resource_template: "http://192.168.10.157:7125/server/files/metadata?filename={{ states(('sensor.sv01pro_current_print')) }}"
json_attributes_path: "$.result.thumbnails.[1]"
json_attributes:
- relative_path
- width
- height
- size
value_template: "OK"
- platform: template
sensors:
sv01pro_parent_file_path:
friendly_name: "File Parent Path"
value_template: '{{ states.sensor.sv01pro_sensor.attributes["print_stats"]["filename"].split("/")[:-1] |join("/")}}'
sv01pro_url_thumbnail:
friendly_name: "URL thumbnail Path"
value_template: '{% if is_state("sensor.sv01pro_parent_file_path", "") %}{{ states("sensor.sv01pro_object_thumbnails") }}{% else %}{{ states("sensor.sv01pro_parent_file_path") }}/{{ states("sensor.sv01pro_object_thumbnails") }}{% endif %}'
sv01pro_object_thumbnails:
friendly_name: "Object Thumbnails"
value_template: '{{ states.sensor.sv01pro_file_metadata.attributes["thumbnails"][1]["relative_path"] }}'
icon_template: mdi:image
sv01pro_hotend_power:
friendly_name: "Hotend Power"
value_template: '{{ ((states.sensor.sv01pro_sensor.attributes["extruder"]["power"] | float) * 100) | round(0) }}'
unit_of_measurement: "%"
icon_template: mdi:flash
sv01pro_bed_power:
friendly_name: "Bed Power"
value_template: '{{ ((states.sensor.sv01pro_sensor.attributes["heater_bed"]["power"] | float) * 100) | round(0) }}'
unit_of_measurement: "%"
icon_template: mdi:flash
sv01pro_heaters_power:
friendly_name: "Bed and Nozzle Power"
value_template: '{{ states("sensor.sv01pro_bed_power") }}% / {{ states("sensor.sv01pro_hotend_power") }}%'
windspeed_too_high:
value_template: "{{ state_attr('weather.greenock_st', 'wind_speed')|float > 20}}"
friendly_name: 'Windspeed too high'
sv01pro_hotend_target:
friendly_name: 'Hotend target'
device_class: temperature
unit_of_measurement: '°C'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['extruder']['target'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_hotend_actual:
friendly_name: 'Hotend actual'
device_class: temperature
unit_of_measurement: '°C'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['extruder']['temperature'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_bed_target:
friendly_name: 'Bed target'
device_class: temperature
unit_of_measurement: '°C'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['heater_bed']['target'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_bed_actual:
friendly_name: 'Bed actual'
device_class: temperature
unit_of_measurement: '°C'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['heater_bed']['temperature'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
# sv01pro_state:
# icon_template: mdi:printer-3d
# value_template: >-
# {{ states.sensor.sv01pro_sensor.attributes['print_stats']['state'] if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_state:
friendly_name: "Printer State"
value_template: '{{ states.sensor.sv01pro_sensor.attributes["print_stats"]["state"]}}'
icon_template: >
{% set val = states.sensor.sv01pro_sensor.attributes["print_stats"]["state"] %}
{% if val == 'standby' %}
mdi:sleep
{% elif val == 'error' %}
mdi:alert-circle
{% elif val == 'printing' %}
mdi:printer-3d-nozzle
{% elif val == 'paused' %}
mdi:pause-circle
{% elif val == 'complete' %}
mdi:printer-3d
{% else %}
mdi:help-circle
{% endif %}
sv01pro_current_print:
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['print_stats']['filename'] if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_current_progress:
unit_of_measurement: '%'
icon_template: mdi:file-percent
value_template: >-
{{ (states.sensor.sv01pro_sensor.attributes['display_status']['progress'] * 100) | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_print_time:
icon_template: mdi:clock-start
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['print_stats']['print_duration'] | timestamp_custom("%H:%M:%S", 0) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_time_remaining:
icon_template: mdi:clock-end
value_template: >-
{{ (((states.sensor.sv01pro_sensor.attributes['print_stats']['print_duration'] / states.sensor.sv01pro_sensor.attributes['display_status']['progress'] - states.sensor.sv01pro_sensor.attributes['print_stats']['print_duration']) if states.sensor.sv01pro_sensor.attributes['display_status']['progress'] > 0 else 0) | timestamp_custom('%H:%M:%S', 0)) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_eta:
icon_template: mdi:clock-outline
value_template: >-
{{ (as_timestamp(now()) + 2 * 60 * 60 + ((states.sensor.sv01pro_sensor.attributes['print_stats']['print_duration'] / states.sensor.sv01pro_sensor.attributes['display_status']['progress'] - states.sensor.sv01pro_sensor.attributes['print_stats']['print_duration']) if states.sensor.sv01pro_sensor.attributes['display_status']['progress'] > 0 else 0)) | timestamp_custom("%H:%M:%S", 0) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_layer_height:
friendly_name: "Layer Height"
value_template: '{{ states.sensor.sv01pro_file_metadata.attributes["layer_height"] | float }}'
unit_of_measurement: "mm"
icon_template: mdi:arrow-collapse-down
sv01pro_object_height:
friendly_name: "Object Height"
value_template: '{{ (states.sensor.sv01pro_file_metadata.attributes["object_height"] | float) - (states.sensor.sv01pro_file_metadata.attributes["layer_height"] | float) }}'
unit_of_measurement: "mm"
icon_template: mdi:arrow-expand-vertical
sv01pro_current_height:
friendly_name: "Current Height"
value_template: '{{ states.sensor.sv01pro_sensor.attributes["gcode_move"]["gcode_position"][2] | float | round(2) }}'
unit_of_measurement: "mm"
icon_template: mdi:arrow-collapse-down
sv01pro_current_layer:
friendly_name: "Current Layer"
value_template: '{{ (states("sensor.sv01pro_current_height")|float / states("sensor.sv01pro_layer_height")|float)|round(0) }}'
sv01pro_total_layers:
friendly_name: "Total Layers"
value_template: '{{ (states("sensor.sv01pro_object_height")|float / states("sensor.sv01pro_layer_height")|float)|round(0) }}'
sv01pro_nozzletemp:
friendly_name: "Nozzle temp"
icon_template: mdi:thermometer
device_class: temperature
value_template: >-
{{ [(states.sensor.sv01pro_sensor.attributes['extruder']['temperature'] | float | round(1) | string), " / ", (states.sensor.sv01pro_sensor.attributes['extruder']['target'] | float | round(1) | string)] | join if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_bedtemp:
friendly_name: "Bed temp"
icon_template: mdi:thermometer
device_class: temperature
value_template: >-
{{ [(states.sensor.sv01pro_sensor.attributes['heater_bed']['temperature'] | float | round(1) | string), " / ", (states.sensor.sv01pro_sensor.attributes['heater_bed']['target'] | float | round(1) | string)] | join if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_speed_actual:
device_class: speed
unit_of_measurement: 'mm/s'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['motion_report']['live_velocity'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_extruder_velocity:
device_class: speed
unit_of_measurement: 'mm/s'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['motion_report']['live_extruder_velocity'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_rpi_actual:
friendly_name: "RPI temperature"
device_class: temperature
unit_of_measurement: '°C'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['temperature_sensor raspberry_pi']['temperature'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_mcu_actual:
friendly_name: "MCU temperature"
device_class: temperature
unit_of_measurement: '°C'
value_template: >-
{{ states.sensor.sv01pro_sensor.attributes['temperature_sensor mcu_temp']['temperature'] | float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_filament_used:
device_class: distance
unit_of_measurement: 'cm'
value_template: >-
{{ (states.sensor.sv01pro_sensor.attributes['print_stats']['filament_used'] / 10)| float | round(1) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_light_brightness:
unit_of_measurement: '%'
icon_template: mdi:file-percent
value_template: >-
{{ (states.sensor.sv01pro_sensor.attributes['output_pin caselight']['value'] *100) | round(0) if is_state('sensor.sv01pro_sensor', 'OK') else None }}
sv01pro_light_helper:
friendly_name: "sv01pro light helper"
value_template: >-
{{ 'on' if states('sensor.sv01pro_light_brightness') | int > 0 else 'off' }}