-
Notifications
You must be signed in to change notification settings - Fork 0
/
as_ezo_rtd.yaml
225 lines (199 loc) · 6.39 KB
/
as_ezo_rtd.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
substitutions:
include_dependencies_as_ezo_rtd: "defined"
############################################################
##
## INITIALIZE SENSOR STATES FROM LAST BOOT
##
############################################################
esphome:
on_boot:
priority: -200 # Highest priority, ensures enable pin to be turned off first
then:
- lambda: |-
id(${device_name}_rtd).set_sensor_type(esphome::ezo::SENSOR_TYPE_RTD);
/***************************************************************
* enable/disable sensors depending on last boot sensor states
***************************************************************/
//always on, since turning off leads to problems with i2c communication sometimes
//id(${device_name}_rtd_enable_pin).turn_on();
id(${device_name}_rtd_enable).turn_on();
//
//if(id(rtd_enabled))
// id(${device_name}_rtd_enable).turn_on();
//else
// id(${device_name}_rtd_enable).turn_off();
/***************************************************************
* enable/disable value sending
***************************************************************/
if(id(rtd_reading_enabled))
id(${device_name}_rtd_enable_reading_values).turn_on();
else
id(${device_name}_rtd_enable_reading_values).turn_off();
sensor:
# SENSOR DEFINITION
- platform: custom_ezo
id: ${device_name}_rtd
name: ${device_name_upper}.rtd
address: 102
accuracy_decimals: 2
unit_of_measurement: "°C"
update_interval: 0.1s
internal: ${entities_internal}
filters:
- sliding_window_moving_average:
window_size: ${sliding_window_size_rtd}
send_every: ${sliding_window_send_every_rtd}
globals:
# PERMANENT GLOBALS FOR STATE STORAGE
- id: rtd_enabled
type: bool
restore_value: yes
initial_value: 'true'
- id: rtd_reading_enabled
type: bool
restore_value: yes
initial_value: 'true'
output:
# ENABLE PIN
- platform: gpio
pin: ${enable_rtd_pin}
id: ${device_name}_rtd_enable_pin
switch:
# CALIBRATION MODE
- platform: template
name: ${device_name_upper}.rtd.cal.activate
id: ${device_name}_rtd_cal_activate
lambda: |-
return id(${device_name}_rtd).calibration_mode_active();
turn_on_action:
- lambda: |-
id(${device_name}_rtd).activate_calibration();
turn_off_action:
- lambda: |-
id(${device_name}_rtd).deactivate_calibration();
internal: ${entities_internal}
# ENABLE/DISABLE SENSOR (removed because this lead to some problems)
- platform: template
id: ${device_name}_rtd_enable
name: ${device_name_upper}.rtd.enable
internal: "true"
lambda: |-
return id(rtd_enabled);
turn_on_action:
- lambda: |-
id(${device_name}_rtd).enable_sensor();
- globals.set:
id: rtd_enabled
value: "true"
- output.turn_on: ${device_name}_rtd_enable_pin
turn_off_action:
- lambda: |-
id(${device_name}_rtd).disable_sensor();
- globals.set:
id: rtd_enabled
value: "false"
- output.turn_off: ${device_name}_rtd_enable_pin
#- switch.turn_off: ${device_name}_ec_enable
#- switch.turn_off: ${device_name}_ph_enable
# ENABLE / DISABLE VALUE SENDING
- platform: template
id: ${device_name}_rtd_enable_reading_values
name: ${device_name_upper}.rtd.enable_reading_values
lambda: |-
return id(${device_name}_rtd).sending_values();
turn_on_action:
- lambda: |-
id(${device_name}_rtd).enable_sending_values();
id(rtd_reading_enabled) = true;
turn_off_action:
- lambda: |-
id(${device_name}_rtd).disable_sending_values();
id(rtd_reading_enabled) = false;
button:
# CALIBRATION METHODS
- platform: template
name: ${device_name_upper}.rtd.cal.check
id: ${device_name}_rtd_cal_check
on_press:
lambda: |-
id(${device_name}_rtd).start_calibration_check();
internal: ${entities_internal}
- platform: template
name: ${device_name_upper}.rtd.cal.clear
id: ${device_name}_rtd_cal_clear
on_press:
lambda: |-
id(${device_name}_rtd).start_calibration_clear();
internal: ${entities_internal}
- platform: template
name: ${device_name_upper}.rtd.cal
id: ${device_name}_rtd_cal
on_press:
lambda: |-
id(${device_name}_rtd).start_calibration_rtd();
internal: ${entities_internal}
# FACTORY RESET
- platform: template
name: ${device_name_upper}.rtd.factory_reset
id: ${device_name}_rtd_factory_reset
on_press:
lambda: |-
id(${device_name}_rtd).start_factory_reset();
internal: ${entities_internal}
number:
# SAMPLE INTERVAL TIME IN [MS]
- platform: template
min_value: ${min_sample_interval_rtd}
max_value: ${max_sample_interval_rtd}
step: "1"
id: ${device_name}_rtd_sample_interval
name: ${device_name}.rtd.sample_interval
optimistic: true
mode: box
restore_value : true
initial_value: ${min_sample_interval_rtd}
update_interval: "10s"
unit_of_measurement: "ms"
on_value:
- lambda: |-
id(${device_name}_rtd).set_sample_interval(x);
# CALIBRATION POINTS
- platform: template
min_value: "0"
max_value: "100.0"
step: "0.01"
id: ${device_name}_rtd_cal_value
name: ${device_name}.rtd.cal.cal_value
optimistic: true
mode: box
restore_value : true
initial_value: "100.0"
update_interval: "10s"
unit_of_measurement: "°C"
on_value:
- lambda: |-
id(${device_name}_rtd).set_rtd_cal_value(x);
internal: ${entities_internal}
binary_sensor:
# ERROR CHECKING SENSOR
#- platform: template
# name: "${device_name_upper}.rtd.error"
# id: ${device_name}_rtd_error
# lambda: |-
# if (id(${device_name}_rtd).retry_counter() >= ${max_retry_attempts})
# {
# return true;
# }else
# {
# return false;
# }
# on_press:
# then:
# if:
# condition:
# lambda: |-
# return id(rtd_enabled);
# then:
# # - switch.turn_off: ${device_name}_rtd_enable
# # - delay: 2s
# # - switch.turn_on: ${device_name}_rtd_enable