Guest User

Untitled

a guest
Mar 22nd, 2025
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. alias: Screens Control V2
  2. description: ""
  3. mode: single
  4.  
  5. triggers:
  6. - trigger: state
  7. entity_id:
  8. - binary_sensor.miguel_presence_occupancy
  9. to: "on"
  10. id: sit-down
  11. - trigger: state
  12. entity_id:
  13. - binary_sensor.miguel_presence_occupancy
  14. to: "off"
  15. id: stand-up
  16. conditions: []
  17. actions:
  18. - choose:
  19. - conditions:
  20. - condition: trigger
  21. id:
  22. - sit-down
  23. sequence:
  24. - action: input_boolean.turn_on
  25. metadata: {}
  26. data: {}
  27. target:
  28. entity_id: input_boolean.desk_presence_miguel
  29. - conditions:
  30. - condition: trigger
  31. id:
  32. - stand-up
  33. - condition: state
  34. entity_id: input_boolean.desk_presence_miguel
  35. state: "on"
  36. sequence:
  37. - variables:
  38. state_last_changed: >-
  39. {{ ((now() -
  40. states.input_boolean.desk_presence_miguel.last_changed).seconds)|int }}
  41. - choose:
  42. - conditions:
  43. - alias: state last changed time less than 1min
  44. condition: template
  45. value_template: "{{ state_last_changed < 60 }}"
  46. sequence:
  47. - action: input_boolean.turn_off
  48. metadata: {}
  49. data: {}
  50. target:
  51. entity_id: input_boolean.desk_presence_miguel
  52. alias: if state been on for less than 1 min switch off
  53. - conditions:
  54. - alias: bulb last changed time 1min+
  55. condition: template
  56. value_template: "{{ state_last_changed > 59 }}"
  57. sequence:
  58. - wait_for_trigger:
  59. - trigger: state
  60. entity_id:
  61. - >-
  62. binary_sensor.miguel_presence_occupancy
  63. to: "on"
  64. timeout:
  65. hours: 0
  66. minutes: 5
  67. seconds: 0
  68. milliseconds: 0
  69. alias: wait for 5 mins to see if comes back
  70. - alias: if clear after wait then turn off
  71. if:
  72. - condition: state
  73. entity_id: binary_sensor.miguel_presence_occupancy
  74. state: "off"
  75. then:
  76. - action: input_boolean.turn_off
  77. metadata: {}
  78. data: {}
  79. target:
  80. entity_id: input_boolean.desk_presence_miguel
  81. alias: if light has been on for 1 min+ keep on for 5 mins
  82.  
Advertisement
Add Comment
Please, Sign In to add comment