2020-02-04 04:03:45 +00:00
|
|
|
substitutions:
|
|
|
|
device_id: basement_bathroom_sensor
|
|
|
|
device_name: Basement Bathroom Sensor
|
|
|
|
platform: ESP8266
|
|
|
|
board: d1_mini
|
|
|
|
ip_address: !secret basement_bathroom_sensor_ip
|
|
|
|
ota_pwd: !secret basement_bathroom_sensor_ota_pwd
|
|
|
|
api_pwd: !secret basement_bathroom_sensor_api_pwd
|
|
|
|
ap_wifi_pwd: !secret basement_bathroom_sensor_ap_wifi_pwd
|
|
|
|
|
|
|
|
esphome:
|
|
|
|
<<: !include common/esphome.yaml
|
2020-02-05 04:04:48 +00:00
|
|
|
on_boot:
|
|
|
|
then:
|
|
|
|
- output.turn_on: motion_pwr
|
2020-02-04 04:03:45 +00:00
|
|
|
|
|
|
|
<<: !include common/common.yaml
|
2020-02-14 02:59:08 +00:00
|
|
|
<<: !include common/logger/logger_none.yaml
|
2020-02-04 04:03:45 +00:00
|
|
|
|
2020-02-05 04:04:48 +00:00
|
|
|
i2c:
|
|
|
|
sda: D2
|
|
|
|
scl: D1
|
|
|
|
scan: true
|
|
|
|
|
2020-02-04 04:03:45 +00:00
|
|
|
binary_sensor:
|
|
|
|
- !include common/binary_sensor/status.yaml
|
2020-02-06 04:04:00 +00:00
|
|
|
|
2020-02-04 04:03:45 +00:00
|
|
|
- platform: gpio
|
|
|
|
name: Basement Bathroom Door
|
2020-02-06 04:04:00 +00:00
|
|
|
id: door
|
2020-02-04 04:03:45 +00:00
|
|
|
device_class: door
|
|
|
|
pin:
|
2020-02-05 04:04:48 +00:00
|
|
|
number: D7
|
2020-02-04 04:03:45 +00:00
|
|
|
mode: INPUT_PULLUP
|
2020-02-06 04:04:00 +00:00
|
|
|
|
|
|
|
- platform: gpio
|
|
|
|
name: Basement Bathroom Motion
|
|
|
|
id: motion
|
|
|
|
device_class: motion
|
|
|
|
pin:
|
|
|
|
number: D0
|
|
|
|
mode: INPUT_PULLDOWN_16
|
|
|
|
on_press:
|
|
|
|
then:
|
|
|
|
- if:
|
|
|
|
condition:
|
|
|
|
and:
|
|
|
|
- binary_sensor.is_off: light
|
|
|
|
- binary_sensor.is_off: shower_light
|
|
|
|
- binary_sensor.is_off: heat
|
|
|
|
then:
|
|
|
|
- if:
|
|
|
|
condition:
|
|
|
|
binary_sensor.is_on: day_night
|
|
|
|
then:
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_on
|
|
|
|
data:
|
|
|
|
entity_id: switch.basement_bathroom_light
|
|
|
|
else:
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_on
|
|
|
|
data:
|
|
|
|
entity_id: switch.basement_shower_light
|
2020-02-09 21:06:10 +00:00
|
|
|
|
|
|
|
- platform: template
|
|
|
|
id: motion_delay_30s
|
|
|
|
lambda: return id(motion).state;
|
|
|
|
filters:
|
|
|
|
- delayed_off: 30s
|
|
|
|
|
2020-02-10 16:49:58 +00:00
|
|
|
- platform: template
|
|
|
|
id: motion_delay_5m
|
|
|
|
lambda: return id(motion).state;
|
|
|
|
filters:
|
|
|
|
- delayed_off: 5min
|
|
|
|
on_release:
|
|
|
|
then:
|
|
|
|
- if:
|
|
|
|
condition:
|
|
|
|
binary_sensor.is_off: trigger_humidity
|
|
|
|
then:
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_off
|
|
|
|
data:
|
|
|
|
entity_id: fan.basement_bathroom_fan
|
|
|
|
|
2020-02-09 21:06:10 +00:00
|
|
|
- platform: template
|
|
|
|
id: motion_delay_20m
|
|
|
|
lambda: return id(motion).state;
|
|
|
|
filters:
|
|
|
|
- delayed_off: 20min
|
|
|
|
|
|
|
|
- platform: template
|
|
|
|
id: trigger_motion
|
|
|
|
lambda: |-
|
|
|
|
if (id(door).state) {
|
|
|
|
return id(motion_delay_30s).state;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return id(motion_delay_20m).state;
|
|
|
|
}
|
2020-02-10 16:49:58 +00:00
|
|
|
filters:
|
|
|
|
- delayed_off: 3s
|
2020-02-06 04:04:00 +00:00
|
|
|
on_release:
|
|
|
|
then:
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_off
|
|
|
|
data:
|
2020-02-09 04:16:34 +00:00
|
|
|
entity_id: switch.basement_bathroom_light
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_off
|
|
|
|
data:
|
|
|
|
entity_id: switch.basement_shower_light
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_off
|
|
|
|
data:
|
|
|
|
entity_id: switch.basement_bathroom_heater
|
2020-02-06 04:04:00 +00:00
|
|
|
|
|
|
|
- platform: template
|
|
|
|
id: trigger_humidity
|
|
|
|
lambda: return (id(humidity).state - id(median_humidity).state) > 5;
|
|
|
|
filters:
|
|
|
|
- delayed_off: 5min
|
|
|
|
on_release:
|
|
|
|
then:
|
|
|
|
- if:
|
|
|
|
condition:
|
|
|
|
binary_sensor.is_off: trigger_motion
|
|
|
|
then:
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_off
|
|
|
|
data:
|
2020-02-09 21:06:10 +00:00
|
|
|
entity_id: fan.basement_bathroom_fan
|
2020-02-06 04:04:00 +00:00
|
|
|
|
2020-02-05 04:04:48 +00:00
|
|
|
- platform: homeassistant
|
|
|
|
id: day_night
|
|
|
|
entity_id: input_boolean.day_night
|
2020-02-06 04:04:00 +00:00
|
|
|
|
|
|
|
- platform: homeassistant
|
|
|
|
id: light
|
|
|
|
entity_id: switch.basement_bathroom_light
|
|
|
|
|
2020-02-05 04:04:48 +00:00
|
|
|
- platform: homeassistant
|
|
|
|
id: shower_light
|
|
|
|
entity_id: switch.basement_shower_light
|
|
|
|
|
2020-02-06 04:04:00 +00:00
|
|
|
- platform: homeassistant
|
|
|
|
id: heat
|
2020-02-09 04:16:34 +00:00
|
|
|
entity_id: switch.basement_bathroom_heater
|
2020-02-06 04:04:00 +00:00
|
|
|
|
2020-02-05 04:04:48 +00:00
|
|
|
output:
|
|
|
|
- platform: gpio
|
|
|
|
pin: D3
|
|
|
|
id: bme_gnd
|
|
|
|
- platform: gpio
|
|
|
|
pin: D5
|
|
|
|
id: motion_gnd
|
|
|
|
- platform: gpio
|
|
|
|
pin: D6
|
|
|
|
id: motion_pwr
|
|
|
|
- platform: gpio
|
|
|
|
pin: D8
|
|
|
|
id: door_gnd
|
2020-02-04 04:03:45 +00:00
|
|
|
|
|
|
|
sensor:
|
|
|
|
- !include common/sensor/uptime.yaml
|
|
|
|
- !include common/sensor/wifi.yaml
|
|
|
|
- platform: bme280
|
|
|
|
temperature:
|
|
|
|
id: temperature
|
|
|
|
name: "Basement Bathroom Temperature"
|
|
|
|
pressure:
|
|
|
|
id: pressure
|
|
|
|
name: "Basement Bathroom Pressure"
|
|
|
|
humidity:
|
|
|
|
id: humidity
|
|
|
|
name: "Basement Bathroom Humidity"
|
2020-02-05 04:04:48 +00:00
|
|
|
address: 0x76
|
|
|
|
update_interval: 15s
|
2020-02-04 04:03:45 +00:00
|
|
|
- platform: template
|
|
|
|
name: "Basement Bathroom Median Humidity"
|
2020-02-06 04:04:00 +00:00
|
|
|
id: median_humidity
|
2020-02-05 04:04:48 +00:00
|
|
|
unit_of_measurement: '%'
|
|
|
|
icon: mdi:water-percent
|
|
|
|
lambda: return id(humidity).state;
|
2020-02-04 04:03:45 +00:00
|
|
|
update_interval: 60s
|
2020-02-15 19:34:41 +00:00
|
|
|
on_raw_value:
|
|
|
|
then:
|
|
|
|
- if:
|
|
|
|
condition:
|
|
|
|
binary_sensor.is_on: trigger_humidity
|
|
|
|
then:
|
|
|
|
- homeassistant.service:
|
|
|
|
service: homeassistant.turn_on
|
|
|
|
data:
|
|
|
|
entity_id: fan.basement_bathroom_fan
|
2020-02-04 04:03:45 +00:00
|
|
|
filters:
|
|
|
|
- median:
|
|
|
|
window_size: 360
|
2020-02-05 04:04:48 +00:00
|
|
|
send_every: 2
|
|
|
|
send_first_at: 2
|
|
|
|
|
|
|
|
status_led:
|
|
|
|
pin:
|
|
|
|
number: D4
|
|
|
|
inverted: true
|
2020-02-04 04:03:45 +00:00
|
|
|
|
|
|
|
switch:
|
|
|
|
- !include common/switch/restart.yaml
|
|
|
|
|
|
|
|
text_sensor:
|
|
|
|
- !include common/text_sensor/version.yaml
|
|
|
|
- !include common/text_sensor/wifi.yaml
|