Guest User

Untitled

a guest
Jul 25th, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.46 KB | None | 0 0
  1. uid: commonBlocks
  2. tags:
  3. - marketplace:131157
  4. props:
  5. parameters: []
  6. parameterGroups: []
  7. timestamp: Jul 25, 2023, 10:14:33 AM
  8. component: BlockLibrary
  9. config:
  10. name: Common Blocks
  11. slots:
  12. blocks:
  13. - component: BlockType
  14. config:
  15. args0:
  16. - name: sourceItem
  17. type: input_value
  18. - name: targetItem
  19. type: input_value
  20. colour: 0
  21. helpUrl: ""
  22. inputsInline: false
  23. message0: Copy state from %1 to %2
  24. nextStatement: ""
  25. previousStatement: ""
  26. tooltip: Will copy current state of first item and send as command to second item
  27. type: copyItemState
  28. slots:
  29. code:
  30. - component: BlockCodeTemplate
  31. config:
  32. template: events.sendCommand({{input:targetItem}}, items.getItem({{input:sourceItem}}).state);
  33. toolbox:
  34. - component: PresetInput
  35. config:
  36. name: sourceItem
  37. shadow: true
  38. type: oh_item
  39. - component: PresetInput
  40. config:
  41. name: targetItem
  42. shadow: true
  43. type: oh_item
  44. - component: BlockType
  45. config:
  46. args0:
  47. - name: notification
  48. type: input_value
  49. - name: icon
  50. type: input_value
  51. - name: severity
  52. options:
  53. - - info
  54. - info
  55. - - warning
  56. - warn
  57. - - highly important
  58. - high
  59. type: field_dropdown
  60. - default: mail@demo
  61. name: email
  62. type: input_value
  63. colour: 0
  64. helpUrl: ""
  65. inputsInline: false
  66. message0: send notification %1 with icon %2 as %3 to %4
  67. nextStatement: ""
  68. previousStatement: ""
  69. tooltip: Sends a notification via Cloud Connector to one individual recipient including icon and severity
  70. type: notificationSingleWithIconAndSeverity
  71. slots:
  72. code:
  73. - component: BlockCodeTemplate
  74. config:
  75. template: "{{utility:notifications}}.sendNotification({{input:email}}, {{input:notification}}, {{input:icon}}, '{{field:severity}}');"
  76. toolbox:
  77. - component: PresetInput
  78. config:
  79. fields:
  80. TEXT: message
  81. name: notification
  82. shadow: true
  83. type: text
  84. - component: PresetInput
  85. config:
  86. fields:
  87. TEXT: window
  88. name: icon
  89. shadow: true
  90. type: text
  91. - component: PresetInput
  92. config:
  93. fields:
  94. TEXT: test@example.org
  95. name: email
  96. shadow: true
  97. type: text
  98. - component: BlockType
  99. config:
  100. args0:
  101. - check: Number
  102. name: duration
  103. type: input_value
  104. - name: duration_unit
  105. options:
  106. - - seconds
  107. - plusSeconds
  108. - - minutes
  109. - plusMinutes
  110. - - hours
  111. - plusHours
  112. - - days
  113. - plusDays
  114. - - weeks
  115. - plusWeeks
  116. - - months
  117. - plusMonths
  118. type: field_dropdown
  119. - check: String
  120. name: timer_name
  121. type: input_value
  122. - default: mail@demo
  123. name: timer_statement
  124. type: input_statement
  125. colour: 0
  126. helpUrl: https://openhab-scripters.github.io/openhab-helper-libraries/Guides/Event%20Object%20Attributes.html
  127. inputsInline: true
  128. message0: after %1 %2 do with %3 %4 and keep triggering event-context
  129. nextStatement: ""
  130. previousStatement: ""
  131. tooltip: Schedules a new timer and will pass the event variable as argument to the timer, that you can reuse the initial event during timer execution (e.g. event.itemName)
  132. type: timerWithInitialEvent
  133. slots:
  134. code:
  135. - component: BlockCodeTemplate
  136. config:
  137. template: >
  138. if (typeof this.timers === 'undefined') {
  139. this.timers = [];
  140. }
  141.  
  142. if (typeof this.timers[{{input:timer_name}}] === 'undefined' || this.timers[{{input:timer_name}}].hasTerminated()) {
  143. this.timers[{{input:timer_name}}] = {{utility:scriptExecution}}.createTimerWithArgument({{utility:zdt}}.now().{{field:duration_unit}}({{input:duration}}),event, function (event) {
  144.  
  145. {{statements:timer_statement}}
  146.  
  147. })
  148. }
  149. toolbox:
  150. - component: PresetInput
  151. config:
  152. fields:
  153. TEXT: MyTimer
  154. name: timer_name
  155. shadow: true
  156. type: text
  157. - component: PresetInput
  158. config:
  159. fields:
  160. NUM: 10
  161. name: duration
  162. shadow: true
  163. type: math_number
  164. - component: BlockType
  165. config:
  166. args0:
  167. - check: Number
  168. name: duration
  169. type: input_value
  170. - name: duration_unit
  171. options:
  172. - - seconds
  173. - plusSeconds
  174. - - minutes
  175. - plusMinutes
  176. - - hours
  177. - plusHours
  178. - - days
  179. - plusDays
  180. - - weeks
  181. - plusWeeks
  182. - - months
  183. - plusMonths
  184. type: field_dropdown
  185. - check: String
  186. name: timer_name
  187. type: input_value
  188. - name: timer_statement
  189. type: input_statement
  190. - name: reschedule_option
  191. options:
  192. - - reschedule
  193. - this.timers[{{input:timer_name}}].reschedule(zdt.now().{{field:duration_unit}}({{input:duration}}));
  194. - - cancel
  195. - >
  196. this.timers[{{input:timer_name}}].cancel();
  197.  
  198. this.timers[{{input:timer_name}}] = undefined;
  199. - - do nothing
  200. - //do nothing
  201. type: field_dropdown
  202. colour: 0
  203. helpUrl: https://openhab-scripters.github.io/openhab-helper-libraries/Guides/Event%20Object%20Attributes.html
  204. inputsInline: true
  205. message0: after %1 %2 do with %3 %4 %5 if retriggered and keep triggering event-context
  206. nextStatement: ""
  207. previousStatement: ""
  208. tooltip: Schedules a new timer with option to reschedule or cancle and will pass the event variable as argument to the timer, that you can reuse the initial event during timer execution (e.g. event.itemName)
  209. type: timerWithInitialEventAndOption
  210. slots:
  211. code:
  212. - component: BlockCodeTemplate
  213. config:
  214. template: >
  215. if (typeof this.timers === 'undefined') {
  216. this.timers = [];
  217. }
  218.  
  219. if (typeof this.timers[{{input:timer_name}}] === 'undefined' || this.timers[{{input:timer_name}}].hasTerminated()) {
  220. this.timers[{{input:timer_name}}] = {{utility:scriptExecution}}.createTimerWithArgument({{utility:zdt}}.now().{{field:duration_unit}}({{input:duration}}),event, function (event) {
  221.  
  222. {{statements:timer_statement}}
  223.  
  224. })
  225. } else {
  226. {{field:reschedule_option}}
  227. }
  228. toolbox:
  229. - component: PresetInput
  230. config:
  231. fields:
  232. TEXT: MyTimer
  233. name: timer_name
  234. shadow: true
  235. type: text
  236. - component: PresetInput
  237. config:
  238. fields:
  239. NUM: 10
  240. name: duration
  241. shadow: true
  242. type: math_number
  243. - component: BlockType
  244. config:
  245. args0:
  246. - name: toggleItem
  247. type: input_value
  248. colour: 0
  249. helpUrl: ""
  250. inputsInline: false
  251. message0: Toggle Item %1
  252. nextStatement: ""
  253. previousStatement: ""
  254. tooltip: Will switch an item ON or OFF, depending on current state
  255. type: toggleItem
  256. slots:
  257. code:
  258. - component: BlockCodeTemplate
  259. config:
  260. template: >
  261. if (items.getItem({{input:toggleItem}}).state == 'ON') {
  262. events.sendCommand({{input:toggleItem}}, 'OFF');
  263. } else {
  264. events.sendCommand({{input:toggleItem}}, 'ON');
  265. }
  266. toolbox:
  267. - component: PresetInput
  268. config:
  269. name: toggleItem
  270. shadow: true
  271. type: oh_item
  272. - component: BlockType
  273. config:
  274. args0:
  275. - name: dateTimeItem
  276. type: input_value
  277. - name: dateTimeFormat
  278. type: input_value
  279. colour: 0
  280. helpUrl: ""
  281. inputsInline: false
  282. message0: Formate datetime item %1 with %2
  283. output: String
  284. type: formatDateTime
  285. slots:
  286. code:
  287. - component: BlockCodeTemplate
  288. config:
  289. template: time.toZDT(items.getItem({{input:dateTimeItem}})).format(time.DateTimeFormatter.ofPattern({{input:dateTimeFormat}}))
  290. toolbox:
  291. - component: PresetInput
  292. config:
  293. name: dateTimeItem
  294. shadow: true
  295. type: oh_item
  296. - component: PresetInput
  297. config:
  298. fields:
  299. TEXT: HH:mm
  300. name: dateTimeFormat
  301. shadow: true
  302. type: text
  303. utilities:
  304. - component: UtilityJavaType
  305. config:
  306. javaClass: org.openhab.io.openhabcloud.NotificationAction
  307. name: notifications
  308. - component: UtilityJavaType
  309. config:
  310. javaClass: org.openhab.core.model.script.actions.ScriptExecution
  311. name: scriptExecution
  312. - component: UtilityJavaType
  313. config:
  314. javaClass: java.time.ZonedDateTime
  315. name: zdt
  316. - component: UtilityJavaType
  317. config:
  318. javaClass: java.time.format.DateTimeFormatter
  319. name: dtf
  320.  
Add Comment
Please, Sign In to add comment