Advertisement
leader21

pimatic changelog devices

Feb 2nd, 2016
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.94 KB | None | 0 0
  1. pimatic and homeduino changelog devices
  2.  
  3. here you will find all needed codework for to copy and past into your config.json to get the pimatic and homeduino
  4. changelog devices running. don't forget to install "sudo npm install -g github-changes" and change the credentials of the iframe devices below!
  5. cheers
  6. leader21
  7.  
  8.  
  9. =================================================
  10. PLUGINS FOR THE PLUGIN SECTION OF THE CONFIG.JSON
  11. =================================================
  12.  
  13. {
  14. "plugin": "filebrowser",
  15. "mappings": [
  16. {
  17. "path": "/files",
  18. "directory": "/"
  19. }
  20. ]
  21. },
  22. {
  23. "plugin": "iframe"
  24. },
  25. {
  26. "plugin": "shell-execute"
  27. }
  28.  
  29.  
  30. =================================================
  31. DEVICES FOR THE DEVICE SECTION OF THE CONFIG.JSON
  32. =================================================
  33.  
  34. {
  35. "id": "systembuttons",
  36. "name": "System Commands",
  37. "class": "ButtonsDevice",
  38. "buttons": [
  39. {
  40. "id": "button-reboot",
  41. "text": "Reboot Pi"
  42. },
  43. {
  44. "id": "button-shutdown",
  45. "text": "Shutdown Pi"
  46. },
  47. {
  48. "id": "button-pimatic-restart",
  49. "text": "Restart pimatic"
  50. },
  51. {
  52. "id": "button-homeduino-update",
  53. "text": "Update Homeduino"
  54. }
  55. ]
  56. },
  57. {
  58. "id": "pimatic-version",
  59. "name": "Pimatic Version",
  60. "class": "ShellSensor",
  61. "attributeName": "version",
  62. "attributeType": "string",
  63. "command": "cat /home/pi/pimatic-app/node_modules/pimatic/package.json |grep version\\\": |awk {'print $2'}|sed 's/,//g' |sed 's/\"//g'",
  64. "interval": 180000
  65. },
  66. {
  67. "id": "homeduino-version",
  68. "name": "homeduino Version",
  69. "class": "ShellSensor",
  70. "attributeName": "version",
  71. "attributeType": "string",
  72. "command": "cat /home/pi/pimatic-app/node_modules/pimatic-homeduino/package.json |grep version\\\": |awk {'print $2'}|sed 's/,//g' |sed 's/\"//g'",
  73. "interval": 180000
  74. },
  75. {
  76. "class": "iframeDevice",
  77. "id": "homeduino-changelog",
  78. "name": "Homeduino Changelog",
  79. "url": "http://admin:password@YOUR-PIMATIC-IP-HERE/files/home/pi/homeduino-changelog.log",
  80. "width": 600,
  81. "height": 150,
  82. "border": 0,
  83. "scrolling": "yes",
  84. "scale": 1,
  85. "reload": 30
  86. },
  87. {
  88. "class": "iframeDevice",
  89. "id": "pimatic-changelog",
  90. "name": "Pimatic Changelog",
  91. "url": "http://admin:password@YOUR-PIMATIC-IP-HERE/files/home/pi/pimatic-changelog.log",
  92. "width": 600,
  93. "height": 150,
  94. "border": 0,
  95. "scrolling": "yes",
  96. "scale": 1,
  97. "reload": 30
  98. },
  99. {
  100. "id": "pimatic-version-git",
  101. "name": "Pimatic Version Request",
  102. "class": "ShellSensor",
  103. "attributeName": "versionrequest",
  104. "attributeType": "string",
  105. "command": "curl -s https://github.com/pimatic/pimatic/blob/master/package.json | grep version | grep span | awk -F\\> {'print $11'} | awk -F\\< {'print $1'}\n",
  106. "interval": 21600000
  107. },
  108. {
  109. "id": "homeduino-version-git",
  110. "name": "homeduino Version Request",
  111. "class": "ShellSensor",
  112. "attributeName": "versionrequest",
  113. "attributeType": "string",
  114. "command": "curl -s https://github.com/pimatic/pimatic-homeduino/blob/v0.9.x/package.json | grep version | grep span | awk -F\\> {'print $11'} | awk -F\\< {'print $1'}\n",
  115. "interval": 21600000
  116. },
  117. {
  118. "id": "pimatic-update-gui",
  119. "name": "pimatic update info",
  120. "class": "VariablesDevice",
  121. "variables": [
  122. {
  123. "name": "pimatic-update-gui",
  124. "type": "string",
  125. "expression": "$pimatic-update-info"
  126. }
  127. ]
  128. },
  129. {
  130. "id": "homeduino-update-gui",
  131. "name": "homeduino update info",
  132. "class": "VariablesDevice",
  133. "variables": [
  134. {
  135. "name": "homeduino-update-gui",
  136. "type": "string",
  137. "expression": "$homeduino-update-info"
  138. }
  139. ]
  140. },
  141.  
  142.  
  143. =================================================================
  144. RULES FOR COMPARING VERSION NUMBERS AND FOR SYSTEM BUTTONS DEVICE
  145. =================================================================
  146.  
  147. {
  148. "id": "pimatic-update-available",
  149. "name": "pimatic update available",
  150. "rule": "if $pimatic-version-git.versionrequest is not $pimatic-version.version then set $pimatic-update-info = \"Update to v$pimatic-version-git.versionrequest available\"",
  151. "active": true,
  152. "logging": true
  153. },
  154. {
  155. "id": "pimatic-update-not-available",
  156. "name": "pimatic update not available",
  157. "rule": "if $pimatic-version-git.versionrequest is $pimatic-version.version then set $pimatic-update-info = \"No update found\"",
  158. "active": true,
  159. "logging": true
  160. },
  161. {
  162. "id": "pimatic-changelog-request",
  163. "name": "pimatic changelog request",
  164. "rule": "if $pimatic-version-git.versionrequest gets updated then execute \"sudo github-changes -o pimatic -r pimatic -f /home/pi/CHANGELOG-PIMATIC.md && head -23 /home/pi/CHANGELOG-PIMATIC.md | tail -20 | awk '-F)' \\{'print \\$2'\\} | sed 's/(//g' > /home/pi/pimatic-changelog.log\"",
  165. "active": true,
  166. "logging": true
  167. },
  168. {
  169. "id": "homeduino-update-available",
  170. "name": "homeduino update available",
  171. "rule": "if $homeduino-version-git.versionrequest is not $homeduino-version.version then set $homeduino-update-info = \"Update to v$homeduino-version-git.versionrequest available\"",
  172. "active": true,
  173. "logging": true
  174. },
  175. {
  176. "id": "homeduino-update-not-available",
  177. "name": "homeduino update not available",
  178. "rule": "if $homeduino-version-git.versionrequest is $homeduino-version.version then set $homeduino-update-info = \"No update found\"",
  179. "active": true,
  180. "logging": true
  181. },
  182. {
  183. "id": "homeduino-changelog-request",
  184. "name": "homeduino changelog request",
  185. "rule": "if $homeduino-version-git.versionrequest gets updated then execute \"sudo github-changes -o pimatic -r pimatic-homeduino -b v0.9.x -f /home/pi/CHANGELOG-HOMEDUINO.md && head -23 /home/pi/CHANGELOG-HOMEDUINO.md | tail -20 | awk '-F)' \\{'print \\$2'\\} | sed 's/(//g' > /home/pi/homeduino-changelog.log\"",
  186. "active": true,
  187. "logging": true
  188. },
  189. {
  190. "id": "system-homeduino-update",
  191. "name": "System Homeduino update",
  192. "rule": "if button-homeduino-update is pressed then execute \"sudo bash /home/pi/homeduino-online-installer.sh\"",
  193. "active": true,
  194. "logging": true
  195. },
  196. {
  197. "id": "system-pimatic-restart",
  198. "name": "System Pimatic restart",
  199. "rule": "if button-pimatic-restart is pressed then execute \"sudo service pimatic restart\"",
  200. "active": true,
  201. "logging": true
  202. },
  203. {
  204. "id": "system-reboot",
  205. "name": "System reboot",
  206. "rule": "if button-reboot is pressed then execute \"sudo reboot\"",
  207. "active": true,
  208. "logging": true
  209. },
  210. {
  211. "id": "system-shutdown",
  212. "name": "System shutdown",
  213. "rule": "if button-shutdown is pressed then execute \"sudo shutdown -h now\"",
  214. "active": true,
  215. "logging": true
  216. }
  217.  
  218.  
  219. ======================================================
  220. VARIABLES FOR THE VARIABLES SECTION OF THE CONFIG.JSON
  221. ======================================================
  222.  
  223. {
  224. "name": "pimatic-update-info",
  225. "value": "No update found"
  226. },
  227. {
  228. "name": "homeduino-update-info",
  229. "value": "No update found"
  230. }
  231.  
  232.  
  233.  
  234. =====================================================================
  235. homeduino-online-installer.sh BASH SCRIPT FOR HOMEDUINO UPDATE BUTTON
  236. =====================================================================
  237.  
  238. #!/bin/bash
  239. # homeduino-online-installer.sh
  240. # updating homeduino when pimatic is running.
  241.  
  242. # removing old logfile
  243. sudo rm -rf /home/pi/homeduino-online-installer.log
  244.  
  245. # setting the date to the logfile
  246. date &>> /home/pi/homeduino-online-installer.log
  247.  
  248. # stop pimatic daemon
  249. sudo service pimatic stop &>> /home/pi/homeduino-online-installer.log
  250.  
  251. # getting update and upgrade
  252. sudo apt-get -qq update &>> /home/pi/homeduino-online-installer.log
  253. sudo apt-get -qq upgrade &>> /home/pi/homeduino-online-installer.log
  254.  
  255. # copy homeduino to homedirectory
  256. cd /home/pi &>> /home/pi/homeduino-online-installer.log
  257. sudo rm -rf homeduino &>> /home/pi/homeduino-online-installer.log
  258. sudo git clone --recursive https://github.com/pimatic/homeduino.git &>> /home/pi/homeduino-online-installer.log
  259.  
  260. # flash arduino
  261. cd homeduino &>> /home/pi/homeduino-online-installer.log
  262. sudo make upload &>> /home/pi/homeduino-online-installer.log
  263.  
  264. # start pimatic daemon
  265. sudo service pimatic start &>> /home/pi/homeduino-online-installer.log
  266.  
  267. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement