mirror of
https://github.com/brianhanifin/esphome-config.git
synced 2026-07-28 04:05:55 +00:00
87 lines
2.2 KiB
YAML
87 lines
2.2 KiB
YAML
---
|
|
# Shelly 2 Power Module
|
|
# Location: Upstairs Bathroom
|
|
#
|
|
substitutions:
|
|
project: Shelly1 02
|
|
id: shelly1_02
|
|
|
|
<<: !include common/substitutions/gpio/shelly1.yaml
|
|
|
|
<<: !include common/esphome/esp8266.yaml
|
|
<<: !include common/wifi.yaml
|
|
<<: !include common/api.yaml
|
|
<<: !include common/ota.yaml
|
|
<<: !include common/logger.yaml
|
|
|
|
script:
|
|
- id: relay_off_after_delay
|
|
then:
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return id(humidity).state < 50;
|
|
then:
|
|
# Turn off a manually turned on fan after 15 minutes, but only if humidity is below 50%.
|
|
- delay: 15min
|
|
- switch.turn_off: relay
|
|
else:
|
|
# No matter what, turn the fan off after an hour.
|
|
- delay: 60min
|
|
- switch.turn_off: relay
|
|
|
|
- id: relay_toggle
|
|
then:
|
|
if:
|
|
condition:
|
|
api.connected:
|
|
then:
|
|
- if:
|
|
condition:
|
|
switch.is_off: relay
|
|
then:
|
|
# Turn the relay on as requested.
|
|
- switch.turn_on: relay
|
|
|
|
- script.execute: relay_off_after_delay
|
|
else:
|
|
# Turn the switch off as requested.
|
|
- switch.turn_off: relay
|
|
|
|
else:
|
|
# When Home Assistant is unavailable, just toggle the relay.
|
|
- switch.toggle: relay
|
|
|
|
|
|
binary_sensor:
|
|
# Physical Toggle Switch. Monitor for switch position changes internally. Do not expose to Home Assistant.
|
|
- platform: gpio
|
|
pin:
|
|
number: $button_gpio
|
|
inverted: True
|
|
#name: $project Button
|
|
id: button
|
|
filters:
|
|
- delayed_on: 10ms
|
|
- delayed_off: 10ms
|
|
on_press:
|
|
- script.execute: relay_toggle
|
|
on_release:
|
|
- script.execute: relay_toggle
|
|
|
|
sensor:
|
|
# Monitor the humidity from Home Assistant.
|
|
- platform: homeassistant
|
|
id: humidity
|
|
entity_id: sensor.upstairs_bathroom_humidity
|
|
on_value_range:
|
|
- above: 55.0
|
|
then:
|
|
- switch.turn_on: relay
|
|
- below: 50.0
|
|
then:
|
|
- switch.turn_off: relay
|
|
|
|
switch:
|
|
<<: !include common/switches/relay_always_on.yaml
|