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
## this part goes in configuration.yaml | |
input_number: | |
office_blinds_tilt: | |
name: Office Blinds Tilt | |
initial: 0 | |
min: -100 | |
max: 100 | |
step: 1 | |
mode: slider | |
## this part goes in automations.yaml | |
- alias: office blinds tilt servo input | |
id: officeblindstiltservoinput45765934785 | |
trigger: | |
platform: state | |
entity_id: input_number.office_blinds_tilt | |
action: | |
- service: esphome.office_blinds_control_servo | |
data_template: | |
level: '{{ trigger.to_state.state | int }}' | |
## this part goes in your ESPhome servo_device.yaml | |
esphome: | |
name: office_blinds | |
platform: ESP8266 | |
board: d1_mini | |
wifi: | |
ssid: !secret wifi | |
password: !secret wifi_pw | |
debug: | |
# Enable logging | |
logger: | |
level: debug | |
# Enable Home Assistant API & new Service for Servo Control | |
api: | |
services: | |
- service: control_servo | |
variables: | |
level: float | |
then: | |
- servo.write: | |
id: ob_tilt | |
level: !lambda 'return level / 100.0;' | |
ota: | |
output: | |
- platform: gpio | |
id: 'ob_1' | |
pin: D1 | |
- platform: gpio | |
id: 'ob_2' | |
pin: D2 | |
- platform: esp8266_pwm ## this is for the servo | |
id: 'ob_t' | |
pin: D0 | |
frequency: 50 Hz | |
switch: | |
- platform: output | |
name: "ob1" | |
output: 'ob_1' | |
id: ob1 | |
- platform: output | |
name: "ob2" | |
output: 'ob_2' | |
id: ob2 | |
servo: | |
- output: 'ob_t' | |
id: ob_tilt | |
binary_sensor: | |
- platform: gpio | |
pin: D5 | |
name: "Office Blinds End Stop" | |
filters: | |
invert: | |
on_press: | |
then: | |
- switch.turn_off: ob1 | |
- switch.turn_off: ob2 | |
id: ob_end_stop | |
- platform: gpio | |
pin: D3 | |
name: "OB Button" | |
filters: | |
invert: | |
on_press: | |
then: | |
- lambda: | | |
if (id(ob_open).state == cover::COVER_OPEN) { | |
if (id(ob1).state){ | |
// shade is opening | |
id(ob_open).stop(); | |
} else { | |
// shade is open and not moving | |
id(ob_open).close(); | |
} | |
} else { | |
if (id(ob2).state){ | |
// shade is closing | |
id(ob_open).stop(); | |
} else { | |
// shade is closed and not moving | |
id(ob_open).open(); | |
} | |
} | |
cover: | |
- platform: template | |
name: "Office Blinds Full" | |
id: ob_open | |
optimistic: true | |
open_action: | |
- switch.turn_off: ob2 | |
- switch.turn_on: ob1 | |
## customize this time delay based on how long it takes your blinds to fully lift | |
- delay: 155s | |
- switch.turn_off: ob1 | |
close_action: | |
- switch.turn_off: ob1 | |
- switch.turn_on: ob2 | |
## customize this time delay based on how long it takes your blinds to fully descend | |
- delay: 122s | |
- switch.turn_off: ob2 | |
stop_action: | |
- switch.turn_off: ob1 | |
- switch.turn_off: ob2 | |
- platform: template | |
name: "Office Blinds Control" | |
id: ob_open_control | |
assumed_state: true | |
open_action: | |
- switch.turn_off: ob2 | |
- switch.turn_on: ob1 | |
close_action: | |
- switch.turn_off: ob1 | |
- switch.turn_on: ob2 | |
stop_action: | |
- switch.turn_off: ob1 | |
- switch.turn_off: ob2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment