# turn on GPIO25, trigger *three* readings a second apart, and turn GPIO25 off
# again. The ADC sensor has a filter to average the three readings.
+esphome:
+ includes:
+ - chrono.h
+
+globals:
+ - id: last_valid_temp
+ type: long long
+ restore_value: no
+
script:
- id: mqtt_connect_domo
then:
call.set_target_temperature(target_temp);
call.perform();
+time:
+ - platform: sntp
+ on_time:
+ - seconds: 0
+ minutes: /1
+ then:
+ lambda: |-
+ long long now = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
+ if (!id(last_valid_temp)) {
+ id(last_valid_temp) = now;
+ return;
+ }
+ // No valid readings for ten minutes? Turn heat off!
+ if (now > id(last_valid_temp) + 600) {
+ ESP_LOGI("ufh", "No valid temperature readings! Turning heating off");
+ auto call = id(ntc_climate).make_call();
+ call.set_mode("OFF");
+ call.perform();
+ id(ufh_relay).turn_off();
+ }
+
mqtt:
on_connect:
then:
send_every: 1
send_first_at: 1
- clamp:
- min_value: 5
+ min_value: 8
max_value: 35
ignore_out_of_range: true
on_value:
then:
lambda: |-
- if (!isnan(x))
+ if (!isnan(x)) {
id(tell_domo_svalue)->execute(${domo_temp}, std::to_string(x));
+ id(last_valid_temp) = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
+ }
- platform: resistance
id: ntc_resistance