Add `List access` sensor to Bring integration (#126844)

pull/129166/head
Manu 2024-10-25 17:20:31 +02:00 committed by GitHub
parent a95a542148
commit 39a0c0d96e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 134 additions and 0 deletions

View File

@ -12,6 +12,12 @@
},
"list_language": {
"default": "mdi:earth"
},
"list_access": {
"default": "mdi:account-lock",
"state": {
"shared": "mdi:account-group"
}
}
},
"todo": {

View File

@ -40,6 +40,7 @@ class BringSensor(StrEnum):
CONVENIENT = "convenient"
DISCOUNTED = "discounted"
LIST_LANGUAGE = "list_language"
LIST_ACCESS = "list_access"
SENSOR_DESCRIPTIONS: tuple[BringSensorEntityDescription, ...] = (
@ -73,6 +74,14 @@ SENSOR_DESCRIPTIONS: tuple[BringSensorEntityDescription, ...] = (
options=[x.lower() for x in BRING_SUPPORTED_LOCALES],
device_class=SensorDeviceClass.ENUM,
),
BringSensorEntityDescription(
key=BringSensor.LIST_ACCESS,
translation_key=BringSensor.LIST_ACCESS,
value_fn=lambda lst, _: lst["status"].lower(),
entity_category=EntityCategory.DIAGNOSTIC,
options=["registered", "shared"],
device_class=SensorDeviceClass.ENUM,
),
)

View File

@ -61,6 +61,13 @@
"sv-se": "Sweden",
"tr-tr": "Türkiye"
}
},
"list_access": {
"name": "List access",
"state": {
"registered": "Private",
"shared": "Shared"
}
}
}
},

View File

@ -46,6 +46,62 @@
'state': '2',
})
# ---
# name: test_setup[sensor.baumarkt_list_access-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'registered',
'shared',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.baumarkt_list_access',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'original_icon': None,
'original_name': 'List access',
'platform': 'bring',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': <BringSensor.LIST_ACCESS: 'list_access'>,
'unique_id': '00000000-00000000-00000000-00000000_b4776778-7f6c-496e-951b-92a35d3db0dd_list_access',
'unit_of_measurement': None,
})
# ---
# name: test_setup[sensor.baumarkt_list_access-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'enum',
'friendly_name': 'Baumarkt List access',
'options': list([
'registered',
'shared',
]),
}),
'context': <ANY>,
'entity_id': 'sensor.baumarkt_list_access',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'registered',
})
# ---
# name: test_setup[sensor.baumarkt_on_occasion-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -279,6 +335,62 @@
'state': '2',
})
# ---
# name: test_setup[sensor.einkauf_list_access-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'registered',
'shared',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'sensor.einkauf_list_access',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
'original_icon': None,
'original_name': 'List access',
'platform': 'bring',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': <BringSensor.LIST_ACCESS: 'list_access'>,
'unique_id': '00000000-00000000-00000000-00000000_e542eef6-dba7-4c31-a52c-29e6ab9d83a5_list_access',
'unit_of_measurement': None,
})
# ---
# name: test_setup[sensor.einkauf_list_access-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'enum',
'friendly_name': 'Einkauf List access',
'options': list([
'registered',
'shared',
]),
}),
'context': <ANY>,
'entity_id': 'sensor.einkauf_list_access',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'registered',
})
# ---
# name: test_setup[sensor.einkauf_on_occasion-entry]
EntityRegistryEntrySnapshot({
'aliases': set({