diff --git a/homeassistant/components/kiosker/binary_sensor.py b/homeassistant/components/kiosker/binary_sensor.py index 4782e76c9bfc..904de63d2348 100644 --- a/homeassistant/components/kiosker/binary_sensor.py +++ b/homeassistant/components/kiosker/binary_sensor.py @@ -23,7 +23,7 @@ PARALLEL_UPDATES = 0 class KioskerBinarySensorEntityDescription(BinarySensorEntityDescription): """Describes Kiosker binary sensor entity.""" - value_fn: Callable[[KioskerData], bool] + value_fn: Callable[[KioskerData], bool | None] BINARY_SENSORS: tuple[KioskerBinarySensorEntityDescription, ...] = ( @@ -44,6 +44,12 @@ BINARY_SENSORS: tuple[KioskerBinarySensorEntityDescription, ...] = ( (x.status.battery_state or "").casefold() in ("charging", "fully charged") ), ), + KioskerBinarySensorEntityDescription( + key="blackoutDismissible", + translation_key="blackout_dismissible", + entity_registry_enabled_default=False, + value_fn=lambda x: x.blackout.dismissible if x.blackout else None, + ), ) diff --git a/homeassistant/components/kiosker/icons.json b/homeassistant/components/kiosker/icons.json index d2fd470ea71b..fac5d431d966 100644 --- a/homeassistant/components/kiosker/icons.json +++ b/homeassistant/components/kiosker/icons.json @@ -1,6 +1,12 @@ { "entity": { "binary_sensor": { + "blackout_dismissible": { + "default": "mdi:lock", + "state": { + "on": "mdi:lock-open-outline" + } + }, "blackout_state": { "default": "mdi:monitor", "state": { diff --git a/homeassistant/components/kiosker/strings.json b/homeassistant/components/kiosker/strings.json index beabd72e9dd5..ba50643e11fd 100644 --- a/homeassistant/components/kiosker/strings.json +++ b/homeassistant/components/kiosker/strings.json @@ -49,6 +49,9 @@ }, "entity": { "binary_sensor": { + "blackout_dismissible": { + "name": "Blackout dismissible" + }, "blackout_state": { "name": "Blackout" }, diff --git a/tests/components/kiosker/snapshots/test_binary_sensor.ambr b/tests/components/kiosker/snapshots/test_binary_sensor.ambr index 5281a09e6371..f53f13e14ccc 100644 --- a/tests/components/kiosker/snapshots/test_binary_sensor.ambr +++ b/tests/components/kiosker/snapshots/test_binary_sensor.ambr @@ -49,6 +49,56 @@ 'state': 'on', }) # --- +# name: test_all_entities[binary_sensor.kiosker_a98be1ce_blackout_dismissible-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.kiosker_a98be1ce_blackout_dismissible', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Blackout dismissible', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Blackout dismissible', + 'platform': 'kiosker', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'blackout_dismissible', + 'unique_id': 'A98BE1CE-5FE7-4A8D-B2C3-123456789ABC_blackoutDismissible', + 'unit_of_measurement': None, + }) +# --- +# name: test_all_entities[binary_sensor.kiosker_a98be1ce_blackout_dismissible-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Kiosker A98BE1CE Blackout dismissible', + }), + 'context': , + 'entity_id': 'binary_sensor.kiosker_a98be1ce_blackout_dismissible', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- # name: test_all_entities[binary_sensor.kiosker_a98be1ce_charging-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/kiosker/test_binary_sensor.py b/tests/components/kiosker/test_binary_sensor.py index 820ad148eda7..08c71cee1546 100644 --- a/tests/components/kiosker/test_binary_sensor.py +++ b/tests/components/kiosker/test_binary_sensor.py @@ -3,6 +3,7 @@ from types import SimpleNamespace from unittest.mock import MagicMock, patch +import pytest from syrupy.assertion import SnapshotAssertion from homeassistant.const import Platform @@ -14,6 +15,7 @@ from . import setup_integration from tests.common import MockConfigEntry, snapshot_platform +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_all_entities( hass: HomeAssistant, snapshot: SnapshotAssertion, @@ -22,7 +24,9 @@ async def test_all_entities( entity_registry: er.EntityRegistry, ) -> None: """Test all entities.""" - mock_kiosker_api.blackout_get.return_value = SimpleNamespace(visible=True) + mock_kiosker_api.blackout_get.return_value = SimpleNamespace( + visible=True, dismissible=True + ) mock_kiosker_api.screensaver_get_state.return_value = SimpleNamespace(visible=False) with patch("homeassistant.components.kiosker._PLATFORMS", [Platform.BINARY_SENSOR]):