diff --git a/homeassistant/components/led_infrared/button.py b/homeassistant/components/led_infrared/button.py index 2fb449a0aa74..7ec102e5243f 100644 --- a/homeassistant/components/led_infrared/button.py +++ b/homeassistant/components/led_infrared/button.py @@ -42,6 +42,14 @@ SUPPORTED_BUTTONS = { "quick", "slow", ], + LEDIrDeviceType.GENERIC_10_KEY: [ + "brightness_up", + "brightness_down", + "timer_2h", + "timer_4h", + "timer_6h", + "timer_8h", + ], } diff --git a/homeassistant/components/led_infrared/config_flow.py b/homeassistant/components/led_infrared/config_flow.py index 113c93169969..fcedbdd106c6 100644 --- a/homeassistant/components/led_infrared/config_flow.py +++ b/homeassistant/components/led_infrared/config_flow.py @@ -28,8 +28,9 @@ from .const import ( ) DEVICE_NAMES = { - LEDIrDeviceType.GENERIC_24_KEY: "24-key remote", + LEDIrDeviceType.GENERIC_10_KEY: "10-key remote", LEDIrDeviceType.GENERIC_13_KEY: "13-key remote", + LEDIrDeviceType.GENERIC_24_KEY: "24-key remote", LEDIrDeviceType.GENERIC_40_KEY: "40-key remote", LEDIrDeviceType.GENERIC_44_KEY: "44-key remote", } diff --git a/homeassistant/components/led_infrared/const.py b/homeassistant/components/led_infrared/const.py index 6a87589b9e64..c0e97a99eb61 100644 --- a/homeassistant/components/led_infrared/const.py +++ b/homeassistant/components/led_infrared/const.py @@ -11,6 +11,7 @@ CONF_DEVICE_TYPE = "device_type" class LEDIrDeviceType(StrEnum): """LED Infrared device types.""" + GENERIC_10_KEY = "generic_10_key" GENERIC_13_KEY = "generic_13_key" GENERIC_24_KEY = "generic_24_key" GENERIC_40_KEY = "generic_40_key" diff --git a/homeassistant/components/led_infrared/entity.py b/homeassistant/components/led_infrared/entity.py index 8738398a573b..5efb4fc335fc 100644 --- a/homeassistant/components/led_infrared/entity.py +++ b/homeassistant/components/led_infrared/entity.py @@ -1,6 +1,8 @@ """Base entity for LED Infrared integration.""" from infrared_protocols.codes.generic.led import ( + BaseGenericLEDCode, + Generic10KeyCode, Generic13KeyCode, Generic24KeyCode, Generic40KeyCode, @@ -13,12 +15,10 @@ from homeassistant.helpers.entity import Entity from .const import DOMAIN, LEDIrDeviceType -CODES: dict[ - LEDIrDeviceType, - type[Generic24KeyCode | Generic13KeyCode | Generic40KeyCode | Generic44KeyCode], -] = { - LEDIrDeviceType.GENERIC_24_KEY: Generic24KeyCode, +CODES: dict[LEDIrDeviceType, type[BaseGenericLEDCode]] = { + LEDIrDeviceType.GENERIC_10_KEY: Generic10KeyCode, LEDIrDeviceType.GENERIC_13_KEY: Generic13KeyCode, + LEDIrDeviceType.GENERIC_24_KEY: Generic24KeyCode, LEDIrDeviceType.GENERIC_40_KEY: Generic40KeyCode, LEDIrDeviceType.GENERIC_44_KEY: Generic44KeyCode, } diff --git a/homeassistant/components/led_infrared/icons.json b/homeassistant/components/led_infrared/icons.json index e833bfc4d0a1..4d7f8f8c0044 100644 --- a/homeassistant/components/led_infrared/icons.json +++ b/homeassistant/components/led_infrared/icons.json @@ -34,6 +34,18 @@ "timer": { "default": "mdi:timer" }, + "timer_2h": { + "default": "mdi:timer" + }, + "timer_4h": { + "default": "mdi:timer" + }, + "timer_6h": { + "default": "mdi:timer" + }, + "timer_8h": { + "default": "mdi:timer" + }, "white_brightness_100": { "default": "mdi:lightbulb-on" }, @@ -72,6 +84,7 @@ "aqua": "mdi:palette", "auto": "mdi:auto-mode", "blue": "mdi:palette", + "candle": "mdi:candle", "cyan": "mdi:palette", "dark_cyan": "mdi:palette", "deep_blue": "mdi:palette", @@ -91,6 +104,7 @@ "jump3": "mdi:dots-circle", "jump7": "mdi:dots-circle", "lavender_blush": "mdi:palette", + "light": "mdi:lightbulb-on", "light_cyan": "mdi:palette", "light_green": "mdi:palette", "magenta": "mdi:palette", diff --git a/homeassistant/components/led_infrared/light.py b/homeassistant/components/led_infrared/light.py index 4aef99993095..71849e644d5d 100644 --- a/homeassistant/components/led_infrared/light.py +++ b/homeassistant/components/led_infrared/light.py @@ -54,6 +54,7 @@ SUPPORTED_EFFECTS = { "diy5", "diy6", ], + LEDIrDeviceType.GENERIC_10_KEY: ["candle", "light"], } diff --git a/homeassistant/components/led_infrared/strings.json b/homeassistant/components/led_infrared/strings.json index fd47bbbcd8e2..725a3c877dc6 100644 --- a/homeassistant/components/led_infrared/strings.json +++ b/homeassistant/components/led_infrared/strings.json @@ -71,6 +71,18 @@ "timer": { "name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::timer%]" }, + "timer_2h": { + "name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::timer_2h%]" + }, + "timer_4h": { + "name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::timer_4h%]" + }, + "timer_6h": { + "name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::timer_6h%]" + }, + "timer_8h": { + "name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::timer_8h%]" + }, "white_brightness_100": { "name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_brightness_100%]" }, @@ -109,6 +121,7 @@ "blue_up": "Blue up", "brightness_down": "Brightness down", "brightness_up": "Brightness up", + "candle": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::candle%]", "cyan": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::cyan%]", "dark_cyan": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::dark_cyan%]", "deep_blue": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::deep_blue%]", @@ -130,6 +143,7 @@ "jump3": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::jump3%]", "jump7": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::jump7%]", "lavender_blush": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::lavender_blush%]", + "light": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::light%]", "light_cyan": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::light_cyan%]", "light_green": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::light_green%]", "magenta": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::magenta%]", @@ -158,6 +172,10 @@ "smooth": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::smooth%]", "strobe": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::strobe%]", "timer": "Timer", + "timer_2h": "Timer 2h", + "timer_4h": "Timer 4h", + "timer_6h": "Timer 6h", + "timer_8h": "Timer 8h", "tomato": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::tomato%]", "turquoise": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::turquoise%]", "white": "[%key:component::led_infrared::entity::light::light::state_attributes::effect::state::white%]", @@ -184,6 +202,7 @@ "aqua": "Color: Aqua", "auto": "[%key:common::state::auto%]", "blue": "Color: Blue", + "candle": "Candle", "cyan": "Color: Cyan", "dark_cyan": "Color: Dark cyan", "deep_blue": "Color: Deep Blue", @@ -203,6 +222,7 @@ "jump3": "Jump 3", "jump7": "Jump 7", "lavender_blush": "Color: Lavender Blush", + "light": "Steady light", "light_cyan": "Color: Light Cyan", "light_green": "Color: Light green", "magenta": "Color: Magenta", @@ -238,6 +258,7 @@ "selector": { "device_type": { "options": { + "generic_10_key": "10-key remote control", "generic_13_key": "13-key remote control", "generic_24_key": "24-key remote control", "generic_40_key": "40-key remote control", diff --git a/tests/components/led_infrared/conftest.py b/tests/components/led_infrared/conftest.py index 0728752e08b5..774982689a51 100644 --- a/tests/components/led_infrared/conftest.py +++ b/tests/components/led_infrared/conftest.py @@ -70,5 +70,9 @@ def mock_infrared_code_to_command() -> Generator[None]: "infrared_protocols.codes.generic.led.Generic44KeyCode.to_command", new=mock_to_command, ), + patch( + "infrared_protocols.codes.generic.led.Generic10KeyCode.to_command", + new=mock_to_command, + ), ): yield diff --git a/tests/components/led_infrared/snapshots/test_button.ambr b/tests/components/led_infrared/snapshots/test_button.ambr index 60efb80e19fa..d7a5d6476d7c 100644 --- a/tests/components/led_infrared/snapshots/test_button.ambr +++ b/tests/components/led_infrared/snapshots/test_button.ambr @@ -1,4 +1,304 @@ # serializer version: 1 +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_brightness_down-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'button', + 'entity_category': None, + 'entity_id': 'button.led_infrared_via_test_ir_emitter_brightness_down', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Brightness down', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Brightness down', + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'brightness_down', + 'unique_id': '1234567890_brightness_down', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_brightness_down-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'LED Infrared via Test IR emitter Brightness down', + }), + 'context': , + 'entity_id': 'button.led_infrared_via_test_ir_emitter_brightness_down', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_brightness_up-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'button', + 'entity_category': None, + 'entity_id': 'button.led_infrared_via_test_ir_emitter_brightness_up', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Brightness up', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Brightness up', + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'brightness_up', + 'unique_id': '1234567890_brightness_up', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_brightness_up-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'LED Infrared via Test IR emitter Brightness up', + }), + 'context': , + 'entity_id': 'button.led_infrared_via_test_ir_emitter_brightness_up', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_2h-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'button', + 'entity_category': None, + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_2h', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Timer 2h', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Timer 2h', + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'timer_2h', + 'unique_id': '1234567890_timer_2h', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_2h-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'LED Infrared via Test IR emitter Timer 2h', + }), + 'context': , + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_2h', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_4h-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'button', + 'entity_category': None, + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_4h', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Timer 4h', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Timer 4h', + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'timer_4h', + 'unique_id': '1234567890_timer_4h', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_4h-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'LED Infrared via Test IR emitter Timer 4h', + }), + 'context': , + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_4h', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_6h-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'button', + 'entity_category': None, + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_6h', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Timer 6h', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Timer 6h', + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'timer_6h', + 'unique_id': '1234567890_timer_6h', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_6h-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'LED Infrared via Test IR emitter Timer 6h', + }), + 'context': , + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_6h', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_8h-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'button', + 'entity_category': None, + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_8h', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Timer 8h', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Timer 8h', + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'timer_8h', + 'unique_id': '1234567890_timer_8h', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][button.led_infrared_via_test_ir_emitter_timer_8h-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'LED Infrared via Test IR emitter Timer 8h', + }), + 'context': , + 'entity_id': 'button.led_infrared_via_test_ir_emitter_timer_8h', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_setup[generic_13_key][button.led_infrared_via_test_ir_emitter_brightness_down-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/led_infrared/snapshots/test_diagnostics.ambr b/tests/components/led_infrared/snapshots/test_diagnostics.ambr index a35ed6402aa2..dd77b8603327 100644 --- a/tests/components/led_infrared/snapshots/test_diagnostics.ambr +++ b/tests/components/led_infrared/snapshots/test_diagnostics.ambr @@ -1,8 +1,36 @@ # serializer version: 1 -# name: test_diagnostics +# name: test_diagnostics[generic_10_key] + dict({ + 'device_type': 'generic_10_key', + 'infrared_entity_id': 'infrared.test_ir_emitter', + 'infrared_receiver_entity_id': 'infrared.test_ir_receiver', + }) +# --- +# name: test_diagnostics[generic_13_key] + dict({ + 'device_type': 'generic_13_key', + 'infrared_entity_id': 'infrared.test_ir_emitter', + 'infrared_receiver_entity_id': 'infrared.test_ir_receiver', + }) +# --- +# name: test_diagnostics[generic_24_key] dict({ 'device_type': 'generic_24_key', 'infrared_entity_id': 'infrared.test_ir_emitter', 'infrared_receiver_entity_id': 'infrared.test_ir_receiver', }) # --- +# name: test_diagnostics[generic_40_key] + dict({ + 'device_type': 'generic_40_key', + 'infrared_entity_id': 'infrared.test_ir_emitter', + 'infrared_receiver_entity_id': 'infrared.test_ir_receiver', + }) +# --- +# name: test_diagnostics[generic_44_key] + dict({ + 'device_type': 'generic_44_key', + 'infrared_entity_id': 'infrared.test_ir_emitter', + 'infrared_receiver_entity_id': 'infrared.test_ir_receiver', + }) +# --- diff --git a/tests/components/led_infrared/snapshots/test_event.ambr b/tests/components/led_infrared/snapshots/test_event.ambr index b39fe10891c1..1f26c659458b 100644 --- a/tests/components/led_infrared/snapshots/test_event.ambr +++ b/tests/components/led_infrared/snapshots/test_event.ambr @@ -1,4 +1,80 @@ # serializer version: 1 +# name: test_setup[generic_10_key][event.led_infrared_via_test_ir_emitter_received_command-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'on', + 'off', + 'brightness_up', + 'brightness_down', + 'timer_2h', + 'timer_4h', + 'timer_6h', + 'timer_8h', + 'candle', + 'light', + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'event', + 'entity_category': None, + 'entity_id': 'event.led_infrared_via_test_ir_emitter_received_command', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Received command', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Received command', + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'received_command', + 'unique_id': '1234567890', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][event.led_infrared_via_test_ir_emitter_received_command-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : None, + : list([ + 'on', + 'off', + 'brightness_up', + 'brightness_down', + 'timer_2h', + 'timer_4h', + 'timer_6h', + 'timer_8h', + 'candle', + 'light', + ]), + : 'LED Infrared via Test IR emitter Received command', + }), + 'context': , + 'entity_id': 'event.led_infrared_via_test_ir_emitter_received_command', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_setup[generic_13_key][event.led_infrared_via_test_ir_emitter_received_command-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/led_infrared/snapshots/test_light.ambr b/tests/components/led_infrared/snapshots/test_light.ambr index 2368350bd7b0..d3010eee2e14 100644 --- a/tests/components/led_infrared/snapshots/test_light.ambr +++ b/tests/components/led_infrared/snapshots/test_light.ambr @@ -1,4 +1,73 @@ # serializer version: 1 +# name: test_setup[generic_10_key][light.led_infrared_via_test_ir_emitter-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : list([ + 'candle', + 'light', + ]), + : list([ + , + ]), + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'light', + 'entity_category': None, + 'entity_id': 'light.led_infrared_via_test_ir_emitter', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': None, + 'platform': 'led_infrared', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': , + 'translation_key': 'light', + 'unique_id': '1234567890', + 'unit_of_measurement': None, + }) +# --- +# name: test_setup[generic_10_key][light.led_infrared_via_test_ir_emitter-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : True, + : None, + : None, + : list([ + 'candle', + 'light', + ]), + : 'LED Infrared via Test IR emitter', + : list([ + , + ]), + : , + }), + 'context': , + 'entity_id': 'light.led_infrared_via_test_ir_emitter', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_setup[generic_13_key][light.led_infrared_via_test_ir_emitter-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/led_infrared/test_button.py b/tests/components/led_infrared/test_button.py index 1d18aa0f89d3..2d9539fc3bb5 100644 --- a/tests/components/led_infrared/test_button.py +++ b/tests/components/led_infrared/test_button.py @@ -4,6 +4,8 @@ from collections.abc import Generator from unittest.mock import patch from infrared_protocols.codes.generic.led import ( + BaseGenericLEDCode, + Generic10KeyCode, Generic13KeyCode, Generic24KeyCode, Generic40KeyCode, @@ -42,6 +44,7 @@ def button_only() -> Generator[None]: @pytest.mark.parametrize( "config_entry", [ + LEDIrDeviceType.GENERIC_10_KEY, LEDIrDeviceType.GENERIC_13_KEY, LEDIrDeviceType.GENERIC_24_KEY, LEDIrDeviceType.GENERIC_40_KEY, @@ -205,6 +208,36 @@ async def test_setup( "slow", [Generic44KeyCode.SLOW], ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + "brightness_up", + [Generic10KeyCode.BRIGHTNESS_UP], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + "brightness_down", + [Generic10KeyCode.BRIGHTNESS_DOWN], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + "timer_2h", + [Generic10KeyCode.TIMER_2H], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + "timer_4h", + [Generic10KeyCode.TIMER_4H], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + "timer_6h", + [Generic10KeyCode.TIMER_6H], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + "timer_8h", + [Generic10KeyCode.TIMER_8H], + ), ], ) @pytest.mark.usefixtures("infrared_codes") @@ -214,9 +247,7 @@ async def test_button_press( entity_registry: er.EntityRegistry, device_type: LEDIrDeviceType, key: str, - expected_codes: list[ - Generic24KeyCode | Generic13KeyCode | Generic40KeyCode | Generic44KeyCode - ], + expected_codes: list[BaseGenericLEDCode], ) -> None: """Test button press action.""" config_entry = MockConfigEntry( diff --git a/tests/components/led_infrared/test_config_flow.py b/tests/components/led_infrared/test_config_flow.py index 28eeadc07a94..fdd598e7bb70 100644 --- a/tests/components/led_infrared/test_config_flow.py +++ b/tests/components/led_infrared/test_config_flow.py @@ -22,6 +22,7 @@ from tests.components.infrared import EMITTER_ENTITY_ID, RECEIVER_ENTITY_ID @pytest.mark.parametrize( ("device_type", "device_name"), [ + (LEDIrDeviceType.GENERIC_10_KEY, "10-key remote"), (LEDIrDeviceType.GENERIC_13_KEY, "13-key remote"), (LEDIrDeviceType.GENERIC_24_KEY, "24-key remote"), (LEDIrDeviceType.GENERIC_40_KEY, "40-key remote"), diff --git a/tests/components/led_infrared/test_diagnostics.py b/tests/components/led_infrared/test_diagnostics.py index 16f913428770..b9a59284335d 100644 --- a/tests/components/led_infrared/test_diagnostics.py +++ b/tests/components/led_infrared/test_diagnostics.py @@ -1,7 +1,9 @@ """Test for diagnostics platform of the LED Infrared integration.""" +import pytest from syrupy.assertion import SnapshotAssertion +from homeassistant.components.led_infrared.const import LEDIrDeviceType from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant @@ -10,6 +12,17 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry from tests.typing import ClientSessionGenerator +@pytest.mark.parametrize( + "config_entry", + [ + LEDIrDeviceType.GENERIC_10_KEY, + LEDIrDeviceType.GENERIC_13_KEY, + LEDIrDeviceType.GENERIC_24_KEY, + LEDIrDeviceType.GENERIC_40_KEY, + LEDIrDeviceType.GENERIC_44_KEY, + ], + indirect=True, +) async def test_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, diff --git a/tests/components/led_infrared/test_event.py b/tests/components/led_infrared/test_event.py index e09a3e330b81..5ce5b5d83306 100644 --- a/tests/components/led_infrared/test_event.py +++ b/tests/components/led_infrared/test_event.py @@ -4,6 +4,8 @@ from collections.abc import Generator from unittest.mock import patch from infrared_protocols.codes.generic.led import ( + BaseGenericLEDCode, + Generic10KeyCode, Generic13KeyCode, Generic24KeyCode, Generic40KeyCode, @@ -46,6 +48,7 @@ def event_only() -> Generator[None]: @pytest.mark.parametrize( "config_entry", [ + LEDIrDeviceType.GENERIC_10_KEY, LEDIrDeviceType.GENERIC_13_KEY, LEDIrDeviceType.GENERIC_24_KEY, LEDIrDeviceType.GENERIC_40_KEY, @@ -360,6 +363,46 @@ async def test_setup( "on", "light_cyan", ), + (LEDIrDeviceType.GENERIC_10_KEY, Generic10KeyCode.ON, "on", None), + (LEDIrDeviceType.GENERIC_10_KEY, Generic10KeyCode.OFF, "off", None), + (LEDIrDeviceType.GENERIC_10_KEY, Generic10KeyCode.CANDLE, "on", "candle"), + (LEDIrDeviceType.GENERIC_10_KEY, Generic10KeyCode.LIGHT, "on", "light"), + ( + LEDIrDeviceType.GENERIC_10_KEY, + Generic10KeyCode.BRIGHTNESS_UP, + STATE_UNKNOWN, + None, + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + Generic10KeyCode.BRIGHTNESS_DOWN, + STATE_UNKNOWN, + None, + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + Generic10KeyCode.TIMER_2H, + STATE_UNKNOWN, + None, + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + Generic10KeyCode.TIMER_4H, + STATE_UNKNOWN, + None, + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + Generic10KeyCode.TIMER_6H, + STATE_UNKNOWN, + None, + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + Generic10KeyCode.TIMER_8H, + STATE_UNKNOWN, + None, + ), ], ) @pytest.mark.usefixtures( @@ -370,10 +413,7 @@ async def test_event( hass: HomeAssistant, mock_infrared_receiver_entity: MockInfraredReceiverEntity, device_type: LEDIrDeviceType, - command_code: Generic13KeyCode - | Generic24KeyCode - | Generic40KeyCode - | Generic44KeyCode, + command_code: BaseGenericLEDCode, expected_light_state: str, expected_light_effect: str | None, ) -> None: diff --git a/tests/components/led_infrared/test_light.py b/tests/components/led_infrared/test_light.py index 3f650c6d6878..07eb0e38b4b0 100644 --- a/tests/components/led_infrared/test_light.py +++ b/tests/components/led_infrared/test_light.py @@ -4,6 +4,8 @@ from collections.abc import Generator from unittest.mock import patch from infrared_protocols.codes.generic.led import ( + BaseGenericLEDCode, + Generic10KeyCode, Generic13KeyCode, Generic24KeyCode, Generic40KeyCode, @@ -47,6 +49,7 @@ def light_only() -> Generator[None]: @pytest.mark.parametrize( "config_entry", [ + LEDIrDeviceType.GENERIC_10_KEY, LEDIrDeviceType.GENERIC_13_KEY, LEDIrDeviceType.GENERIC_24_KEY, LEDIrDeviceType.GENERIC_40_KEY, @@ -609,6 +612,30 @@ async def test_setup( {ATTR_EFFECT: "light_cyan"}, [Generic44KeyCode.ON, Generic44KeyCode.LIGHT_CYAN], ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + SERVICE_TURN_ON, + {}, + [Generic10KeyCode.ON], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + SERVICE_TURN_OFF, + {}, + [Generic10KeyCode.OFF], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + SERVICE_TURN_ON, + {ATTR_EFFECT: "candle"}, + [Generic10KeyCode.ON, Generic10KeyCode.CANDLE], + ), + ( + LEDIrDeviceType.GENERIC_10_KEY, + SERVICE_TURN_ON, + {ATTR_EFFECT: "light"}, + [Generic10KeyCode.ON, Generic10KeyCode.LIGHT], + ), ], ) @pytest.mark.usefixtures("infrared_codes") @@ -618,9 +645,7 @@ async def test_light_actions( device_type: LEDIrDeviceType, service: str, service_data: dict[str, str], - expected_codes: list[ - Generic13KeyCode | Generic24KeyCode | Generic40KeyCode | Generic44KeyCode - ], + expected_codes: list[BaseGenericLEDCode], ) -> None: """Test light actions.""" config_entry = MockConfigEntry(