mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add translatable states to SmartThings media source input (#139353)
Add translatable states to media source input
This commit is contained in:
parent
b964bc58be
commit
998757f09e
@ -67,6 +67,7 @@ class SmartThingsSensorEntityDescription(SensorEntityDescription):
|
|||||||
extra_state_attributes_fn: Callable[[Any], dict[str, Any]] | None = None
|
extra_state_attributes_fn: Callable[[Any], dict[str, Any]] | None = None
|
||||||
unique_id_separator: str = "."
|
unique_id_separator: str = "."
|
||||||
capability_ignore_list: list[set[Capability]] | None = None
|
capability_ignore_list: list[set[Capability]] | None = None
|
||||||
|
options_attribute: Attribute | None = None
|
||||||
|
|
||||||
|
|
||||||
CAPABILITY_TO_SENSORS: dict[
|
CAPABILITY_TO_SENSORS: dict[
|
||||||
@ -374,6 +375,9 @@ CAPABILITY_TO_SENSORS: dict[
|
|||||||
SmartThingsSensorEntityDescription(
|
SmartThingsSensorEntityDescription(
|
||||||
key=Attribute.INPUT_SOURCE,
|
key=Attribute.INPUT_SOURCE,
|
||||||
translation_key="media_input_source",
|
translation_key="media_input_source",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options_attribute=Attribute.SUPPORTED_INPUT_SOURCES,
|
||||||
|
value_fn=lambda value: value.lower(),
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -841,3 +845,13 @@ class SmartThingsSensor(SmartThingsEntity, SensorEntity):
|
|||||||
self.get_attribute_value(self.capability, self._attribute)
|
self.get_attribute_value(self.capability, self._attribute)
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def options(self) -> list[str] | None:
|
||||||
|
"""Return the options for this sensor."""
|
||||||
|
if self.entity_description.options_attribute:
|
||||||
|
options = self.get_attribute_value(
|
||||||
|
self.capability, self.entity_description.options_attribute
|
||||||
|
)
|
||||||
|
return [option.lower() for option in options]
|
||||||
|
return super().options
|
||||||
|
@ -128,7 +128,34 @@
|
|||||||
"name": "Infrared level"
|
"name": "Infrared level"
|
||||||
},
|
},
|
||||||
"media_input_source": {
|
"media_input_source": {
|
||||||
"name": "Media input source"
|
"name": "Media input source",
|
||||||
|
"state": {
|
||||||
|
"am": "AM",
|
||||||
|
"fm": "FM",
|
||||||
|
"cd": "CD",
|
||||||
|
"hdmi": "HDMI",
|
||||||
|
"hdmi1": "HDMI 1",
|
||||||
|
"hdmi2": "HDMI 2",
|
||||||
|
"hdmi3": "HDMI 3",
|
||||||
|
"hdmi4": "HDMI 4",
|
||||||
|
"hdmi5": "HDMI 5",
|
||||||
|
"hdmi6": "HDMI 6",
|
||||||
|
"digitaltv": "Digital TV",
|
||||||
|
"usb": "USB",
|
||||||
|
"youtube": "YouTube",
|
||||||
|
"aux": "AUX",
|
||||||
|
"bluetooth": "Bluetooth",
|
||||||
|
"digital": "Digital",
|
||||||
|
"melon": "Melon",
|
||||||
|
"wifi": "Wi-Fi",
|
||||||
|
"network": "Network",
|
||||||
|
"optical": "Optical",
|
||||||
|
"coaxial": "Coaxial",
|
||||||
|
"analog1": "Analog 1",
|
||||||
|
"analog2": "Analog 2",
|
||||||
|
"analog3": "Analog 3",
|
||||||
|
"phono": "Phono"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"media_playback_repeat": {
|
"media_playback_repeat": {
|
||||||
"name": "Media playback repeat"
|
"name": "Media playback repeat"
|
||||||
|
@ -4483,7 +4483,14 @@
|
|||||||
'aliases': set({
|
'aliases': set({
|
||||||
}),
|
}),
|
||||||
'area_id': None,
|
'area_id': None,
|
||||||
'capabilities': None,
|
'capabilities': dict({
|
||||||
|
'options': list([
|
||||||
|
'digitaltv',
|
||||||
|
'hdmi1',
|
||||||
|
'hdmi4',
|
||||||
|
'hdmi4',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
'config_entry_id': <ANY>,
|
'config_entry_id': <ANY>,
|
||||||
'config_subentry_id': <ANY>,
|
'config_subentry_id': <ANY>,
|
||||||
'device_class': None,
|
'device_class': None,
|
||||||
@ -4501,7 +4508,7 @@
|
|||||||
'name': None,
|
'name': None,
|
||||||
'options': dict({
|
'options': dict({
|
||||||
}),
|
}),
|
||||||
'original_device_class': None,
|
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
|
||||||
'original_icon': None,
|
'original_icon': None,
|
||||||
'original_name': 'Media input source',
|
'original_name': 'Media input source',
|
||||||
'platform': 'smartthings',
|
'platform': 'smartthings',
|
||||||
@ -4515,14 +4522,21 @@
|
|||||||
# name: test_all_entities[vd_stv_2017_k][sensor.tv_samsung_8_series_49_media_input_source-state]
|
# name: test_all_entities[vd_stv_2017_k][sensor.tv_samsung_8_series_49_media_input_source-state]
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
|
'device_class': 'enum',
|
||||||
'friendly_name': '[TV] Samsung 8 Series (49) Media input source',
|
'friendly_name': '[TV] Samsung 8 Series (49) Media input source',
|
||||||
|
'options': list([
|
||||||
|
'digitaltv',
|
||||||
|
'hdmi1',
|
||||||
|
'hdmi4',
|
||||||
|
'hdmi4',
|
||||||
|
]),
|
||||||
}),
|
}),
|
||||||
'context': <ANY>,
|
'context': <ANY>,
|
||||||
'entity_id': 'sensor.tv_samsung_8_series_49_media_input_source',
|
'entity_id': 'sensor.tv_samsung_8_series_49_media_input_source',
|
||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': 'HDMI1',
|
'state': 'hdmi1',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_all_entities[vd_stv_2017_k][sensor.tv_samsung_8_series_49_media_playback_status-entry]
|
# name: test_all_entities[vd_stv_2017_k][sensor.tv_samsung_8_series_49_media_playback_status-entry]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user