Added garage.yaml

This commit is contained in:
2021-11-08 18:22:25 +01:00
parent d47f0b4b62
commit c08fd7847d
2 changed files with 218 additions and 3 deletions

216
garage.yaml Normal file
View File

@@ -0,0 +1,216 @@
esphome:
name: garage
platform: ESP8266
board: esp01_1m
on_boot:
then:
- if:
condition:
and:
- binary_sensor.is_on: SensorUnten
- binary_sensor.is_off: SensorOben
then:
- lambda: |-
id(GarageStatus) = 0;
- if:
condition:
and:
- binary_sensor.is_off: SensorUnten
- binary_sensor.is_on: SensorOben
then:
- lambda: |-
id(GarageStatus) = 2;
- if:
condition:
and:
- binary_sensor.is_off: SensorUnten
- binary_sensor.is_off: SensorOben
then:
- lambda: |-
id(GarageStatus) = 1;
# Enable logging
logger:
# Enable Home Assistant API
#api:
ota:
password: "6e5ed3fb02234218269a67f7fb3dc2fb"
wifi:
ssid: "EasyBox-368239"
password: "inginf95"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Garage Fallback Hotspot"
password: "inginf95"
captive_portal:
web_server:
port: 80
auth:
username: nils
password: inginf95
globals:
- id: GarageStatus
type: int
restore_value: no
initial_value: '0'
#0 = open
#1 = in transit
#2 = closed, assume the garage is closed
mqtt:
broker: 192.168.178.76
port: 1884
username: nils
password: inginf95
switch:
- platform: gpio
name: "Relay"
id: pushbutton
pin: 14
inverted: true
on_turn_on:
- delay: 500ms
- switch.turn_off: pushbutton
text_sensor:
- platform: mqtt_subscribe
name: "Garage Command"
id: command
topic: cmnd/Badezimmer/MQTTGateway/Garage/target
on_value:
- if:
condition:
text_sensor.state:
id: command
state: 'OPEN'
then:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage soll ge<67>ffnet werden"
- if:
condition:
lambda: 'return (id(GarageStatus)==2);'
then:
- switch.turn_on: pushbutton
- if:
condition:
text_sensor.state:
id: command
state: 'CLOSE'
then:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage soll geschlossen werden"
- if:
condition:
lambda: 'return (id(GarageStatus)==0);'
then:
- switch.turn_on: pushbutton
binary_sensor:
- platform: gpio
pin:
number: 5
name: SensorOben
id: SensorOben
on_state:
if:
condition:
binary_sensor.is_on: SensorOben
then:
if:
condition:
binary_sensor.is_off: SensorUnten
then:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage ist offen"
- mqtt.publish:
topic: stat/Badezimmer/MQTTGateway/Garage/status
payload: "OPENED"
- lambda: |-
id(GarageStatus) = 0;
else: #is off
if:
condition:
binary_sensor.is_on: SensorUnten
then:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage ist geschlossen"
- mqtt.publish:
topic: stat/Badezimmer/MQTTGateway/Garage/status
payload: "CLOSED"
- lambda: |-
id(GarageStatus) = 2;
else:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage ist in Transit"
- mqtt.publish:
topic: stat/Badezimmer/MQTTGateway/Garage/status
payload: "IN TRANSIT"
- lambda: |-
id(GarageStatus) = 1;
- platform: gpio
pin:
number: 4
name: SensorUnten
id: SensorUnten
on_state:
if:
condition:
binary_sensor.is_on: SensorUnten
then:
if:
condition:
binary_sensor.is_off: SensorOben
then:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage ist geschlossen"
- mqtt.publish:
topic: stat/Badezimmer/MQTTGateway/Garage/status
payload: "CLOSED"
- lambda: |-
id(GarageStatus) = 2;
else: #is off
if:
condition:
binary_sensor.is_on: SensorOben
then:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage ist offen"
- mqtt.publish:
topic: stat/Badezimmer/MQTTGateway/Garage/status
payload: "OPENED"
- lambda: |-
id(GarageStatus) = 0;
else:
- mqtt.publish:
topic: stat/Garage/status
payload: "Garage ist in Transit"
- mqtt.publish:
topic: stat/Badezimmer/MQTTGateway/Garage/status
payload: "IN TRANSIT"
- lambda: |-
id(GarageStatus) = 1;
sensor:
- platform: wifi_signal
name: "WiFi Signal Sensor"
update_interval: 60s
- platform: uptime
name: Uptime Sensor

View File

@@ -13,15 +13,14 @@ ota:
password: "dd9d2a5e573d1d0ed1435d5c176b580c" password: "dd9d2a5e573d1d0ed1435d5c176b580c"
wifi: wifi:
ssid: "EasyBox-368239_WZ" ssid: "EasyBox-368239"
password: "inginf95" password: "inginf95"
# Enable fallback hotspot (captive portal) in case wifi connection fails # Enable fallback hotspot (captive portal) in case wifi connection fails
ap: ap:
ssid: "HS-Erdgeschoss Fallback Hotspot" ssid: "HS-Erdgeschoss Fallback Hotspot"
password: "inginf95" password: "inginf95"
switch: switch:
- platform: gpio - platform: gpio
name: "Ventil 1" name: "Ventil 1"