LoraTap SC500W-V1 shutter switch with ESPHome

Hi,

the last few days I spent on dealing with this cheap, but good shutter switch. Because I did not wanted to register and deal with Tuya, I desided to change it to ESPHome.
Now I would like to share my knowledge and .yaml.

first of all the unit:
-get shure to buy the version V1 with the Tuya ESP8285
-it works with a Remote Control on 868MHz, WiFi and you can connect normal wall-buttons
-its small enought to fit in a standard 68mm wallbox

After simple opening the case, it is needed to solder the contacts or cables for the flash process.
Here is a very good tutorial allready and was as well my base to do the hole change. thanks to @zry98

my testunit with flash and reset buttons:
PXL_20230919_163328564 (Handy) PXL_20230919_163148139 (Handy)

YAML:
-Because I do not need this working in three different ways, I desided to deactivate WiFi and have it only as a backup for ota changings of the .yaml. As well I dont want in every corner of my house a wifi client.

-There is a delay of 1sec.between quick up and down changes to protect the motor. A interlock is not needed, because there is always a stop command before changing up or down direction.

-Wall-push-buttons: press once the push-button and the curtain opens/closes completely, to stop press during the open/close action more then 1sec. and keep it pressed until you reach the position you like, after release the button, the curtain will stop.

-There are some other settings you can include, exclude or change like you need.

19.09.23-18.24.19

esphome:
  name: "curtain-test"
  friendly_name: "curtain-test"

###turn wifi off, also set (api: --> reboot_timeout: 0s) to prevent bootloop
  on_boot:
     then:
       - delay: 300s
       - wifi.disable:

  #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: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

ota:
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  

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.00
    gateway: 192.168.1.0
    subnet: 255.255.255.0
    dns1: 192.168.1.0

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

captive_portal:
  

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

substitutions:
  device_name: 'shutter 1'
  
  
  # 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


 
  # external switches
binary_sensor: 
  - platform: gpio
    id: switch_open
    pin:
      number: 4
      inverted: true
    on_click:
    - min_length: 50ms        # Short press
      max_length: 500ms
      then:
        - cover.open: shutter
    - min_length: 1000ms      # Medium press / long
      max_length: 5000ms
      then:
        - cover.stop: shutter      
     
  - platform: gpio
    id: switch_close
    pin:
      number: 5
      inverted: true     
    on_click:
    - min_length: 50ms        # Short press
      max_length: 500ms
      then:
        - cover.close: shutter
    - min_length: 1000ms      # Medium press / long
      max_length: 5000ms
      then:
        - cover.stop: shutter     

  - platform: gpio
    id: stop_button
    pin:
      number: 13
      inverted: true
    on_click: 
      then:
        - cover.stop: shutter



  # relays
output:
  - platform: gpio
    id: relay_open
    pin: 12
  - platform: gpio
    id: relay_close
    pin: 14



  # cover with 1000ms delay inbetween change of directions
cover:
  - platform: time_based
    id: shutter
    name: '${device_name}'
    device_class: shutter
    open_action:   
      - output.turn_off: relay_close
      - delay: 1000ms    # additional delay   
      - output.turn_on: relay_open
    open_duration: 40s   # adjust it to the actual duration to fully open
    close_action:   
      - output.turn_off: relay_open
      - delay: 1000ms    # additional delay 
      - output.turn_on: relay_close
    close_duration: 40s  # adjust it to the actual duration to fully close
    stop_action:
      - output.turn_off: relay_open
      - output.turn_off: relay_close      
    assumed_state: true



   #optional
#sensor:
#  - platform: wifi_signal
#    name: "WiFi Signal Strength"
#    update_interval: 60s

#  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
#    name: "WiFi Signal dB"
#    id: wifi_signal_db
#    update_interval: 60s
#    entity_category: "diagnostic"

#  - platform: copy # Reports the WiFi signal strength in %
#    source_id: wifi_signal_db
#    name: "WiFi Signal Percent"
#    filters:
#      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
#    unit_of_measurement: "Signal %"
#    entity_category: "diagnostic"
    
#  - platform: uptime
#    name: Uptime Sensor
#    update_interval: 60s
    
    
###on_click:  standard timings
#    - 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

enjoy

2 Likes

wifi.disable did not work properly and got repaired in ESPHome 2023.9.0 (stable)

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