LoraTap SC500W-V1 shutter switch with ESPHome

Meanwhile I did receive the shutters for my house and have installed them.

Finally in reality it looks all different with the code for the LoraTap shutter switch and I did find out, that the cover-component is useless in my case.

There is the problem with the timing.
If you open/stop/close/stop/open/stop/open… it looses the real position an the shutters stops anywhere but not where you want them.
I understood now that the cover-component is a compromise because there is only a virtual position recognitioning. It works great only if you always fully open or close the shutters.

Now I decided to make the code based on a simple double relay.
Like this you loose the comfortable shutter switch control in HA, but all the rest works like I wanted.
My prefered control units are anyway the RF remote and the wall buttons what works like a charme now.
And the relay switches in HA I do use to connect the shutter-motors into theirs programming mode.

To intergrate the shutters better in HA with the double relay, its needed to create a automatism for it. But this is no problem at all.

So finally I`m glad with this code and maybe somebody else gets happy with it as well:

esphome:
  name: "rolladen-test"
  friendly_name: "rolladen-test"

  #turn wifi off, set (api: --> reboot_timeout: 0s) to prevent bootloop
#  on_boot:
#     then:
#       - delay: 300s
#       - wifi.disable:
   
#external_components:
#  - source: github://ssieb/esphome@wifioff
#    components: [ wifi ]
#    refresh: 1min
 

  #esp8266 1MB flash
esp8266:
  board: esp8285
  restore_from_flash: false

# Enable logging
logger:

# Enable Home Assistant API
api:
  #turn wifi off, set (api: --> reboot_timeout: 0s) to prevent bootloop
  reboot_timeout: 0s
  
  encryption:
    key: "xxxxxxxx"

ota:
   password: "xxxxxxxx"
  

wifi:
  #wifi powersafe mode: NONE,LIGHT,HIGH
  power_save_mode: HIGH
#  fast_connect: true  
  
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  
  manual_ip:
    static_ip: 192.168.1.x
    gateway: 192.168.1.x
    subnet: 255.255.255.0
    dns1: 192.168.1.x

  # Enable fallback hotspot (captive portal) in case wifi connection fails, http:192.168.4.1
#  ap:
#    ssid: "Esphome-Web-xxxxxx"
#    password: "xxxxxx"

#captive_portal:
  

      # reduce write frequency to flash to avoid wearing it out, adjust it as needed
preferences:
  flash_write_interval: 24h
 

substitutions:
  device_name: 'Rolladen test'
  
  
  # for hard restart 
button:
   - platform: restart
     id: restart_button
     name: 'Restart ${device_name}'
     entity_category: diagnostic

status_led:  # onboard LED
     pin:
         number: 3
         inverted: true


  # relays
switch:
   - platform: gpio
     id: open_relay
     name: open ${device_name}
     pin: 12
#     interlock: [close_relay]
   - platform: gpio
     id: close_relay
     name: close ${device_name}
     pin: 14
#     interlock: [open_relay]


script:
   - id: open_script
     mode: restart
     then:
         - switch.turn_off: close_relay 
         - delay: 500ms          
         - switch.turn_on: open_relay
         - delay: 30s        
         - switch.turn_off: open_relay
        
   - id: open_halt_script
     then:   
         - switch.turn_off: open_relay
        
   - id: close_script
     mode: restart
     then:   
         - switch.turn_off: open_relay
         - delay: 500ms          
         - switch.turn_on: close_relay
         - delay: 30s
         - switch.turn_off: close_relay 
        
   - id: close_halt_script
     then:  
         - switch.turn_off: close_relay  
      

  # external switches
binary_sensor: 
   - platform: gpio
     id: open_button
     pin:
         number: 4
         inverted: true
     on_click:
       - min_length: 50ms        # Short press
         max_length: 500ms
         then:
             - script.execute: open_script
       - min_length: 1000ms      # Medium press / long
         max_length: 30000ms
         then:
             - script.execute: open_halt_script
             - script.stop: open_script
             - script.stop: close_script       
        
   - platform: gpio
     id: close_button
     pin:
         number: 5
         inverted: true     
     on_click:
       - min_length: 50ms        # Short press
         max_length: 500ms
         then:
             - script.execute: close_script       
       - min_length: 1000ms      # Medium press / long
         max_length: 30000ms
         then:
             - script.execute: close_halt_script
             - script.stop: open_script
             - script.stop: close_script      
      
   - platform: gpio
     id: stop_button
     pin:
         number: 13
         inverted: true
     on_click: 
         then:
             - script.execute: open_halt_script
             - script.execute: close_halt_script      
             - script.stop: open_script
             - script.stop: close_script       
        
    
    
 #on_click:
#    - min_length: 50ms        # Short press
#      max_length: 500ms
#      then:
#        # Some action
#    - min_length: 500ms      # Medium press
#      max_length: 3000ms
#      then:
#        # Some other action
#    - min_length: 3000ms        # Long press
#      max_length: 10000ms
#      then:
#        # Some other action
1 Like