Hi
I can’t figure the global variables out.
I just want to use it so i can call the service in HA to control my covers.
I want to be able to control it through 2 buttons and i don’t have any feedback, but during travel it should be able to stop by pressing the opposite direction.
Here’s the script:
esphome:
name: signale-terrasse
platform: ESP8266
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "xxx"
wifi:
ssid: "xxx"
password: "xxx"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "xxx"
password: "xxx"
captive_portal:
globals:
- id: cover_1_closing
type: int
restore_value: no
initial_value: '0'
- id: cover_1_opening
type: int
restore_value: no
initial_value: '0'
sensor:
- platform: dht
pin: D8
temperature:
name: "Lüftung Ansaugung Temperatur"
humidity:
name: "Lüftung Ansaugung Luftfeuchtigkeit"
model: AM2302
update_interval: 60s
binary_sensor:
- platform: gpio
pin:
number: D0
mode: INPUT
inverted: true
name: "Store 1 UP"
internal: true
on_press:
- if:
condition:
lambda: |-
return id(cover_1_closing).state < 1;
then:
- homeassistant.service:
service: cover.open_cover
data:
entity_id: cover.store_1
- globals.set:
id: cover_1_opening
value: '1'
- delay: 33s
- globals.set:
id: cover_1_opening
value: '0'
else:
- homeassistant.service:
service: cover.stop_cover
data:
entity_id: cover.store_1
- globals.set:
id: cover_1_opening
value: '0'
- globals.set:
id: cover_1_closing
value: '0'
- platform: gpio
pin:
number: D1
mode: INPUT_PULLUP
inverted: true
name: "Store 1 DOWN"
internal: true
on_press:
- if:
condition:
lambda: |-
return id(cover_1_opening).state < 1;
then:
- homeassistant.service:
service: cover.close_cover
data:
entity_id: cover.store_1
- globals.set:
id: cover_1_closing
value: '1'
- delay: 33s
- globals.set:
id: cover_1_closing
value: '0'
else:
- homeassistant.service:
service: cover.stop_cover
data:
entity_id: cover.store_1
- globals.set:
id: cover_1_opening
value: '0'
- globals.set:
id: cover_1_closing
value: '0'
Thank you for your help