Hi,
i want to set the binary sensor for an feedback Cover.
for now i use this code, but with delay the state alwayr changes regardles if the rotary encoder is still moving.
Someone knows a better way to archiv this ?
Thank you very much
sensor:
- platform: rotary_encoder
name: "Rotary Encoder"
pin_a: D2
pin_b: D4
on_clockwise:
- logger.log: "Turned Clockwise"
- lambda: |-
id(open_movement_binary_sensor).publish_state(true);
id(close_movement_binary_sensor).publish_state(false);
- delay: 200ms
- lambda: |-
id(open_movement_binary_sensor).publish_state(false);
id(close_movement_binary_sensor).publish_state(false);
on_anticlockwise:
- logger.log: "Turned Anticlockwise"
- lambda: |-
id(open_movement_binary_sensor).publish_state(false);
id(close_movement_binary_sensor).publish_state(true);
- delay: 200ms
- lambda: |-
id(open_movement_binary_sensor).publish_state(false);
id(close_movement_binary_sensor).publish_state(false);