mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Add USB-PD Mode select entity to IronOS integration (#134901)
Add USB-PD Mode select entity
This commit is contained in:
parent
59d61104d1
commit
6fd0760f25
@ -102,6 +102,9 @@
|
|||||||
},
|
},
|
||||||
"logo_duration": {
|
"logo_duration": {
|
||||||
"default": "mdi:clock-digital"
|
"default": "mdi:clock-digital"
|
||||||
|
},
|
||||||
|
"usb_pd_mode": {
|
||||||
|
"default": "mdi:meter-electric-outline"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
@ -19,6 +19,7 @@ from pynecil import (
|
|||||||
ScrollSpeed,
|
ScrollSpeed,
|
||||||
SettingsDataResponse,
|
SettingsDataResponse,
|
||||||
TempUnit,
|
TempUnit,
|
||||||
|
USBPDMode,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||||
@ -55,6 +56,7 @@ class PinecilSelect(StrEnum):
|
|||||||
DESC_SCROLL_SPEED = "desc_scroll_speed"
|
DESC_SCROLL_SPEED = "desc_scroll_speed"
|
||||||
LOCKING_MODE = "locking_mode"
|
LOCKING_MODE = "locking_mode"
|
||||||
LOGO_DURATION = "logo_duration"
|
LOGO_DURATION = "logo_duration"
|
||||||
|
USB_PD_MODE = "usb_pd_mode"
|
||||||
|
|
||||||
|
|
||||||
def enum_to_str(enum: Enum | None) -> str | None:
|
def enum_to_str(enum: Enum | None) -> str | None:
|
||||||
@ -140,6 +142,16 @@ PINECIL_SELECT_DESCRIPTIONS: tuple[IronOSSelectEntityDescription, ...] = (
|
|||||||
entity_category=EntityCategory.CONFIG,
|
entity_category=EntityCategory.CONFIG,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
|
IronOSSelectEntityDescription(
|
||||||
|
key=PinecilSelect.USB_PD_MODE,
|
||||||
|
translation_key=PinecilSelect.USB_PD_MODE,
|
||||||
|
characteristic=CharSetting.USB_PD_MODE,
|
||||||
|
value_fn=lambda x: enum_to_str(x.get("usb_pd_mode")),
|
||||||
|
raw_value_fn=lambda value: USBPDMode[value.upper()],
|
||||||
|
options=["off", "on"],
|
||||||
|
entity_category=EntityCategory.CONFIG,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,6 +166,13 @@
|
|||||||
"seconds_5": "5 second",
|
"seconds_5": "5 second",
|
||||||
"loop": "Loop"
|
"loop": "Loop"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"usb_pd_mode": {
|
||||||
|
"name": "Power Delivery 3.1 EPR",
|
||||||
|
"state": {
|
||||||
|
"off": "[%key:common::state::off%]",
|
||||||
|
"on": "[%key:common::state::on%]"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sensor": {
|
"sensor": {
|
||||||
|
@ -237,6 +237,61 @@
|
|||||||
'state': 'right_handed',
|
'state': 'right_handed',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
# name: test_state[select.pinecil_power_delivery_3_1_epr-entry]
|
||||||
|
EntityRegistryEntrySnapshot({
|
||||||
|
'aliases': set({
|
||||||
|
}),
|
||||||
|
'area_id': None,
|
||||||
|
'capabilities': dict({
|
||||||
|
'options': list([
|
||||||
|
'off',
|
||||||
|
'on',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'config_entry_id': <ANY>,
|
||||||
|
'device_class': None,
|
||||||
|
'device_id': <ANY>,
|
||||||
|
'disabled_by': None,
|
||||||
|
'domain': 'select',
|
||||||
|
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||||
|
'entity_id': 'select.pinecil_power_delivery_3_1_epr',
|
||||||
|
'has_entity_name': True,
|
||||||
|
'hidden_by': None,
|
||||||
|
'icon': None,
|
||||||
|
'id': <ANY>,
|
||||||
|
'labels': set({
|
||||||
|
}),
|
||||||
|
'name': None,
|
||||||
|
'options': dict({
|
||||||
|
}),
|
||||||
|
'original_device_class': None,
|
||||||
|
'original_icon': None,
|
||||||
|
'original_name': 'Power Delivery 3.1 EPR',
|
||||||
|
'platform': 'iron_os',
|
||||||
|
'previous_unique_id': None,
|
||||||
|
'supported_features': 0,
|
||||||
|
'translation_key': <PinecilSelect.USB_PD_MODE: 'usb_pd_mode'>,
|
||||||
|
'unique_id': 'c0:ff:ee:c0:ff:ee_usb_pd_mode',
|
||||||
|
'unit_of_measurement': None,
|
||||||
|
})
|
||||||
|
# ---
|
||||||
|
# name: test_state[select.pinecil_power_delivery_3_1_epr-state]
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'friendly_name': 'Pinecil Power Delivery 3.1 EPR',
|
||||||
|
'options': list([
|
||||||
|
'off',
|
||||||
|
'on',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'select.pinecil_power_delivery_3_1_epr',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'unknown',
|
||||||
|
})
|
||||||
|
# ---
|
||||||
# name: test_state[select.pinecil_power_source-entry]
|
# name: test_state[select.pinecil_power_source-entry]
|
||||||
EntityRegistryEntrySnapshot({
|
EntityRegistryEntrySnapshot({
|
||||||
'aliases': set({
|
'aliases': set({
|
||||||
|
@ -16,6 +16,7 @@ from pynecil import (
|
|||||||
ScreenOrientationMode,
|
ScreenOrientationMode,
|
||||||
ScrollSpeed,
|
ScrollSpeed,
|
||||||
TempUnit,
|
TempUnit,
|
||||||
|
USBPDMode,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
@ -105,6 +106,11 @@ async def test_state(
|
|||||||
"loop",
|
"loop",
|
||||||
(CharSetting.LOGO_DURATION, LogoDuration.LOOP),
|
(CharSetting.LOGO_DURATION, LogoDuration.LOOP),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"select.pinecil_power_delivery_3_1_epr",
|
||||||
|
"on",
|
||||||
|
(CharSetting.USB_PD_MODE, USBPDMode.ON),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default", "ble_device")
|
@pytest.mark.usefixtures("entity_registry_enabled_by_default", "ble_device")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user