mirror of
https://github.com/home-assistant/core.git
synced 2026-09-30 18:16:46 +01:00
Add Kiosker blackout details binary sensor (#173303)
This commit is contained in:
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
{
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"blackout_dismissible": {
|
||||
"default": "mdi:lock",
|
||||
"state": {
|
||||
"on": "mdi:lock-open-outline"
|
||||
}
|
||||
},
|
||||
"blackout_state": {
|
||||
"default": "mdi:monitor",
|
||||
"state": {
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"blackout_dismissible": {
|
||||
"name": "Blackout dismissible"
|
||||
},
|
||||
"blackout_state": {
|
||||
"name": "Blackout"
|
||||
},
|
||||
|
||||
@@ -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': <ANY>,
|
||||
'config_subentry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'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': <ANY>,
|
||||
'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': <ANY>,
|
||||
'entity_id': 'binary_sensor.kiosker_a98be1ce_blackout_dismissible',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[binary_sensor.kiosker_a98be1ce_charging-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': list([
|
||||
|
||||
@@ -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]):
|
||||
|
||||
Reference in New Issue
Block a user