YAML   172

DIY Curtain Code

Guest on 3rd May 2022 08:06:23 PM

  1. stepper:
  2.   - platform: a4988
  3.     id: my_stepper
  4.     step_pin: 5
  5.     dir_pin: 2
  6.     max_speed: 500
  7.    
  8.     # Optional:
  9.     sleep_pin: 4
  10.     acceleration: inf
  11.     deceleration: inf
  12.    
  13. cover:
  14.   - platform: template
  15.     name: "bedroomcurtain"
  16.     id: bedroomcurtain
  17.     device_class: curtain
  18.     open_action:
  19.       - stepper.set_target:
  20.           id: my_stepper
  21.           target: 6000
  22.  
  23.     close_action:
  24.       - stepper.set_target:
  25.           id: my_stepper
  26.           target: 0
  27.          
  28.     stop_action:
  29.       - stepper.set_target:
  30.           id: my_stepper
  31.           target: !lambda return id(my_stepper).current_position;
  32.       - sensor.template.publish:
  33.             id: position
  34.             state: !lambda return id(my_stepper).current_position;
  35.     optimistic: true
  36.     assumed_state: true
  37. sensor:
  38.     platform: template
  39.     name: "Bedroom Curtain Position"
  40.     id: position

Raw Paste


Login or Register to edit or fork this paste. It's free.