165 lines
3.5 KiB
YAML
165 lines
3.5 KiB
YAML
substitutions:
|
|
device_name: "blinds-speelkamer"
|
|
friendly_name: "blinds speelkamer"
|
|
comment: "esp32c3, motor, encoder"
|
|
location: "speelkamer"
|
|
api_password: !secret blinds_api
|
|
ota_password: !secret ota_password
|
|
wifi_ssid: !secret wifi_ssid
|
|
wifi_password: !secret wifi_password
|
|
gateway: !secret ip_gateway
|
|
subnet: !secret ip_subnet
|
|
ip: !secret blinds_ip
|
|
update_interval: 30s
|
|
pin_mot1: GPIO3
|
|
pin_mot2: GPIO2
|
|
pin_enc1: GPIO7
|
|
pin_enc2: GPIO8
|
|
pin_sw1: GPIO9
|
|
pin_sw2: GPIO10
|
|
|
|
packages:
|
|
board: !include boards/esp32-C3.yaml
|
|
device_base: !include common/common.yaml
|
|
connection: !include common/wifi.yaml
|
|
logger: !include templates/logger.yaml
|
|
|
|
binary_sensor:
|
|
- platform: gpio
|
|
id: endstop1
|
|
name: endstop1
|
|
pin:
|
|
number: ${pin_sw1}
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
inverted: true
|
|
on_press:
|
|
then:
|
|
- sensor.rotary_encoder.set_value:
|
|
id: encoder1
|
|
value: 0
|
|
- platform: gpio
|
|
id: endstop2
|
|
name: endstop2
|
|
pin:
|
|
number: ${pin_sw2}
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
inverted: true
|
|
|
|
|
|
|
|
globals:
|
|
- id: min_tilt
|
|
type: int
|
|
restore_value: true
|
|
initial_value: "0"
|
|
- id: max_tilt
|
|
type: int
|
|
restore_value: true
|
|
initial_value: "2328"
|
|
|
|
script:
|
|
- id: tilt_left
|
|
then:
|
|
- switch.turn_off: positive
|
|
- switch.turn_on: negative
|
|
- id: tilt_right
|
|
then:
|
|
- switch.turn_off: negative
|
|
- switch.turn_on: positive
|
|
- id: tilt_stop
|
|
then:
|
|
- switch.turn_off: negative
|
|
- switch.turn_off: positive
|
|
|
|
|
|
sensor:
|
|
- platform: rotary_encoder
|
|
name: "Rotary Encoder"
|
|
id: 'encoder1'
|
|
pin_a: ${pin_enc1}
|
|
pin_b: ${pin_enc2}
|
|
publish_initial_value: True
|
|
#restore_mode: RESTORE_DEFAULT_ZERO
|
|
# on_value:
|
|
# then:
|
|
# - lambda: |-
|
|
# id(blind).position = x / (id(max_tilt)-id(min_tilt));
|
|
# id(blind).publish_state();
|
|
|
|
|
|
# Exposed switches.
|
|
switch:
|
|
- platform: template
|
|
id: resetc
|
|
name: Reset count
|
|
turn_on_action:
|
|
then:
|
|
- sensor.rotary_encoder.set_value:
|
|
id: encoder1
|
|
value: 0
|
|
- switch.turn_off: resetc
|
|
- platform: restart
|
|
name: restart
|
|
- platform: output
|
|
name: "shade1"
|
|
output: 'shade1'
|
|
internal: true
|
|
id: negative
|
|
- platform: output
|
|
name: "shade2"
|
|
output: 'shade2'
|
|
internal: true
|
|
id: positive
|
|
|
|
output:
|
|
- platform: gpio
|
|
id: 'shade1'
|
|
pin: ${pin_mot1}
|
|
- platform: gpio
|
|
id: 'shade2'
|
|
pin: ${pin_mot2}
|
|
|
|
cover:
|
|
- platform: endstop
|
|
device_class: blind
|
|
name: "speelkamer blind"
|
|
#optimistic: TRUE
|
|
id: blind
|
|
#has_position: true
|
|
# lambda: |-
|
|
# if(id(endstop1).state & id(blind).current_operation == CoverOperation::COVER_OPERATION_CLOSING)
|
|
# {
|
|
# id(tilt_stop).execute();
|
|
# return COVER_CLOSED;
|
|
# }
|
|
# else if(id(endstop2).state & id(blind).current_operation == CoverOperation::COVER_OPERATION_OPENING)
|
|
# {
|
|
# id(tilt_stop).execute();
|
|
# return COVER_OPEN;
|
|
# }
|
|
# return {};
|
|
|
|
open_endstop: endstop2
|
|
open_duration: 5s
|
|
close_endstop: endstop1
|
|
close_duration: 5s
|
|
stop_action:
|
|
then:
|
|
- script.execute: tilt_stop
|
|
|
|
open_action:
|
|
then:
|
|
- script.execute: tilt_right
|
|
|
|
close_action:
|
|
then:
|
|
- script.execute: tilt_left
|
|
|
|
# on_open:
|
|
# - logger.log: "Cover is Open!"
|
|
# on_closed:
|
|
# - logger.log: "Cover is Closed!" |