Advertisement
Guest User

Untitled

a guest
May 19th, 2022
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.22 KB | None | 0 0
  1. captive_portal:
  2.  
  3.  
  4. i2c:
  5. ## - id: bus_a
  6. ## sda: 0
  7. ## scl: 26
  8. ## scan: true
  9. - id: bus_b
  10. sda: 21
  11. scl: 22
  12. scan: true
  13. - id: bus_c
  14. sda: 32
  15. scl: 33
  16. scan: true
  17.  
  18. axp192:
  19. id: axp
  20. address: 0x34
  21. i2c_id: bus_b
  22. update_interval: 60s
  23.  
  24.  
  25.  
  26.  
  27.  
  28. binary_sensor:
  29.  
  30.  
  31.  
  32. - platform: gpio
  33. pin:
  34. number: GPIO37
  35. inverted: True
  36. name: "M5 Button"
  37. #on_press:
  38.  
  39. on_multi_click:
  40. # double click
  41. - timing:
  42. - ON for at most 1s
  43. - OFF for at most 1s
  44. - ON for at most 1s
  45. - OFF for at least 0.2s
  46. then:
  47. - homeassistant.service:
  48. service: media_player.media_next_track
  49. data:
  50. entity_id: media_player.spotify_matt_bruman
  51. # hold button
  52. - timing:
  53. - ON for 1s to 5s
  54. - OFF for at least 0.5s
  55. then:
  56. - homeassistant.service:
  57. service: light.toggle
  58. data:
  59. entity_id: light.office_lights
  60. # single click
  61. - timing:
  62. - ON for at most 1s
  63. - OFF for at least 0.5s
  64. then:
  65. - homeassistant.service:
  66. service: media_player.media_play_pause
  67. data:
  68. entity_id: media_player.spotify_matt_bruman
  69. - logger.log: "single click - play/pause"
  70.  
  71. - platform: axp192
  72. axp192_id: axp
  73. type: charging
  74. id: axp_charger
  75. name: "Charger"
  76.  
  77. - platform: homeassistant
  78. id: lock_status
  79. internal: true
  80. entity_id: input_boolean.locks
  81.  
  82. ##binary sensor for condition - invert as the toggle is to DISABLE the fans thus loop
  83.  
  84. - platform: status
  85. name: "Node Status"
  86. id: system_status
  87.  
  88.  
  89.  
  90. - platform: gpio
  91. pin:
  92. number: GPIO39
  93. inverted: true
  94. name: Button B
  95. on_multi_click:
  96. # double click
  97. - timing:
  98. - ON for at most 1s
  99. - OFF for at most 1s
  100. - ON for at most 1s
  101. - OFF for at least 0.2s
  102. then:
  103. - homeassistant.service:
  104. service: lock.unlock
  105. data:
  106. entity_id: lock.side_door_lock_locked
  107. - delay: 30s
  108. - homeassistant.service:
  109. service: lock.lock
  110. data:
  111. entity_id: lock.side_door_lock_locked
  112. # hold button
  113. - timing:
  114. - ON for 3s to 5s
  115. - OFF for at least 0.5s
  116. then:
  117. - light.toggle: backlight
  118. # single click
  119. - timing:
  120. - ON for at most 2s
  121. - OFF for at least 0.5s
  122. then:
  123. - display.page.show_next: tft
  124.  
  125.  
  126.  
  127. # internal LED
  128. light:
  129. - platform: monochromatic
  130. output: builtin_led
  131. name: Led
  132. id: led1
  133.  
  134. # internal LED
  135. - platform: axp192
  136. id: backlight
  137. axp192_id: axp
  138. restore_mode: ALWAYS_ON
  139. name: "Backlight"
  140.  
  141. output:
  142.  
  143. - platform: ledc
  144. pin: GPIO10
  145. inverted: true
  146. id: builtin_led
  147.  
  148.  
  149.  
  150. sensor:
  151. - platform: axp192
  152. axp192_id: axp
  153. id: batterylevel
  154. name: "Battery Level"
  155.  
  156. - platform: wifi_signal
  157. name: WiFi Signal
  158. id: wifi_dbm
  159.  
  160. - platform: uptime
  161. name: Uptime
  162.  
  163. image:
  164. - file: "spotify.png"
  165. id: my_image
  166. resize: 75x75
  167.  
  168.  
  169.  
  170. text_sensor:
  171.  
  172. - platform: homeassistant
  173. name: "Spotify Title"
  174. id: spotify_title
  175. entity_id: media_player.spotify_
  176. attribute: media_title
  177.  
  178. - platform: homeassistant
  179. name: "Spotify Artist"
  180. id: spotify_artist
  181. entity_id: media_player.spotify_
  182. attribute: media_artist
  183.  
  184. - platform: homeassistant
  185. name: "Spotify State"
  186. id: spotify_state
  187. entity_id: media_player.spotify_
  188.  
  189. - platform: homeassistant
  190. name: "Office"
  191. id: light_office
  192. entity_id: light.office_lights
  193.  
  194. - platform: homeassistant
  195. name: "Locks"
  196. id: lock_locks
  197. entity_id: input_boolean.locks
  198.  
  199. - platform: homeassistant
  200. name: "Windows"
  201. id: windows
  202. entity_id: binary_sensor.windows
  203.  
  204. spi:
  205. clk_pin: GPIO13
  206. mosi_pin: GPIO15
  207.  
  208. font:
  209. - file: "arial.ttf"
  210. id: font1
  211. size: 14
  212. glyphs:
  213. ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
  214. '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
  215. 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
  216. 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
  217. 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
  218. 'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/']
  219.  
  220. - file: "arial.ttf"
  221. id: font2
  222. size: 32
  223. glyphs:
  224. ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
  225. '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
  226. 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
  227. 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
  228. 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
  229. 'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/']
  230.  
  231. - file: "arial.ttf"
  232. id: font3
  233. size: 14
  234. glyphs:
  235. ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
  236. '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
  237. 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
  238. 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
  239. 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
  240. 'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/']
  241.  
  242. - file: "arial.ttf"
  243. id: font4
  244. size: 12
  245. glyphs:
  246. ['&', '@', '!', ',', '.', '"', '%', '(', ')', '+', '-', '_', ':', '°', '0',
  247. '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
  248. 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
  249. 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
  250. 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
  251. 'u', 'v', 'w', 'x', 'y', 'z', 'å', 'ä', 'ö', '/']
  252.  
  253. color:
  254. - id: my_red
  255. red: 100%
  256. green: 0%
  257. blue: 0%
  258. - id: my_yellow
  259. red: 100%
  260. green: 100%
  261. blue: 0%
  262. - id: my_green
  263. red: 0%
  264. green: 100%
  265. blue: 0%
  266. - id: my_blue
  267. red: 0%
  268. green: 0%
  269. blue: 100%
  270. - id: my_gray
  271. red: 50%
  272. green: 50%
  273. blue: 50%
  274.  
  275. #Display size 135*240
  276. display:
  277. - platform: st7789v
  278. id: tft
  279. update_interval: 1s
  280. cs_pin: GPIO5
  281. dc_pin: GPIO23
  282. reset_pin: GPIO18
  283. rotation: 0
  284. pages:
  285. - id: page1
  286. lambda: |-
  287.  
  288. // Draw a line from [0,22] to [240,22]
  289. it.line(0, 22, it.get_width(), 22);
  290. //it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
  291. //it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
  292.  
  293. it.print(5, 5, id(font1), id(my_yellow), TextAlign::TOP_LEFT, "P1");
  294. it.printf( 100, 15, id(font4), TextAlign::CENTER, "Bat: %.1f%%", id(batterylevel).state);
  295. it.printf( 100, 5, id(font4), id(my_yellow), TextAlign::CENTER, "Wifi: %.1f%%", id(wifi_dbm).state);
  296. // Comment out the above lines to see the image without text overlaid
  297. // it.image(0, 0, id(my_image));
  298.  
  299.  
  300. it.printf( 5, 28, id(font1), "Windows: %s", id(windows).state.c_str());
  301. it.printf( 5, 38, id(font1), "Locks: %s", id(lock_locks).state.c_str());
  302. it.printf( 5, 58, id(font1), "Office: %s", id(light_office).state.c_str());
  303.  
  304.  
  305. - id: page2
  306. lambda: |-
  307.  
  308. // Draw a line from [0,22] to [240,22]
  309. it.line(0, 22, it.get_width(), 22);
  310. //it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
  311. //it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
  312.  
  313. it.print(5, 5, id(font1), id(my_yellow), TextAlign::TOP_LEFT, "P2");
  314. it.printf( 100, 15, id(font4), TextAlign::CENTER, "Bat: %.1f%%", id(batterylevel).state);
  315. it.printf( 100, 5, id(font4), id(my_yellow), TextAlign::CENTER, "Wifi: %.1f%%", id(wifi_dbm).state);
  316. // Comment out the above lines to see the image without text overlaid
  317. // it.image(0, 0, id(my_image));
  318.  
  319.  
  320. - id: page3
  321. lambda: |-
  322. // Draw a line from [0,22] to [240,22]
  323. it.line(0, 22, it.get_width(), 22);
  324. it.image(30, 30, id(my_image));
  325.  
  326. it.print(5, 5, id(font1), id(my_yellow), TextAlign::TOP_LEFT, "P3");
  327. it.printf( 100, 15, id(font4), TextAlign::CENTER, "Bat: %.1f%%", id(batterylevel).state);
  328. it.printf( 100, 5, id(font4), id(my_yellow), TextAlign::CENTER, "Wifi: %.1f%%", id(wifi_dbm).state);
  329. // Comment out the above lines to see the image without text overlaid
  330. // it.image(0, 0, id(my_image));
  331.  
  332. //Spotify
  333. it.printf( 5, 130, id(font1), "%s", id(spotify_artist).state.c_str());
  334. it.printf( 5, 150, id(font1), "%s", id(spotify_title).state.c_str());
  335. it.printf( 5, 200, id(font2), "%s", id(spotify_state).state.c_str());
  336. time:
  337. - platform: homeassistant
  338. id: homeassistant_time
  339. - platform: sntp
  340. id: sntp_time
  341.  
  342.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement