Skip to content

Instantly share code, notes, and snippets.

@andywarburton
Created May 28, 2025 12:58
Show Gist options
  • Save andywarburton/6d0fc2245ed933839b2b75b0b68ce08b to your computer and use it in GitHub Desktop.
Save andywarburton/6d0fc2245ed933839b2b75b0b68ce08b to your computer and use it in GitHub Desktop.
esphome:
name: esphome-web-06c3f4
friendly_name: Office Blind Controller 06c3f4
min_version: 2024.11.0
name_add_mac_suffix: false
esp8266:
board: d1_mini
restore_from_flash: True
preferences:
flash_write_interval: 12hours
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "XXXXX"
ota:
- platform: esphome
password: "XXXX"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: XXXX
gateway: XXXX
subnet: XXXX
dns1: XXXX
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Office-Blind-Controller"
password: "5xTImlkBReYt"
captive_portal:
web_server:
stepper:
- platform: a4988
id: my_stepper
sleep_pin:
number: GPIO13
inverted: True
dir_pin: GPIO14
step_pin: GPIO12
max_speed: 1500
acceleration: inf
deceleration: inf
switch:
- platform: template
name: "Move Blind Up"
optimistic: True
id: switch_blind_up
on_turn_on:
- logger.log: "switch is on"
- script.execute: blind_up
on_turn_off:
- logger.log: "switch is off"
- script.execute: blind_stop
- platform: template
name: "Move Blind Down"
optimistic: True
id: switch_blind_down
on_turn_on:
- logger.log: "switch is on"
- script.execute: blind_down
on_turn_off:
- logger.log: "switch is off"
- script.execute: blind_stop
button:
- platform: template
name: "STOP Blind"
id: button_blind_stop
on_press:
- logger.log: "STOP SWITCH ON"
- script.execute: blind_stop
cover:
- platform: time_based
name: "Office Blinds"
id: living_room_blinds
has_built_in_endstop: False
open_action:
- switch.turn_on: switch_blind_up
open_duration: 115s
close_action:
- switch.turn_on: switch_blind_down
close_duration: 115s
stop_action:
- switch.turn_off: switch_blind_down
- switch.turn_off: switch_blind_up
- button.press: button_blind_stop
script:
- id: blind_up
then:
- while:
condition:
switch.is_on: switch_blind_up
then:
- delay: 0.25s
- logger.log: "MOVING SERVO UP"
- stepper.report_position:
id: my_stepper
position: 0
- stepper.set_target:
id: my_stepper
target: 500
- id: blind_down
then:
- while:
condition:
switch.is_on: switch_blind_down
then:
- delay: 0.25s
- logger.log: "MOVING SERVO DOWN"
- stepper.report_position:
id: my_stepper
position: 0
- stepper.set_target:
id: my_stepper
target: -500
- id: blind_stop
then:
- logger.log: "STOPPING SERVO"
- switch.turn_off: switch_blind_down
- switch.turn_off: switch_blind_up
- delay: 1s
- stepper.report_position:
id: my_stepper
position: 0
- stepper.set_target:
id: my_stepper
target: 0
number:
- platform: template
name: "Motor Turn Amount"
id: stepper_move_amount
unit_of_measurement: 'steps'
min_value: -9999
max_value: 9999
initial_value: 200
step: 1
mode: box
optimistic: true
restore_value: true
entity_category: config
sensor:
- platform: template
name: "Stepper Position"
id: stepper_pos
unit_of_measurement: s
lambda: "return id(my_stepper).current_position;"
# update_interval: 5s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment