Add USB-PD Mode select entity to IronOS integration (#134901)
Add USB-PD Mode select entitypull/135292/head
parent
59d61104d1
commit
6fd0760f25
|
@ -102,6 +102,9 @@
|
|||
},
|
||||
"logo_duration": {
|
||||
"default": "mdi:clock-digital"
|
||||
},
|
||||
"usb_pd_mode": {
|
||||
"default": "mdi:meter-electric-outline"
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
|
|
|
@ -19,6 +19,7 @@ from pynecil import (
|
|||
ScrollSpeed,
|
||||
SettingsDataResponse,
|
||||
TempUnit,
|
||||
USBPDMode,
|
||||
)
|
||||
|
||||
from homeassistant.components.select import SelectEntity, SelectEntityDescription
|
||||
|
@ -55,6 +56,7 @@ class PinecilSelect(StrEnum):
|
|||
DESC_SCROLL_SPEED = "desc_scroll_speed"
|
||||
LOCKING_MODE = "locking_mode"
|
||||
LOGO_DURATION = "logo_duration"
|
||||
USB_PD_MODE = "usb_pd_mode"
|
||||
|
||||
|
||||
def enum_to_str(enum: Enum | None) -> str | None:
|
||||
|
@ -140,6 +142,16 @@ PINECIL_SELECT_DESCRIPTIONS: tuple[IronOSSelectEntityDescription, ...] = (
|
|||
entity_category=EntityCategory.CONFIG,
|
||||
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",
|
||||
"loop": "Loop"
|
||||
}
|
||||
},
|
||||
"usb_pd_mode": {
|
||||
"name": "Power Delivery 3.1 EPR",
|
||||
"state": {
|
||||
"off": "[%key:common::state::off%]",
|
||||
"on": "[%key:common::state::on%]"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
|
|
|
@ -237,6 +237,61 @@
|
|||
'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]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
|
|
@ -16,6 +16,7 @@ from pynecil import (
|
|||
ScreenOrientationMode,
|
||||
ScrollSpeed,
|
||||
TempUnit,
|
||||
USBPDMode,
|
||||
)
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
@ -105,6 +106,11 @@ async def test_state(
|
|||
"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")
|
||||
|
|
Loading…
Reference in New Issue