mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[mapping] Implement yaml-configured maps (#8333)
This commit is contained in:
		
							
								
								
									
										71
									
								
								tests/components/mapping/common.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								tests/components/mapping/common.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| image: | ||||
|   grayscale: | ||||
|     alpha_channel: | ||||
|       - file: ../../pnglogo.png | ||||
|         id: image_1 | ||||
|         resize: 50x50 | ||||
|       - file: ../../pnglogo.png | ||||
|         id: image_2 | ||||
|         resize: 50x50 | ||||
|  | ||||
| mapping: | ||||
|   - id: weather_map | ||||
|     from: string | ||||
|     to: "image::Image" | ||||
|     entries: | ||||
|       clear-night: image_1 | ||||
|       sunny: image_2 | ||||
|   - id: weather_map_1 | ||||
|     from: string | ||||
|     to: esphome::image::Image | ||||
|     entries: | ||||
|       clear-night: image_1 | ||||
|       sunny: image_2 | ||||
|   - id: weather_map_2 | ||||
|     from: string | ||||
|     to: image | ||||
|     entries: | ||||
|       clear-night: image_1 | ||||
|       sunny: image_2 | ||||
|   - id: int_map | ||||
|     from: int | ||||
|     to: string | ||||
|     entries: | ||||
|       1: "one" | ||||
|       2: "two" | ||||
|       3: "three" | ||||
|       77: "seventy-seven" | ||||
|   - id: string_map | ||||
|     from: string | ||||
|     to: int | ||||
|     entries: | ||||
|       one: 1 | ||||
|       two: 2 | ||||
|       three: 3 | ||||
|       seventy-seven: 77 | ||||
|   - id: color_map | ||||
|     from: string | ||||
|     to: color | ||||
|     entries: | ||||
|       red: red_id | ||||
|       blue: blue_id | ||||
|       green: green_id | ||||
|  | ||||
| color: | ||||
|   - id: red_id | ||||
|     red: 1.0 | ||||
|     green: 0.0 | ||||
|     blue: 0.0 | ||||
|   - id: green_id | ||||
|     red: 0.0 | ||||
|     green: 1.0 | ||||
|     blue: 0.0 | ||||
|   - id: blue_id | ||||
|     red: 0.0 | ||||
|     green: 0.0 | ||||
|     blue: 1.0 | ||||
|  | ||||
| display: | ||||
|   lambda: |- | ||||
|       it.image(0, 0, id(weather_map)[0]); | ||||
|       it.image(0, 100, id(weather_map)[1]); | ||||
							
								
								
									
										17
									
								
								tests/components/mapping/test.esp32-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/components/mapping/test.esp32-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| spi: | ||||
|   - id: spi_main_lcd | ||||
|     clk_pin: 16 | ||||
|     mosi_pin: 17 | ||||
|     miso_pin: 15 | ||||
|  | ||||
| display: | ||||
|   - platform: ili9xxx | ||||
|     id: main_lcd | ||||
|     model: ili9342 | ||||
|     cs_pin: 12 | ||||
|     dc_pin: 13 | ||||
|     reset_pin: 21 | ||||
|     invert_colors: false | ||||
|  | ||||
| packages: | ||||
|   map: !include common.yaml | ||||
							
								
								
									
										17
									
								
								tests/components/mapping/test.esp32-c3-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/components/mapping/test.esp32-c3-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| spi: | ||||
|   - id: spi_main_lcd | ||||
|     clk_pin: 6 | ||||
|     mosi_pin: 7 | ||||
|     miso_pin: 5 | ||||
|  | ||||
| display: | ||||
|   - platform: ili9xxx | ||||
|     id: main_lcd | ||||
|     model: ili9342 | ||||
|     cs_pin: 8 | ||||
|     dc_pin: 9 | ||||
|     reset_pin: 10 | ||||
|     invert_colors: false | ||||
|  | ||||
| packages: | ||||
|   map: !include common.yaml | ||||
							
								
								
									
										17
									
								
								tests/components/mapping/test.esp32-c3-idf.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/components/mapping/test.esp32-c3-idf.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| spi: | ||||
|   - id: spi_main_lcd | ||||
|     clk_pin: 6 | ||||
|     mosi_pin: 7 | ||||
|     miso_pin: 5 | ||||
|  | ||||
| display: | ||||
|   - platform: ili9xxx | ||||
|     id: main_lcd | ||||
|     model: ili9342 | ||||
|     cs_pin: 8 | ||||
|     dc_pin: 9 | ||||
|     reset_pin: 10 | ||||
|     invert_colors: false | ||||
|  | ||||
| packages: | ||||
|   map: !include common.yaml | ||||
							
								
								
									
										17
									
								
								tests/components/mapping/test.esp32-idf.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/components/mapping/test.esp32-idf.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| spi: | ||||
|   - id: spi_main_lcd | ||||
|     clk_pin: 16 | ||||
|     mosi_pin: 17 | ||||
|     miso_pin: 15 | ||||
|  | ||||
| display: | ||||
|   - platform: ili9xxx | ||||
|     id: main_lcd | ||||
|     model: ili9342 | ||||
|     cs_pin: 12 | ||||
|     dc_pin: 13 | ||||
|     reset_pin: 21 | ||||
|     invert_colors: false | ||||
|  | ||||
| packages: | ||||
|   map: !include common.yaml | ||||
							
								
								
									
										17
									
								
								tests/components/mapping/test.esp8266-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/components/mapping/test.esp8266-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| spi: | ||||
|   - id: spi_main_lcd | ||||
|     clk_pin: 14 | ||||
|     mosi_pin: 13 | ||||
|     miso_pin: 12 | ||||
|  | ||||
| display: | ||||
|   - platform: ili9xxx | ||||
|     id: main_lcd | ||||
|     model: ili9342 | ||||
|     cs_pin: 5 | ||||
|     dc_pin: 15 | ||||
|     reset_pin: 16 | ||||
|     invert_colors: false | ||||
|  | ||||
| packages: | ||||
|   map: !include common.yaml | ||||
							
								
								
									
										12
									
								
								tests/components/mapping/test.host.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								tests/components/mapping/test.host.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| display: | ||||
|   - platform: sdl | ||||
|     id: sdl_display | ||||
|     update_interval: 1s | ||||
|     auto_clear_enabled: false | ||||
|     show_test_card: true | ||||
|     dimensions: | ||||
|       width: 450 | ||||
|       height: 600 | ||||
|  | ||||
| packages: | ||||
|   map: !include common.yaml | ||||
							
								
								
									
										17
									
								
								tests/components/mapping/test.rp2040-ard.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								tests/components/mapping/test.rp2040-ard.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| spi: | ||||
|   - id: spi_main_lcd | ||||
|     clk_pin: 2 | ||||
|     mosi_pin: 3 | ||||
|     miso_pin: 4 | ||||
|  | ||||
| display: | ||||
|   - platform: ili9xxx | ||||
|     id: main_lcd | ||||
|     model: ili9342 | ||||
|     cs_pin: 20 | ||||
|     dc_pin: 21 | ||||
|     reset_pin: 22 | ||||
|     invert_colors: false | ||||
|  | ||||
| packages: | ||||
|   map: !include common.yaml | ||||
		Reference in New Issue
	
	Block a user