Skip to content

Commit 39d3231

Browse files
authored
Disable "last seen" Z-Wave entity by default (home-assistant#148987)
1 parent 57c0244 commit 39d3231

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

homeassistant/components/zwave_js/sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ class ZWaveJSStatisticsSensorEntityDescription(SensorEntityDescription):
558558
key="last_seen",
559559
translation_key="last_seen",
560560
device_class=SensorDeviceClass.TIMESTAMP,
561-
entity_registry_enabled_default=True,
561+
entity_registry_enabled_default=False,
562562
),
563563
]
564564

tests/components/zwave_js/test_init.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ async def test_on_node_added_not_ready(
514514
assert len(device.identifiers) == 1
515515

516516
entities = er.async_entries_for_device(entity_registry, device.id)
517-
# the only entities are the node status sensor, last_seen sensor, and ping button
518-
assert len(entities) == 3
517+
# the only entities are the node status sensor, and ping button
518+
assert len(entities) == 2
519519

520520

521521
async def test_existing_node_ready(
@@ -631,8 +631,8 @@ async def test_existing_node_not_ready(
631631
assert len(device.identifiers) == 1
632632

633633
entities = er.async_entries_for_device(entity_registry, device.id)
634-
# the only entities are the node status sensor, last_seen sensor, and ping button
635-
assert len(entities) == 3
634+
# the only entities are the node status sensor, and ping button
635+
assert len(entities) == 2
636636

637637

638638
async def test_existing_node_not_replaced_when_not_ready(

tests/components/zwave_js/test_sensor.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -869,15 +869,15 @@ async def test_statistics_sensors_migration(
869869
)
870870

871871

872-
async def test_statistics_sensors_no_last_seen(
872+
async def test_statistics_sensors(
873873
hass: HomeAssistant,
874874
entity_registry: er.EntityRegistry,
875875
zp3111,
876876
client,
877877
integration,
878878
caplog: pytest.LogCaptureFixture,
879879
) -> None:
880-
"""Test all statistics sensors but last seen which is enabled by default."""
880+
"""Test statistics sensors."""
881881

882882
for prefix, suffixes in (
883883
(CONTROLLER_STATISTICS_ENTITY_PREFIX, CONTROLLER_STATISTICS_SUFFIXES),
@@ -1029,7 +1029,16 @@ async def test_last_seen_statistics_sensors(
10291029
entity_id = f"{NODE_STATISTICS_ENTITY_PREFIX}last_seen"
10301030
entry = entity_registry.async_get(entity_id)
10311031
assert entry
1032-
assert not entry.disabled
1032+
assert entry.disabled
1033+
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
1034+
assert hass.states.get(entity_id) is None # disabled by default
1035+
1036+
entity_registry.async_update_entity(entity_id, disabled_by=None)
1037+
async_fire_time_changed(
1038+
hass,
1039+
dt_util.utcnow() + timedelta(seconds=RELOAD_AFTER_UPDATE_DELAY + 1),
1040+
)
1041+
await hass.async_block_till_done()
10331042

10341043
state = hass.states.get(entity_id)
10351044
assert state

0 commit comments

Comments
 (0)