I’m trying to create a program in ESPHome to tilt the blinds. In the blind I have two relays, open and closed, and a potentiometer for the position. Also a switch to operate the blinds manually.
I want to create an automation in Home Assistant where I can move the blinds to a certain position. For example, blinds to 30%.
So far I have tried the following. In Home Assistant I can only go in one direction and how can I make the blinds move to a certain position?
Who can help me with this?
esphome:
name: jalousie
friendly_name: Jalousie
esp8266:
board: nodemcuv2
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key:
ota:
password:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Jalousie Fallback Hotspot"
password:
captive_portal:
#variabelen
globals:
- id: richting
type: bool
restore_value: true
initial_value: 'true'
#potmeter
sensor:
- platform: adc
pin: A0
name: "stand"
id: potmeter
update_interval: .2s
filters:
- multiply: 100
- filter_out: 100
accuracy_decimals: 0
on_value_range:
- above: 90
then:
- switch.turn_off: output_d5
- below: 10
then:
- switch.turn_off: output_d6
switch:
- platform: gpio
pin: D5
name: "jalousie open"
id: output_d5
- platform: gpio
pin: D6
name: "jalousie dicht"
id: output_d6
- platform: template
name: "Handbediening richting"
id: handb_richting
turn_on_action:
- globals.set:
id: richting
value: 'true'
turn_off_action:
- globals.set:
id: richting
value: 'false'
#handbediening schakelaar
binary_sensor:
- platform: gpio
pin:
number: D4
inverted: true
filters:
- delayed_on: 25ms
- delayed_off: 25ms
name: "hand bediening"
id: hand_bediening
on_press:
then:
if:
condition:
- switch.is_on: handb_richting
then:
- switch.turn_off: handb_richting
- if:
condition:
- lambda: return id(potmeter).state < 90;
then:
- switch.turn_on: output_d5
else:
- switch.turn_on: handb_richting
- if:
condition:
- lambda: return id(potmeter).state > 10;
then:
- switch.turn_on: output_d6
on_release:
- switch.turn_off: output_d5
- switch.turn_off: output_d6
cover:
- platform: template
name: "Jalousie BG zij 1"
id: Jalousie_BG_Z1
open_action:
- switch.turn_on: output_d6
close_action:
- switch.turn_on: output_d5
stop_action:
- switch.turn_off: output_d5
- switch.turn_off: output_d6