I had a hard time finding a solution for my problem I had so I decided to share it, for who ever may ever need it.
I have shutters/covers/rolladen (german) / rolluiken (dutch)/… When I press the up button, they go up and when I press it again they stop moving. Same for going down.
My biggest problem is that all my wall switches (light and shutters) only send a 24v signal to my electric system that then triggers a teleruptor/relay that then activates the 230v switch.
With an ESP32 and a relay board I can simulate this signal and I can control my lights and shutters.
Thanks to ESPhome I could make time based covers after some thinking and reading.
How I setup my GPIO switch control:
switch:
- platform: gpio
name: "Keuken achter omhoog"
id: keukenomhoog
pin:
number: 32
inverted: yes
- platform: gpio
name: "Keuken achter omloog"
id: keukenomlaag
pin:
number: 33
inverted: yes
- platform: gpio
name: "Living achter omhoog"
id: livingomhoog
pin:
number: 25
inverted: yes
Then I added 2 template binary sensors that I use to control the covers.
binary_sensor:
- platform: template
name: "Keuken open"
id: keukenopen
- platform: template
name: "Keuken gesloten"
id: keukengesloten
With the binary sensors I can choose which stop action has to be called. Because if they are going down and the stop action is both up and down (omhoog en omlaag) the shutter will always go up again. That’s why when I do the open action it triggers one sensor to on and the other to off…
cover:
- platform: time_based
name: "Keuken cover"
id: keukencover
has_built_in_endstop: true
open_action:
- switch.turn_on: keukenomhoog
- binary_sensor.template.publish:
id: keukenopen
state: ON
- binary_sensor.template.publish:
id: keukengesloten
state: OFF
open_duration: 35s
close_action:
- switch.turn_on: keukenomlaag
- binary_sensor.template.publish:
id: keukengesloten
state: ON
- binary_sensor.template.publish:
id: keukenopen
state: OFF
close_duration: 33s
stop_action:
- if:
condition:
- binary_sensor.is_on: keukenopen
then:
- switch.turn_on: keukenomhoog
- if:
condition:
- binary_sensor.is_on: keukengesloten
then:
- switch.turn_on: keukenomlaag
Maybe there is a proper/better way to solve this, maybe there ain’t.
It’s just to help out some one else if ever needed
3 Likes
Just to have more examples out there, I’d like to share what my settings look like:
switch:
- platform: gpio
id: blind_down
pin:
number: GPIO12
inverted: True
on_turn_on:
- delay: 500ms
- switch.turn_off: blind_down
interlock: [blind_up, blind_stop]
internal: True
- platform: gpio
id: blind_up
pin:
number: GPIO14
inverted: True
on_turn_on:
- delay: 500ms
- switch.turn_off: blind_up
interlock: [blind_down, blind_stop]
internal: True
- platform: gpio
id: blind_stop
pin:
number: GPIO13
inverted: True
on_turn_on:
- delay: 500ms
- switch.turn_off: blind_stop
interlock: [blind_down, blind_up]
internal: True
cover:
- platform: time_based
name: None
device_class: shutter
open_duration:
seconds: 48
close_duration:
seconds: 48
open_action:
then:
- switch.turn_on: blind_up
stop_action:
then:
- switch.turn_on: blind_stop
close_action:
then:
- switch.turn_on: blind_down
1 Like
Does somebody have a YAML for the bk7231n based MOES WS-Y-EUTC-WH-MS ?
This is also a cover controller, but it has 3 touch buttons on the front ( up, stop , down)
I already flashed it with cloudcutter/libretiny but the availabe YAML is configured as if it’s a lightswitch with 2 relays.
how to incorporate this module using the cover platform, and also interlocks so you don’t fry the motor ?
I did something that you can use:
esphome:
name: shutter_${device_name}
bk72xx:
board: generic-bk7231n-qfn32-tuya
logger:
web_server:
captive_portal:
mdns:
api:
password: ""
ota:
password: ""
wifi:
use_address: ${ip}
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
button:
- platform: restart
name: Restart
debug:
update_interval: 30s
text_sensor:
- platform: debug
reset_reason:
name: Reset Reason
- platform: libretiny
version:
name: LibreTiny Version
sensor:
- platform: uptime
name: Uptime
# Note: you may try to comment that line if the Wi-Fi connection is not stable...
#power_save_mode: high
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 1min
# status_led:
# id: led_status
# pin: GPIO2
switch:
- platform: gpio
id: switch_led_light
name: shutter_${device_name}_led_light
pin: GPIO11
- platform: gpio
id: led_up_red
pin: GPIO14
restore_mode: ALWAYS_OFF
- platform: gpio
id: led_stop_red
pin: GPIO08
restore_mode: ALWAYS_OFF
- platform: gpio
id: led_down_red
pin: GPIO23
restore_mode: ALWAYS_OFF
- platform: gpio
id: up_relay
pin: GPIO06
interlock: [down_relay]
restore_mode: ALWAYS_OFF
- platform: gpio
id: down_relay
pin: GPIO09
interlock: [up_relay]
restore_mode: ALWAYS_OFF
binary_sensor:
- platform: gpio
id: up_button
pin:
number: GPIO24
inverted: true
on_press:
then:
- if:
condition:
lambda: 'return id(shutter_${device_name}).position != COVER_OPEN;'
then:
- cover.open: shutter_${device_name}
- switch.turn_on: led_up_red
- platform: gpio
id: stop_button
pin:
number: GPIO10
inverted: true
on_press:
- cover.stop: shutter_${device_name}
- switch.turn_on: led_stop_red
on_release:
- switch.turn_off: led_stop_red
- platform: gpio
id: down_button
pin:
number: GPIO07
inverted: true
on_press:
then:
- if:
condition:
lambda: 'return id(shutter_${device_name}).position != COVER_CLOSED;'
then:
- cover.close: shutter_${device_name}
- switch.turn_on: led_down_red
number:
- platform: template
name: ${upper_device_name} open duration time
id: open_duration_time
optimistic: True
initial_value: ${open_duration_time_number_init_value}
min_value: 0
max_value: 100
step: 1
set_action:
lambda: !lambda |-
auto value = x;
id(open_duration_time).publish_state(value);
on_value:
then:
lambda: !lambda |-
auto duration_in_seconds = static_cast<uint32_t>(id(open_duration_time).state) * 1000;
id(shutter_${device_name}).set_open_duration(duration_in_seconds);
disabled_by_default: False
mode: AUTO
update_interval: 60s
- platform: template
name: ${upper_device_name} close duration time
id: close_duration_time
optimistic: True
initial_value: ${close_duration_time_number_init_value}
min_value: 0
max_value: 100
step: 1
on_value:
then:
lambda: !lambda |-
auto duration_in_seconds = static_cast<uint32_t>(id(open_duration_time).state) * 1000;
id(shutter_${device_name}).set_close_duration(duration_in_seconds);
disabled_by_default: False
mode: AUTO
update_interval: 60s
cover:
- platform: time_based
name: "${upper_device_name}"
id: shutter_${device_name}
device_class: shutter
open_action:
- switch.turn_on: up_relay
open_duration: ${open_duration_time}
close_action:
- switch.turn_on: down_relay
close_duration: ${close_duration_time}
stop_action:
- switch.turn_off: up_relay
- switch.turn_off: led_up_red
- switch.turn_off: down_relay
- switch.turn_off: led_down_red
and you need to use it with this:
substitutions:
ip: YOUR_DESIRED_IP_ADDRESS
device_name: master_bedroom
upper_device_name: Master Bedroom
open_duration_time: 18s
close_duration_time: 18s
open_duration_time_number_init_value: "18"
close_duration_time_number_init_value: "18"
<<: !include shutter_moes_common.yaml
I am still having problems to control the open and close duration from home assistant.