mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[image]Rename option "use_transparency" (#8113)
This commit is contained in:
		| @@ -282,7 +282,7 @@ IMAGE_TYPE = { | ||||
|  | ||||
| TransparencyType = image_ns.enum("TransparencyType") | ||||
|  | ||||
| CONF_USE_TRANSPARENCY = "use_transparency" | ||||
| CONF_TRANSPARENCY = "transparency" | ||||
|  | ||||
| # If the MDI file cannot be downloaded within this time, abort. | ||||
| IMAGE_DOWNLOAD_TIMEOUT = 30  # seconds | ||||
| @@ -417,7 +417,7 @@ def validate_type(image_types): | ||||
|  | ||||
| def validate_settings(value): | ||||
|     type = value[CONF_TYPE] | ||||
|     transparency = value[CONF_USE_TRANSPARENCY].lower() | ||||
|     transparency = value[CONF_TRANSPARENCY].lower() | ||||
|     allow_config = IMAGE_TYPE[type].allow_config | ||||
|     if transparency not in allow_config: | ||||
|         raise cv.Invalid( | ||||
| @@ -458,9 +458,7 @@ BASE_SCHEMA = cv.Schema( | ||||
| IMAGE_SCHEMA = BASE_SCHEMA.extend( | ||||
|     { | ||||
|         cv.Required(CONF_TYPE): validate_type(IMAGE_TYPE), | ||||
|         cv.Optional( | ||||
|             CONF_USE_TRANSPARENCY, default=CONF_OPAQUE | ||||
|         ): validate_transparency(), | ||||
|         cv.Optional(CONF_TRANSPARENCY, default=CONF_OPAQUE): validate_transparency(), | ||||
|     } | ||||
| ) | ||||
|  | ||||
| @@ -476,7 +474,7 @@ def typed_image_schema(image_type): | ||||
|                     BASE_SCHEMA.extend( | ||||
|                         { | ||||
|                             cv.Optional( | ||||
|                                 CONF_USE_TRANSPARENCY, default=t | ||||
|                                 CONF_TRANSPARENCY, default=t | ||||
|                             ): validate_transparency((t,)), | ||||
|                             cv.Optional(CONF_TYPE, default=image_type): validate_type( | ||||
|                                 (image_type,) | ||||
| @@ -494,7 +492,7 @@ def typed_image_schema(image_type): | ||||
|             BASE_SCHEMA.extend( | ||||
|                 { | ||||
|                     cv.Optional( | ||||
|                         CONF_USE_TRANSPARENCY, default=CONF_OPAQUE | ||||
|                         CONF_TRANSPARENCY, default=CONF_OPAQUE | ||||
|                     ): validate_transparency(), | ||||
|                     cv.Optional(CONF_TYPE, default=image_type): validate_type( | ||||
|                         (image_type,) | ||||
| @@ -556,7 +554,7 @@ async def write_image(config, all_frames=False): | ||||
|         else Image.Dither.FLOYDSTEINBERG | ||||
|     ) | ||||
|     type = config[CONF_TYPE] | ||||
|     transparency = config[CONF_USE_TRANSPARENCY] | ||||
|     transparency = config[CONF_TRANSPARENCY] | ||||
|     invert_alpha = config[CONF_INVERT_ALPHA] | ||||
|     frame_count = 1 | ||||
|     if all_frames: | ||||
|   | ||||
| @@ -5,7 +5,7 @@ import esphome.codegen as cg | ||||
| from esphome.components.http_request import CONF_HTTP_REQUEST_ID, HttpRequestComponent | ||||
| from esphome.components.image import ( | ||||
|     CONF_INVERT_ALPHA, | ||||
|     CONF_USE_TRANSPARENCY, | ||||
|     CONF_TRANSPARENCY, | ||||
|     IMAGE_SCHEMA, | ||||
|     Image_, | ||||
|     get_image_type_enum, | ||||
| @@ -168,7 +168,7 @@ async def to_code(config): | ||||
|  | ||||
|     url = config[CONF_URL] | ||||
|     width, height = config.get(CONF_RESIZE, (0, 0)) | ||||
|     transparent = get_transparency_enum(config[CONF_USE_TRANSPARENCY]) | ||||
|     transparent = get_transparency_enum(config[CONF_TRANSPARENCY]) | ||||
|  | ||||
|     var = cg.new_Pvariable( | ||||
|         config[CONF_ID], | ||||
|   | ||||
| @@ -2,12 +2,12 @@ animation: | ||||
|   - id: rgb565_animation | ||||
|     file: $component_dir/anim.gif | ||||
|     type: RGB565 | ||||
|     use_transparency: opaque | ||||
|     transparency: opaque | ||||
|     resize: 50x50 | ||||
|   - id: rgb_animation | ||||
|     file: $component_dir/anim.apng | ||||
|     type: RGB | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|     resize: 50x50 | ||||
|   - id: grayscale_animation | ||||
|     file: $component_dir/anim.apng | ||||
|   | ||||
| @@ -6,54 +6,54 @@ image: | ||||
|   - id: transparent_transparent_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: BINARY | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|  | ||||
|   - id: rgba_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: RGB | ||||
|     use_transparency: alpha_channel | ||||
|     transparency: alpha_channel | ||||
|     resize: 50x50 | ||||
|   - id: rgb24_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: RGB | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|   - id: rgb_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: RGB | ||||
|     use_transparency: opaque | ||||
|     transparency: opaque | ||||
|  | ||||
|   - id: rgb565_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: RGB565 | ||||
|     use_transparency: opaque | ||||
|     transparency: opaque | ||||
|   - id: rgb565_ck_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: RGB565 | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|   - id: rgb565_alpha_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: RGB565 | ||||
|     use_transparency: alpha_channel | ||||
|     transparency: alpha_channel | ||||
|  | ||||
|   - id: grayscale_alpha_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: grayscale | ||||
|     use_transparency: alpha_channel | ||||
|     transparency: alpha_channel | ||||
|     resize: 50x50 | ||||
|   - id: grayscale_ck_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: grayscale | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|   - id: grayscale_image | ||||
|     file: ../../pnglogo.png | ||||
|     type: grayscale | ||||
|     use_transparency: opaque | ||||
|     transparency: opaque | ||||
|  | ||||
|   - id: web_svg_image | ||||
|     file: https://raw.githubusercontent.com/esphome/esphome-docs/a62d7ab193c1a464ed791670170c7d518189109b/images/logo.svg | ||||
|     resize: 256x48 | ||||
|     type: BINARY | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|   - id: web_tiff_image | ||||
|     file: https://upload.wikimedia.org/wikipedia/commons/b/b6/SIPI_Jelly_Beans_4.1.07.tiff | ||||
|     type: RGB | ||||
|   | ||||
| @@ -12,7 +12,7 @@ image: | ||||
|       dither: FloydSteinberg | ||||
|     - id: transparent_transparent_image | ||||
|       file: ../../pnglogo.png | ||||
|       use_transparency: chroma_key | ||||
|       transparency: chroma_key | ||||
|   rgb: | ||||
|     alpha_channel: | ||||
|       - id: rgba_image | ||||
| @@ -28,21 +28,21 @@ image: | ||||
|   rgb565: | ||||
|     - id: rgb565_image | ||||
|       file: ../../pnglogo.png | ||||
|       use_transparency: opaque | ||||
|       transparency: opaque | ||||
|     - id: rgb565_ck_image | ||||
|       file: ../../pnglogo.png | ||||
|       use_transparency: chroma_key | ||||
|       transparency: chroma_key | ||||
|     - id: rgb565_alpha_image | ||||
|       file: ../../pnglogo.png | ||||
|       use_transparency: alpha_channel | ||||
|       transparency: alpha_channel | ||||
|   grayscale: | ||||
|     - id: grayscale_alpha_image | ||||
|       file: ../../pnglogo.png | ||||
|       use_transparency: alpha_channel | ||||
|       transparency: alpha_channel | ||||
|       resize: 50x50 | ||||
|     - id: grayscale_ck_image | ||||
|       file: ../../pnglogo.png | ||||
|       use_transparency: chroma_key | ||||
|       transparency: chroma_key | ||||
|     - id: grayscale_image | ||||
|       file: ../../pnglogo.png | ||||
|       use_transparency: opaque | ||||
|       transparency: opaque | ||||
|   | ||||
| @@ -14,18 +14,18 @@ online_image: | ||||
|   - id: online_binary_transparent_image | ||||
|     url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png | ||||
|     type: BINARY | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|     format: png | ||||
|   - id: online_rgba_image | ||||
|     url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png | ||||
|     format: PNG | ||||
|     type: RGB | ||||
|     use_transparency: alpha_channel | ||||
|     transparency: alpha_channel | ||||
|   - id: online_rgb24_image | ||||
|     url: http://www.libpng.org/pub/png/img_png/pnglogo-blk-tiny.png | ||||
|     format: PNG | ||||
|     type: RGB | ||||
|     use_transparency: chroma_key | ||||
|     transparency: chroma_key | ||||
|  | ||||
| # Check the set_url action | ||||
| esphome: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user