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