esphome:
name: lobbydoor-opener
platform: ESP8266
board: esp_wroom_02
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret api_password
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: lobbydoor-outdoor
password: !secret wifi_ap_password
captive_portal:
#############################
esphome:
name: lobbydoor-opener
platform: ESP8266
board: esp_wroom_02
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret api_password
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: lobbydoor-outdoor
password: !secret wifi_ap_password
captive_portal:
#############################
globals:
- id: auto_open
type: bool
restore_value: no
initial_value: 'false'
- id: not_opened
type: bool
restore_value: no
initial_value: 'false'
- id: opening
type: bool
restore_value: no
initial_value: 'false'
i2c:
sda: GPIO4
scl: GPIO5
scan: True
sensor:
- platform: bh1750
name: "Interphone Illuminance"
address: 0x23
update_interval: 1s
internal: true
on_value_range:
- above: 8 #8lux以上
then:
- if:
condition:
lambda: 'return id(auto_open) == true;'
then:
#flg on
- globals.set:
id: opening
value: 'true'
# open!
#Click 応答
- servo.write:
id: servo1
level: -40%
- delay: 500ms
- servo.write:
id: servo1
level: 0%
#Click 開錠
- servo.write:
id: servo2
level: -50%
- delay: 500ms
- servo.write:
id: servo2
level: 0%
- servo.detach: servo2
#Click 閉じる
- servo.write:
id: servo1
level: -40%
- delay: 500ms
- servo.write:
id: servo1
level: 0%
- servo.detach: servo1
# auto off
- globals.set:
id: auto_open
value: 'false'
# flg off
- globals.set:
id: opening
value: 'false'
else:
#flg on
- globals.set:
id: not_opened
value: 'true'
- delay: 500ms
# flg off
- globals.set:
id: not_opened
value: 'false'
binary_sensor:
- platform: template
name: "LobbyDoor not open"
id: lobbydoor_not_open
lambda: 'return id(not_opened);'
- platform: template
name: "LobbyDoor opening"
id: lobbydoor_opening
lambda: 'return id(opening);'
servo:
- id: servo1
output: pwm_output1
auto_detach_time: 10s
- id: servo2
output: pwm_output2
auto_detach_time: 10s
output:
- platform: esp8266_pwm
id: pwm_output1
pin: GPIO12
frequency: 50 Hz
- platform: esp8266_pwm
id: pwm_output2
pin: GPIO13
frequency: 50 Hz
switch:
- platform: template
name: Lobbydoor Auto Open
id: lobbydoor_auto_open
internal: false
lambda: 'return id(auto_open);'
turn_on_action:
- globals.set:
id: auto_open
value: 'true'
turn_off_action:
- globals.set:
id: auto_open
value: 'false'