-
-
Save tjhorner/267ef058b192f40b5918a402ff550b38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
esphome: | |
name: smartlock | |
platform: ESP8266 | |
board: d1_mini | |
output: | |
- platform: esp8266_pwm | |
id: pwm_output | |
pin: D1 | |
frequency: 50Hz | |
servo: | |
- id: lock_servo | |
min_level: "2%" | |
max_level: "12.6%" | |
output: pwm_output | |
switch: | |
- platform: template | |
id: lock_switch | |
name: "Front Door Lock" | |
icon: "mdi:lock" | |
optimistic: true | |
restore_state: true | |
turn_on_action: | |
- servo.write: | |
id: lock_servo | |
level: -0.9 | |
turn_off_action: | |
- servo.write: | |
id: lock_servo | |
level: 0.3 | |
binary_sensor: | |
- platform: gpio | |
id: lock_button | |
on_click: | |
- min_length: 50ms | |
max_length: 1s | |
then: | |
- switch.toggle: lock_switch | |
- min_length: 1s | |
max_length: 5s | |
then: | |
- switch.turn_off: lock_switch | |
- delay: 10s | |
- switch.turn_on: lock_switch | |
pin: | |
number: D5 | |
inverted: true | |
mode: INPUT_PULLUP | |
- platform: gpio | |
id: hall_sensor | |
name: "Front Door Position" | |
device_class: door | |
filters: | |
- delayed_on_off: 1s | |
pin: | |
number: D6 | |
inverted: false | |
mode: INPUT_PULLUP | |
# Enable logging | |
logger: | |
debug: | |
# Enable Home Assistant API | |
api: | |
password: "" | |
services: | |
- service: control_servo | |
variables: | |
level: float | |
then: | |
- servo.write: | |
id: lock_servo | |
level: !lambda "return level / 100.0;" | |
ota: | |
password: "" | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
# Enable fallback hotspot (captive portal) in case wifi connection fails | |
ap: | |
ssid: "Smart Lock Fallback Hotspot" | |
password: "" | |
captive_portal: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment