Fizyczne klawisze do sterowania roletami (góra/dół)

@welpl
poprawiony kod:

    on_press:
      then:
        - lambda: |
            if (id(roleta_przedsionek).current_operation == COVER_OPERATION_IDLE) {
              id(roleta_przedsionek).make_call().set_command_open().perform();
            } else {
              id(roleta_przedsionek).make_call().set_command_stop().perform();    
            }    

Poniżej cały kod do płytki esp8266 nodemcu v3.
Zamiennie :wink: ESP32 na 8 rolet.
Przekaźniki w trybie interlock z opóźnieniem 200ms (zabezpiecza przed włączeniem jednocześnie góra - dół) - mogą być pomocne w razie popsucia się stanu otwarcia/zamknięcia rolety.
przekaz

Fiyzyczne i wirtualne przyciski działają za zasadzie góra/dół dowolny przycisk wyłącz.

substitutions:
  device_name_lower: "test"

esphome:
  name: ${device_name_lower}

esp8266:
  board: nodemcuv2

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "afe78518ea3599494473a6xxxxxxxxxx"

wifi:
  ssid: moja_siec_wifi
  password: moje_haslo

# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name_lower}_roleta"
    password: "moje_haslo_do_wifi_esp_roleta"

captive_portal:
    
web_server:
  port: 80
 
cover:
  - platform: time_based
    device_class: shutter
    name: "${device_name_lower}_roleta"
    id: my_cover
    
    open_action:
      - switch.turn_on: sw01
    open_duration: 65s

    close_action:
      - switch.turn_on: sw02
    close_duration: 60s

    stop_action:
      - switch.turn_off: sw01
      - switch.turn_off: sw02
      
# fizyczny przycisk D1 i D2
binary_sensor:

  - platform: gpio
    pin:
      number: D1
      inverted: true
      mode:
        input: true
        pullup: true
    name: "${device_name_lower}_przycisk_01"
    
    on_press:
      then:
        - lambda: |
            if (id(my_cover).current_operation == COVER_OPERATION_IDLE) {
              id(my_cover).make_call().set_command_open().perform();
            } else {
              id(my_cover).make_call().set_command_stop().perform();
            }   

  - platform: gpio
    pin:
      number: D2
      inverted: true
      mode:
        input: true
        pullup: true
    name: "${device_name_lower}_przycisk_02"

    on_press:
      then:
        - lambda: |
            if (id(my_cover).current_operation == COVER_OPERATION_IDLE) {
              id(my_cover).make_call().set_command_close().perform();
            } else {
              id(my_cover).make_call().set_command_stop().perform();
            }

# przekaznik D6 i D7
switch:

  - platform: gpio
    pin: D6
    name: "${device_name_lower}_przekaznik_01"
    id: sw01
    icon: "mdi:electric-switch"
    inverted: true
    interlock: [sw02]
    interlock_wait_time: 200ms

    
  - platform: gpio
    pin: D7
    name: "${device_name_lower}_przekaznik_02"
    id: sw02
    icon: "mdi:electric-switch"
    inverted: true
    interlock: [sw01]
    interlock_wait_time: 200ms

#wirtualny przycisk
button:

  - platform: template
    id: button_01
    name: "${device_name_lower}_przycisk_wirtual_01"
    icon: "mdi:gesture-tap-button"
    
    on_press:
      then:
        - lambda: |
            if (id(my_cover).current_operation == COVER_OPERATION_IDLE) {
              id(my_cover).make_call().set_command_open().perform();
            } else {
              id(my_cover).make_call().set_command_stop().perform();
            }    

  - platform: template
    id: button_02
    name: "${device_name_lower}_przycisk_wirtual_02"
    icon: "mdi:gesture-tap-button"
    
    on_press:
      then:
        - lambda: |
            if (id(my_cover).current_operation == COVER_OPERATION_IDLE) {
              id(my_cover).make_call().set_command_close().perform();
            } else {
              id(my_cover).make_call().set_command_stop().perform();
            }
            

roleta

Do sterowania wizualnego rolety z HACS (interfejs użytkownika) zainstalować Shutter Card.

type: custom:shutter-card
title: Roleta
entities:
  - entity: cover.test_roleta
    name: okno salon
    buttons_position: left
    title_position: bottom

shutter-card

1 polubienie