mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Add more button entities to LED Infrared (#177400)
This commit is contained in:
@@ -16,6 +16,32 @@ PARALLEL_UPDATES = 1
|
||||
SUPPORTED_BUTTONS = {
|
||||
LEDIrDeviceType.GENERIC_24_KEY: ["brightness_up", "brightness_down"],
|
||||
LEDIrDeviceType.GENERIC_13_KEY: ["brightness_up", "brightness_down", "timer"],
|
||||
LEDIrDeviceType.GENERIC_40_KEY: [
|
||||
"brightness_up",
|
||||
"brightness_down",
|
||||
"white_brightness_up",
|
||||
"white_brightness_down",
|
||||
"white_on",
|
||||
"white_off",
|
||||
"white_brightness_25",
|
||||
"white_brightness_50",
|
||||
"white_brightness_75",
|
||||
"white_brightness_100",
|
||||
"quick",
|
||||
"slow",
|
||||
],
|
||||
LEDIrDeviceType.GENERIC_44_KEY: [
|
||||
"brightness_up",
|
||||
"brightness_down",
|
||||
"red_up",
|
||||
"green_up",
|
||||
"blue_up",
|
||||
"red_down",
|
||||
"green_down",
|
||||
"blue_down",
|
||||
"quick",
|
||||
"slow",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,62 @@
|
||||
{
|
||||
"entity": {
|
||||
"button": {
|
||||
"blue_down": {
|
||||
"default": "mdi:alpha-b-circle-outline"
|
||||
},
|
||||
"blue_up": {
|
||||
"default": "mdi:alpha-b-circle"
|
||||
},
|
||||
"brightness_down": {
|
||||
"default": "mdi:brightness-5"
|
||||
},
|
||||
"brightness_up": {
|
||||
"default": "mdi:brightness-7"
|
||||
},
|
||||
"green_down": {
|
||||
"default": "mdi:alpha-g-circle-outline"
|
||||
},
|
||||
"green_up": {
|
||||
"default": "mdi:alpha-g-circle"
|
||||
},
|
||||
"quick": {
|
||||
"default": "mdi:speedometer"
|
||||
},
|
||||
"red_down": {
|
||||
"default": "mdi:alpha-r-circle-outline"
|
||||
},
|
||||
"red_up": {
|
||||
"default": "mdi:alpha-r-circle"
|
||||
},
|
||||
"slow": {
|
||||
"default": "mdi:speedometer-slow"
|
||||
},
|
||||
"timer": {
|
||||
"default": "mdi:timer"
|
||||
},
|
||||
"white_brightness_100": {
|
||||
"default": "mdi:lightbulb-on"
|
||||
},
|
||||
"white_brightness_25": {
|
||||
"default": "mdi:lightbulb-on-30"
|
||||
},
|
||||
"white_brightness_50": {
|
||||
"default": "mdi:lightbulb-on-50"
|
||||
},
|
||||
"white_brightness_75": {
|
||||
"default": "mdi:lightbulb-on-80"
|
||||
},
|
||||
"white_brightness_down": {
|
||||
"default": "mdi:brightness-5"
|
||||
},
|
||||
"white_brightness_up": {
|
||||
"default": "mdi:brightness-7"
|
||||
},
|
||||
"white_off": {
|
||||
"default": "mdi:power-off"
|
||||
},
|
||||
"white_on": {
|
||||
"default": "mdi:power-on"
|
||||
}
|
||||
},
|
||||
"event": {
|
||||
|
||||
@@ -38,14 +38,62 @@
|
||||
},
|
||||
"entity": {
|
||||
"button": {
|
||||
"blue_down": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::blue_down%]"
|
||||
},
|
||||
"blue_up": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::blue_up%]"
|
||||
},
|
||||
"brightness_down": {
|
||||
"name": "Brightness down"
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::brightness_down%]"
|
||||
},
|
||||
"brightness_up": {
|
||||
"name": "Brightness up"
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::brightness_up%]"
|
||||
},
|
||||
"green_down": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::green_down%]"
|
||||
},
|
||||
"green_up": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::green_up%]"
|
||||
},
|
||||
"quick": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::quick%]"
|
||||
},
|
||||
"red_down": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::red_down%]"
|
||||
},
|
||||
"red_up": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::red_up%]"
|
||||
},
|
||||
"slow": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::slow%]"
|
||||
},
|
||||
"timer": {
|
||||
"name": "Timer"
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::timer%]"
|
||||
},
|
||||
"white_brightness_100": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_brightness_100%]"
|
||||
},
|
||||
"white_brightness_25": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_brightness_25%]"
|
||||
},
|
||||
"white_brightness_50": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_brightness_50%]"
|
||||
},
|
||||
"white_brightness_75": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_brightness_75%]"
|
||||
},
|
||||
"white_brightness_down": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_brightness_down%]"
|
||||
},
|
||||
"white_brightness_up": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_brightness_up%]"
|
||||
},
|
||||
"white_off": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_off%]"
|
||||
},
|
||||
"white_on": {
|
||||
"name": "[%key:component::led_infrared::entity::event::received_command::state_attributes::event_type::state::white_on%]"
|
||||
}
|
||||
},
|
||||
"event": {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,12 @@
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import patch
|
||||
|
||||
from infrared_protocols.codes.generic.led import Generic13KeyCode, Generic24KeyCode
|
||||
from infrared_protocols.codes.generic.led import (
|
||||
Generic13KeyCode,
|
||||
Generic24KeyCode,
|
||||
Generic40KeyCode,
|
||||
Generic44KeyCode,
|
||||
)
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
@@ -34,6 +39,16 @@ def button_only() -> Generator[None]:
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config_entry",
|
||||
[
|
||||
LEDIrDeviceType.GENERIC_13_KEY,
|
||||
LEDIrDeviceType.GENERIC_24_KEY,
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
@pytest.mark.usefixtures("mock_infrared_emitter_entity")
|
||||
async def test_setup(
|
||||
hass: HomeAssistant,
|
||||
@@ -80,6 +95,116 @@ async def test_setup(
|
||||
"timer",
|
||||
[Generic13KeyCode.TIMER],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"brightness_up",
|
||||
[Generic40KeyCode.BRIGHTNESS_UP],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"brightness_down",
|
||||
[Generic40KeyCode.BRIGHTNESS_DOWN],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_brightness_up",
|
||||
[Generic40KeyCode.WHITE_BRIGHTNESS_UP],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_brightness_down",
|
||||
[Generic40KeyCode.WHITE_BRIGHTNESS_DOWN],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_on",
|
||||
[Generic40KeyCode.WHITE_ON],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_off",
|
||||
[Generic40KeyCode.WHITE_OFF],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_brightness_25",
|
||||
[Generic40KeyCode.WHITE_BRIGHTNESS_25],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_brightness_50",
|
||||
[Generic40KeyCode.WHITE_BRIGHTNESS_50],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_brightness_75",
|
||||
[Generic40KeyCode.WHITE_BRIGHTNESS_75],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"white_brightness_100",
|
||||
[Generic40KeyCode.WHITE_BRIGHTNESS_100],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"quick",
|
||||
[Generic40KeyCode.QUICK],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_40_KEY,
|
||||
"slow",
|
||||
[Generic40KeyCode.SLOW],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"brightness_up",
|
||||
[Generic44KeyCode.BRIGHTNESS_UP],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"brightness_down",
|
||||
[Generic44KeyCode.BRIGHTNESS_DOWN],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"red_up",
|
||||
[Generic44KeyCode.RED_UP],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"green_up",
|
||||
[Generic44KeyCode.GREEN_UP],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"blue_up",
|
||||
[Generic44KeyCode.BLUE_UP],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"red_down",
|
||||
[Generic44KeyCode.RED_DOWN],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"green_down",
|
||||
[Generic44KeyCode.GREEN_DOWN],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"blue_down",
|
||||
[Generic44KeyCode.BLUE_DOWN],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"quick",
|
||||
[Generic44KeyCode.QUICK],
|
||||
),
|
||||
(
|
||||
LEDIrDeviceType.GENERIC_44_KEY,
|
||||
"slow",
|
||||
[Generic44KeyCode.SLOW],
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("infrared_codes")
|
||||
@@ -89,7 +214,9 @@ async def test_button_press(
|
||||
entity_registry: er.EntityRegistry,
|
||||
device_type: LEDIrDeviceType,
|
||||
key: str,
|
||||
expected_codes: list[Generic24KeyCode | Generic13KeyCode],
|
||||
expected_codes: list[
|
||||
Generic24KeyCode | Generic13KeyCode | Generic40KeyCode | Generic44KeyCode
|
||||
],
|
||||
) -> None:
|
||||
"""Test button press action."""
|
||||
config_entry = MockConfigEntry(
|
||||
|
||||
Reference in New Issue
Block a user