Enhance display configuration and add 3D printer progress bar; update security key in mateusz-room-switch.yaml
This commit is contained in:
		
							parent
							
								
									074c0d3fda
								
							
						
					
					
						commit
						89d8008b79
					
				
							
								
								
									
										45
									
								
								display.yaml
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								display.yaml
									
									
									
									
									
								
							| @ -51,16 +51,16 @@ display: | |||||||
|     reset_pin: 4 |     reset_pin: 4 | ||||||
|     lambda: |- |     lambda: |- | ||||||
|       // Define row positions |       // Define row positions | ||||||
|       int icon_row = 5; |       int margin = 5; | ||||||
|       int row_y = icon_row + 25; |  | ||||||
|       int y_step = 30; |       int y_step = 30; | ||||||
|       int col_start = 5; |       int screen_width = 240; | ||||||
|       int col_offset = col_start + 25; |       int row_y = margin + 25; | ||||||
|  |       int col_offset = margin + 25; | ||||||
|       int icon_size = y_step * 0.75; |       int icon_size = y_step * 0.75; | ||||||
| 
 | 
 | ||||||
|       // Calculate column and row positions |       // Calculate column and row positions | ||||||
|       int col_array[] = {col_start, col_offset + y_step, col_offset + y_step * 2, col_offset + y_step * 3, col_offset + y_step * 5, col_offset + y_step * 7};  |       int col_array[] = {margin, col_offset + y_step, col_offset + y_step * 2, col_offset + y_step * 3, col_offset + y_step * 5, col_offset + y_step * 7};  | ||||||
|       int row_array[] = {icon_row, row_y, row_y + y_step, row_y + y_step * 2, row_y + y_step * 3, row_y + y_step * 4}; |       int row_array[] = {margin, row_y, row_y + y_step, row_y + y_step * 2, row_y + y_step * 3, row_y + y_step * 4}; | ||||||
| 
 | 
 | ||||||
|       it.fill(Color(0, 0, 0));  // Clear screen |       it.fill(Color(0, 0, 0));  // Clear screen | ||||||
| 
 | 
 | ||||||
| @ -80,8 +80,10 @@ display: | |||||||
|         } |         } | ||||||
|          |          | ||||||
|         if (text == "unavailable" || text == "unknown") { |         if (text == "unavailable" || text == "unknown") { | ||||||
|             it.filled_triangle(x, y + icon_size, x + icon_size, y + icon_size, x + (icon_size / 2), y, Color(255, 0, 0)); |           if (id(triangle_visible)) { | ||||||
|             it.print((x + icon_size / 3) + 1, y, id(my_font), Color(255, 255, 255), "!"); |             it.filled_triangle(center, y + icon_size, center + icon_size, y + icon_size, center + (icon_size / 2), y, Color(255, 0, 0)); | ||||||
|  |             it.print((center + icon_size / 3) + 1, y, id(my_font), Color(255, 255, 255), "!"); | ||||||
|  |           } | ||||||
|         } else if (text == "" && type == "door" || text == "" && type == "motion") { |         } else if (text == "" && type == "door" || text == "" && type == "motion") { | ||||||
|           it.filled_rectangle(x, y, icon_size, icon_size, Color(128, 128, 128)); |           it.filled_rectangle(x, y, icon_size, icon_size, Color(128, 128, 128)); | ||||||
|         } else if (text == "on") { |         } else if (text == "on") { | ||||||
| @ -134,6 +136,16 @@ display: | |||||||
|       handle_state(4, 4, id(tomek_humidity).state, "humidity"); |       handle_state(4, 4, id(tomek_humidity).state, "humidity"); | ||||||
|       handle_state(4, 5, id(mateusz_humidity).state, "humidity"); |       handle_state(4, 5, id(mateusz_humidity).state, "humidity"); | ||||||
| 
 | 
 | ||||||
|  |       // 3D Printer progress bar | ||||||
|  |       if (id(printer_3d_progress).state != "" && id(printer_3d_progress).state != "unknown" && id(printer_3d_progress).state != "unavailable" && id(printer_3d_progress).state != "0") { | ||||||
|  |         int progress_y = row_array[5] + y_step; | ||||||
|  |         it.print(margin, progress_y, id(my_font), Color(255, 255, 255), "3D Printer:"); | ||||||
|  |         int progress_width = screen_width - (2 * margin) - 100; | ||||||
|  |         int progress = (atoi(id(printer_3d_progress).state.c_str()) / 100) * progress_width; | ||||||
|  |         it.filled_rectangle(margin + 90, progress_y, progress, 20, Color(0, 255, 0)); | ||||||
|  |         it.rectangle(margin + 90, progress_y, progress_width, 20, Color(255, 255, 255)); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
| # Home Assistant integration | # Home Assistant integration | ||||||
| text_sensor: | text_sensor: | ||||||
|   - platform: homeassistant |   - platform: homeassistant | ||||||
| @ -199,6 +211,9 @@ text_sensor: | |||||||
|   - platform: homeassistant |   - platform: homeassistant | ||||||
|     entity_id: sensor.mateusz_s_room_sensor_humidity |     entity_id: sensor.mateusz_s_room_sensor_humidity | ||||||
|     id: mateusz_humidity |     id: mateusz_humidity | ||||||
|  |   - platform: homeassistant | ||||||
|  |     entity_id: sensor.octoprint_job_percentage | ||||||
|  |     id: printer_3d_progress | ||||||
| 
 | 
 | ||||||
| font: | font: | ||||||
|   - id: my_font |   - id: my_font | ||||||
| @ -208,3 +223,17 @@ font: | |||||||
|     file: "fonts/JetBrains.ttf" |     file: "fonts/JetBrains.ttf" | ||||||
|     size: 20 |     size: 20 | ||||||
|     glyphs: [ "", "", "", "", "" ] |     glyphs: [ "", "", "", "", "" ] | ||||||
|  | 
 | ||||||
|  | interval: | ||||||
|  |   - interval: 1s | ||||||
|  |     then: | ||||||
|  |       lambda: |- | ||||||
|  |         static bool toggle = false; | ||||||
|  |         toggle = !toggle; | ||||||
|  |         id(triangle_visible) = toggle; | ||||||
|  | 
 | ||||||
|  | globals: | ||||||
|  |   - id: triangle_visible | ||||||
|  |     type: bool | ||||||
|  |     restore_value: no | ||||||
|  |     initial_value: 'true' | ||||||
|  | |||||||
| @ -15,7 +15,7 @@ mdns: | |||||||
| 
 | 
 | ||||||
| api: | api: | ||||||
|   encryption: |   encryption: | ||||||
|     key: "" |     key: "6XGt8kCrllL861S4s3oBM5eUZ+p84JhxZqP6X4EsWE4=" | ||||||
| 
 | 
 | ||||||
| ota: | ota: | ||||||
|   platform: esphome |   platform: esphome | ||||||
|  | |||||||
| @ -47,6 +47,18 @@ binary_sensor: | |||||||
|             id(power_switch).publish_state(x); |             id(power_switch).publish_state(x); | ||||||
|           } |           } | ||||||
| 
 | 
 | ||||||
|  | text_sensor: | ||||||
|  |   - platform: homeassistant | ||||||
|  |     entity_id: remote.chromecast_hd | ||||||
|  |     id: tv_status | ||||||
|  |     on_value: | ||||||
|  |       - lambda: |- | ||||||
|  |           if (x == "on") { | ||||||
|  |             id(power_switch).turn_on(); | ||||||
|  |           } else { | ||||||
|  |             id(power_switch).turn_off(); | ||||||
|  |           } | ||||||
|  | 
 | ||||||
| # Define the switch to control TV power (Only toggled via Home Assistant) | # Define the switch to control TV power (Only toggled via Home Assistant) | ||||||
| switch: | switch: | ||||||
|   - platform: template |   - platform: template | ||||||
| @ -54,10 +66,10 @@ switch: | |||||||
|     id: power_switch |     id: power_switch | ||||||
|     optimistic: true |     optimistic: true | ||||||
|     restore_mode: RESTORE_DEFAULT_OFF |     restore_mode: RESTORE_DEFAULT_OFF | ||||||
|     turn_on_action: |     # turn_on_action: | ||||||
|       - output.turn_off: tv_relay  # Set P23 LOW |     #   - output.turn_off: tv_relay  # Set P23 LOW | ||||||
|       - delay: 300ms |     #   - delay: 300ms | ||||||
|       - output.turn_on: tv_relay   # Set P23 HIGH |     #   - output.turn_on: tv_relay   # Set P23 HIGH | ||||||
|     turn_off_action: |     turn_off_action: | ||||||
|       - output.turn_off: tv_relay  # Set P23 LOW |       - output.turn_off: tv_relay  # Set P23 LOW | ||||||
|       - delay: 1500ms |       - delay: 1500ms | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user