# GPIO16: Onboard relay (bathroom fan)
# GPIO13: DHT22
+substitutions:
+ domo_fan: "522"
+ domo_hum: "520"
+ domo_temp: "521"
+ domo_thresh: "902"
+
esphome:
name: bathroom
- light.turn_on: blue_led
- delay: 2s # Too soon and the first messages don't get through!
- lambda: |-
- id(tell_domo_nvalue)->execute(522, id(fan_relay).state);
- id(tell_domo_svalue)->execute(523, std::to_string(id(hum_threshold)));
+ id(tell_domo_nvalue)->execute(${domo_fan}, id(fan_relay).state);
+ id(tell_domo_nsvalues)->execute(${domo_thresh}, 2, std::to_string(id(hum_threshold)));
on_disconnect:
then:
// ESP_LOGD("on_json_message", x["name"]);
switch (idx) {
- case 522: /* Fan relay */
+ case ${domo_fan}: /* Fan relay */
if (nvalue) {
id(fan_relay).turn_on();
id(relay_off_time) = ::time(NULL) + id(fan_delay);
}
break;
- case 523: /* Humidity threshold */
- id(hum_threshold) = x["svalue"].as<float>();
+ case ${domo_thresh}: /* Humidity threshold */
+ id(hum_threshold) = x["svalue1"].as<float>();
ESP_LOGD("mqtt", "Got hum_threshold %f", id(hum_threshold));
break;
}
on_turn_on:
then:
- lambda: |-
- id(tell_domo_nvalue)->execute(522, 1);
+ id(tell_domo_nvalue)->execute(${domo_fan}, 1);
id(relay_off_time) = 0;
on_turn_off:
then:
- lambda: |-
- id(tell_domo_nvalue)->execute(522, 0);
+ id(tell_domo_nvalue)->execute(${domo_fan}, 0);
id(relay_off_time) = 0;
sensor:
then:
lambda: |-
if (!isnan(x))
- id(tell_domo_svalue)->execute(521, std::to_string(x));
+ id(tell_domo_svalue)->execute(${domo_temp}, std::to_string(x));
humidity:
name: "Bathroom Humidity"
on_value:
hum_stat = "2"; // Dry
}
if (!isnan(x))
- id(tell_domo_nsvalues)->execute(520, x, hum_stat);
+ id(tell_domo_nsvalues)->execute(${domo_hum}, x, hum_stat);
update_interval: 10s
# GPIO16: Onboard relay (toilet fan)
# GPIO13: DHT22
+substitutions:
+ domo_fan: "900"
+ domo_hum: "898"
+ domo_temp: "899"
+ domo_thresh: "901"
+
esphome:
name: toilet
- light.turn_on: blue_led
- delay: 2s # Too soon and the first messages don't get through!
- lambda: |-
- id(tell_domo_nvalue)->execute(900, id(fan_relay).state);
- id(tell_domo_svalue)->execute(901, std::to_string(id(hum_threshold)));
+ id(tell_domo_nvalue)->execute(${domo_fan}, id(fan_relay).state);
+ id(tell_domo_nsvalues)->execute(${domo_thresh}, 2, std::to_string(id(hum_threshold)));
on_disconnect:
then:
// ESP_LOGD("on_json_message", x["name"]);
switch (idx) {
- case 900: /* Fan relay */
+ case ${domo_fan}: /* Fan relay */
if (nvalue) {
id(fan_relay).turn_on();
id(relay_off_time) = ::time(NULL) + id(fan_delay);
}
break;
- case 901: /* Humidity threshold */
- id(hum_threshold) = x["svalue"].as<float>();
+ case ${domo_thresh}: /* Humidity threshold */
+ id(hum_threshold) = x["svalue1"].as<float>();
ESP_LOGD("mqtt", "Got hum_threshold %f", id(hum_threshold));
break;
}
on_turn_on:
then:
- lambda: |-
- id(tell_domo_nvalue)->execute(900, 1);
+ id(tell_domo_nvalue)->execute(${domo_fan}, 1);
id(relay_off_time) = 0;
on_turn_off:
then:
- lambda: |-
- id(tell_domo_nvalue)->execute(900, 0);
+ id(tell_domo_nvalue)->execute(${domo_fan}, 0);
id(relay_off_time) = 0;
sensor:
then:
lambda: |-
if (!isnan(x))
- id(tell_domo_svalue)->execute(899, std::to_string(x));
+ id(tell_domo_svalue)->execute(${domo_temp}, std::to_string(x));
humidity:
name: "Toilet Humidity"
on_value:
hum_stat = "2"; // Dry
}
if (!isnan(x))
- id(tell_domo_nsvalues)->execute(898, x, hum_stat);
+ id(tell_domo_nsvalues)->execute(${domo_hum}, x, hum_stat);
update_interval: 10s