From 6e63a90ff7db9c96db5ce61a0d4830562724d036 Mon Sep 17 00:00:00 2001 From: ChNussbaum Date: Wed, 5 Feb 2020 22:04:00 -0600 Subject: [PATCH] More basement bathroom updates --- basement_bathroom_light_fan.yaml | 29 ++---- basement_bathroom_sensor.yaml | 107 +++++++++++++++++++-- basement_bathroom_shower_light_heater.yaml | 4 +- 3 files changed, 109 insertions(+), 31 deletions(-) diff --git a/basement_bathroom_light_fan.yaml b/basement_bathroom_light_fan.yaml index 6721b9a..9180e28 100644 --- a/basement_bathroom_light_fan.yaml +++ b/basement_bathroom_light_fan.yaml @@ -17,7 +17,7 @@ esphome: binary_sensor: - !include common/binary_sensor/status.yaml - platform: gpio - id: light_toggle + id: light_button pin: number: 12 mode: INPUT_PULLUP @@ -25,25 +25,17 @@ binary_sensor: then: - switch.toggle: light - platform: gpio - id: fan_toggle + id: fan_button pin: number: 3 mode: INPUT_PULLUP on_press: then: - - fan.toggle: fan - - platform: homeassistant - id: motion - name: Motion - entity_id: binary_sensor.basement_bathroom_motion - - platform: homeassistant - id: door - name: Door - entity_id: binary_sensor.basement_bathroom_door + - fan.toggle: the_fan fan: - platform: binary - id: fan + id: the_fan output: fan_output name: "Basement Bathroom Fan" @@ -55,17 +47,11 @@ output: sensor: - !include common/sensor/uptime.yaml - !include common/sensor/wifi.yaml - - platform: homeassistant - id: humidity - name: Humidity - entity_id: sensor.basement_bathroom_humidity - - platform: homeassistant - id: median_humidity - name: Median Humidity - entity_id: sensor.basement_bathroom_median_humidity status_led: - pin: 0 + pin: + number: 0 + inverted: true switch: - !include common/switch/restart.yaml @@ -74,7 +60,6 @@ switch: name: "Basement Bathroom Light" icon: mdi:lightbulb pin: 13 - inverted: false text_sensor: - !include common/text_sensor/version.yaml diff --git a/basement_bathroom_sensor.yaml b/basement_bathroom_sensor.yaml index c90b713..f2eeafb 100644 --- a/basement_bathroom_sensor.yaml +++ b/basement_bathroom_sensor.yaml @@ -24,25 +24,119 @@ i2c: binary_sensor: - !include common/binary_sensor/status.yaml - - platform: gpio - name: Basement Bathroom Motion - device_class: motion - pin: - number: D0 - mode: INPUT_PULLDOWN_16 + - platform: gpio name: Basement Bathroom Door + id: door device_class: door pin: number: D7 mode: INPUT_PULLUP + + - platform: gpio + name: Basement Bathroom Motion + id: motion + device_class: motion + pin: + number: D0 + mode: INPUT_PULLDOWN_16 + + - platform: template + id: motion_delay_30s + lambda: return id(motion).state; + filters: + - delayed_off: 30s + + - 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; + } + 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 + on_release: + then: + - homeassistant.service: + service: homeassistant.turn_off + data: + entity_id: switch.basement_bathroom_light, switch.basement_shower_light, switch.basement_bathroom_heat + - if: + condition: + binary_sensor.is_off: trigger_humidity + then: + - homeassistant.service: + service: homeassistant.turn_off + data: + entity_id: switch.basement_bathroom_fan + + - platform: template + id: trigger_humidity + lambda: return (id(humidity).state - id(median_humidity).state) > 5; + filters: + - delayed_off: 5min + on_press: + then: + - homeassistant.service: + service: homeassistant.turn_on + data: + entity_id: switch.basement_bathroom_fan + on_release: + then: + - if: + condition: + binary_sensor.is_off: trigger_motion + then: + - homeassistant.service: + service: homeassistant.turn_off + data: + entity_id: switch.basement_bathroom_fan + - platform: homeassistant id: day_night entity_id: input_boolean.day_night + + - platform: homeassistant + id: light + entity_id: switch.basement_bathroom_light + - platform: homeassistant id: shower_light entity_id: switch.basement_shower_light + - platform: homeassistant + id: heat + entity_id: switch.basement_bathroom_heat + output: - platform: gpio pin: D3 @@ -74,6 +168,7 @@ sensor: update_interval: 15s - platform: template name: "Basement Bathroom Median Humidity" + id: median_humidity unit_of_measurement: '%' icon: mdi:water-percent lambda: return id(humidity).state; diff --git a/basement_bathroom_shower_light_heater.yaml b/basement_bathroom_shower_light_heater.yaml index ae1d13f..a1a683e 100644 --- a/basement_bathroom_shower_light_heater.yaml +++ b/basement_bathroom_shower_light_heater.yaml @@ -25,7 +25,7 @@ binary_sensor: then: - switch.toggle: light - platform: gpio - id: fan_button + id: heater_button pin: number: 3 mode: INPUT_PULLUP @@ -49,13 +49,11 @@ switch: name: "Basement Shower Light" icon: mdi:lightbulb pin: 13 - inverted: false - platform: gpio id: heater name: "Basement Bathroom Heater" icon: mdi:radiator pin: 4 - inverted: false text_sensor: - !include common/text_sensor/version.yaml