Hey Guys -
I recently added a motor to my venetian blinds which turns clockwise / counter-clockwise to open and close them. The motor is attached to HA via ESPHome. In Home Assistant, I added a cover for the blinds which allows me to fully open, close, or stop them - it works great.
What I’m trying to do is add a button to Lovelace which will enable me to open them to 50%, but haven’t had success doing so. I’ve reviewed the documentation for cover plus tried examples in other forums without luck. I also tried setting up an automation to set the blinds at 50% which didn’t work. Below is the code I currently use. Any help would be appreciated!
ESPHome Config
esphome:
name: officeblinds
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "xxxxxxxxxxxxxx"
password: "xxxxxxxxxxxxx"
ap:
ssid: "Officeblinds Fallback Hotspot"
password: "xxxxxxxxxxxxxxx"
captive_portal:
logger:
api:
services:
- service: control_blind
variables:
target: int
then:
- stepper.set_target:
id: my_stepper
target: !lambda 'return target;'
- sensor.template.publish:
id: position
state: !lambda 'return target;'
cover:
- platform: template
name: "Office Window Blinds"
id: my_blind
device_class: blind
open_action:
- stepper.set_target:
id: my_stepper
target: 0
- sensor.template.publish:
id: position
state: !lambda return id(my_stepper).target_position;
close_action:
- stepper.set_target:
id: my_stepper
target: 24000
- sensor.template.publish:
id: position
state: !lambda return id(my_stepper).target_position;
stop_action:
- stepper.set_target:
id: my_stepper
target: !lambda return id(my_stepper).current_position;
- sensor.template.publish:
id: position
state: !lambda return id(my_stepper).current_position;
optimistic: true
assumed_state: true
sensor:
- platform: template
name: "Office Blinds"
id: position
stepper:
- platform: uln2003
id: my_stepper
pin_a: D1
pin_b: D2
pin_c: D3
pin_d: D4
max_speed: 500 steps/s
sleep_when_done: true
acceleration: inf
deceleration: inf
step_mode: FULL_STEP
ota:
(Current) Lovelace Button
type: entities
entities:
- entity: cover.office_window_blinds
Automation Attempted (Failed to do anything)
- id: '1621522082992'
alias: Blinds 50% Test
description: ''
trigger:
- platform: time
at: '10:00'
condition: []
action:
- service: cover.set_cover_position
target:
entity_id: cover.office_window_blinds
data:
position: 50
mode: single
Any help would be appreciated - Thanks!