Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. recorder:
  2.  
  3. timer:
  4. window_up_1:
  5. name: "Timer"
  6. duration: '00:00:20'
  7. window_down_1:
  8. name: "Timer"
  9. duration: '00:00:20'
  10.  
  11. input_number:
  12. window_position_1:
  13. name: "Window 1 Position"
  14. min: 0
  15. max: 20
  16. window_set_position_1:
  17. name: "Apertura Serranda"
  18. min: 0
  19. max: 100
  20. (di questo uso solo entità: input_number.window_set_position_1)
  21. cover:
  22. - platform: template
  23. covers:
  24. window_cover_1:
  25. friendly_name: "Window 1 Cover"
  26. position_template: "{{ (((states.input_number.window_position_1.state | int) * 100)/20 | int) }}"
  27. open_cover:
  28. - service: mqtt.publish
  29. data:
  30. topic: 'cmnd/sonoff_1/power2'
  31. payload: 'OFF'
  32. - service: mqtt.publish
  33. data:
  34. topic: 'cmnd/sonoff_1/power1'
  35. payload: 'ON'
  36. close_cover:
  37. - service: mqtt.publish
  38. data:
  39. topic: 'cmnd/sonoff_1/power1'
  40. payload: 'OFF'
  41. - service: mqtt.publish
  42. data:
  43. topic: 'cmnd/sonoff_1/power2'
  44. payload: 'ON'
  45. stop_cover:
  46. - service: mqtt.publish
  47. data:
  48. topic: 'cmnd/sonoff_1/power1'
  49. payload: 'OFF'
  50. - service: mqtt.publish
  51. data:
  52. topic: 'cmnd/sonoff_1/power2'
  53. payload: 'OFF'
  54.  
  55.  
  56. - platform: mqtt
  57. state_topic: "tele/sonoff_1/STATE"
  58. command_topic: "cmnd/sonoff_1/Backlog"
  59. name: "Serranda 1"
  60. qos: 0
  61. retain: true
  62. payload_open: "power2 OFF;power1 ON"
  63. payload_close: "power1 OFF;power2 ON"
  64. payload_stop: "power1 OFF;power2 OFF"
  65. state_open: "ON"
  66. state_closed: "OFF"
  67. optimistic: false
  68.  
  69.  
  70. automations.yaml
  71.  
  72. #########################Serranda 1 set Position##############################
  73. - id: '301_1'
  74. alias: Window 1 - MQTT Button1 OFF (up)
  75. trigger:
  76. - payload: 'OFF'
  77. platform: mqtt
  78. topic: stat/sonoff_1/POWER1
  79. action:
  80. - service: timer.cancel
  81. entity_id: timer.window_up_1
  82.  
  83. - id: '302_1'
  84. alias: Window 1 - MQTT Button2 OFF (down)
  85. trigger:
  86. - payload: 'OFF'
  87. platform: mqtt
  88. topic: stat/sonoff_1/POWER2
  89. action:
  90. - service: timer.cancel
  91. entity_id: timer.window_down_1
  92.  
  93. - id: '303_1'
  94. alias: Window 1 - Timer stopped
  95. trigger:
  96. - platform: event
  97. event_type: timer.finished
  98. event_data:
  99. entity_id: timer.window_up_1
  100. - platform: event
  101. event_type: timer.finished
  102. event_data:
  103. entity_id: timer.window_down_1
  104. action:
  105. - service: cover.stop_cover
  106. data:
  107. entity_id: cover.window_cover_1
  108.  
  109. - id: '311_1'
  110. alias: Window 1 - MQTT Button1 ON (up)
  111. trigger:
  112. - payload: 'ON'
  113. platform: mqtt
  114. topic: stat/sonoff_1/POWER1
  115. condition:
  116. condition: template
  117. value_template: '{{ as_timestamp(now()) - as_timestamp(states.input_number.window_set_position_1.last_updated) > 3 }}'
  118. action:
  119. - service: timer.start
  120. data:
  121. duration: 00:00:20
  122. entity_id: timer.window_up_1
  123.  
  124. - id: '312_1'
  125. alias: Window 1 - MQTT Button2 ON (down)
  126. trigger:
  127. - payload: 'ON'
  128. platform: mqtt
  129. topic: stat/sonoff_1/POWER2
  130. condition:
  131. condition: template
  132. value_template: '{{ as_timestamp(now()) - as_timestamp(states.input_number.window_set_position_1.last_updated) > 3 }}'
  133. action:
  134. - service: timer.start
  135. data:
  136. duration: 00:00:20
  137. entity_id: timer.window_down_1
  138.  
  139. - id: '512_1'
  140. alias: Window 1 - Set Position UP
  141. trigger:
  142. platform: state
  143. entity_id: input_number.window_set_position_1
  144. condition:
  145. condition: template
  146. value_template: "{{ (states.input_number.window_position_1.state | int) < ((((states.input_number.window_set_position_1.state | int ) * 20 )/100) | int) }}"
  147. action:
  148. - service: timer.start
  149. data_template:
  150. entity_id: timer.window_up_1
  151. duration: "{{ '00:00:%02d' | format( ((states.input_number.window_position_1.state | int) - ((((states.input_number.window_set_position_1.state | int ) * 20 )/100) | int) ) | abs ) }}"
  152. - service: cover.open_cover
  153. data:
  154. entity_id: cover.window_cover_1
  155. #############################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement