Add uncalibrated sensor for tedee (#122594)

* add uncalibrated sensor

* change off icon
This commit is contained in:
Josef Zweck 2024-07-25 15:42:10 +02:00 committed by GitHub
parent e6d0bc7d5d
commit f1b933ae0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 70 additions and 6 deletions

View File

@ -47,6 +47,14 @@ ENTITIES: tuple[TedeeBinarySensorEntityDescription, ...] = (
is_on_fn=lambda lock: lock.is_enabled_pullspring,
entity_category=EntityCategory.DIAGNOSTIC,
),
TedeeBinarySensorEntityDescription(
key="uncalibrated",
translation_key="uncalibrated",
is_on_fn=lambda lock: lock.state == TedeeLockState.UNCALIBRATED,
device_class=BinarySensorDeviceClass.PROBLEM,
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
)

View File

@ -1,5 +1,13 @@
{
"entity": {
"binary_sensor": {
"uncalibrated": {
"state": {
"on": "mdi:sync-alert",
"off": "mdi:sync"
}
}
},
"sensor": {
"pullspring_duration": {
"default": "mdi:timer-lock-open"

View File

@ -53,6 +53,9 @@
},
"semi_locked": {
"name": "Semi locked"
},
"uncalibrated": {
"name": "Lock uncalibrated"
}
},
"sensor": {

View File

@ -32,6 +32,39 @@
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[entry-lock_uncalibrated]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'binary_sensor.lock_1a2b_lock_uncalibrated',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <BinarySensorDeviceClass.PROBLEM: 'problem'>,
'original_icon': None,
'original_name': 'Lock uncalibrated',
'platform': 'tedee',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'uncalibrated',
'unique_id': '12345-uncalibrated',
'unit_of_measurement': None,
})
# ---
# name: test_binary_sensors[entry-pullspring_enabled]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -112,6 +145,20 @@
'state': 'off',
})
# ---
# name: test_binary_sensors[state-lock_uncalibrated]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'problem',
'friendly_name': 'Lock-1A2B Lock uncalibrated',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.lock_1a2b_lock_uncalibrated',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_binary_sensors[state-pullspring_enabled]
StateSnapshot({
'attributes': ReadOnlyDict({

View File

@ -15,20 +15,17 @@ from tests.common import async_fire_time_changed
pytestmark = pytest.mark.usefixtures("init_integration")
BINARY_SENSORS = (
"charging",
"semi_locked",
"pullspring_enabled",
)
BINARY_SENSORS = ("charging", "semi_locked", "pullspring_enabled", "lock_uncalibrated")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensors(
hass: HomeAssistant,
mock_tedee: MagicMock,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test tedee battery charging sensor."""
"""Test tedee binary sensor."""
for key in BINARY_SENSORS:
state = hass.states.get(f"binary_sensor.lock_1a2b_{key}")
assert state
@ -39,6 +36,7 @@ async def test_binary_sensors(
assert entry == snapshot(name=f"entry-{key}")
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_new_binary_sensors(
hass: HomeAssistant,
mock_tedee: MagicMock,