Remove deprecated WLED binary sensor platform (#119984)
parent
5ee418724b
commit
6c80f865f5
|
@ -10,7 +10,6 @@ from .const import LOGGER
|
|||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
|
||||
PLATFORMS = (
|
||||
Platform.BINARY_SENSOR,
|
||||
Platform.BUTTON,
|
||||
Platform.LIGHT,
|
||||
Platform.NUMBER,
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
"""Support for WLED binary sensor."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import WLEDConfigEntry
|
||||
from .coordinator import WLEDDataUpdateCoordinator
|
||||
from .entity import WLEDEntity
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: WLEDConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up a WLED binary sensor based on a config entry."""
|
||||
async_add_entities(
|
||||
[
|
||||
WLEDUpdateBinarySensor(entry.runtime_data),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class WLEDUpdateBinarySensor(WLEDEntity, BinarySensorEntity):
|
||||
"""Defines a WLED firmware binary sensor."""
|
||||
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
_attr_device_class = BinarySensorDeviceClass.UPDATE
|
||||
_attr_translation_key = "firmware"
|
||||
|
||||
# Disabled by default, as this entity is deprecated.
|
||||
_attr_entity_registry_enabled_default = False
|
||||
|
||||
def __init__(self, coordinator: WLEDDataUpdateCoordinator) -> None:
|
||||
"""Initialize the button entity."""
|
||||
super().__init__(coordinator=coordinator)
|
||||
self._attr_unique_id = f"{coordinator.data.info.mac_address}_update"
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return the state of the sensor."""
|
||||
current = self.coordinator.data.info.version
|
||||
beta = self.coordinator.data.info.version_latest_beta
|
||||
stable = self.coordinator.data.info.version_latest_stable
|
||||
|
||||
return current is not None and (
|
||||
(stable is not None and stable > current)
|
||||
or (
|
||||
beta is not None
|
||||
and (current.alpha or current.beta or current.release_candidate)
|
||||
and beta > current
|
||||
)
|
||||
)
|
|
@ -1,82 +0,0 @@
|
|||
# serializer version: 1
|
||||
# name: test_update_available
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'update',
|
||||
'friendly_name': 'WLED RGB Light Firmware',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'binary_sensor.wled_rgb_light_firmware',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_update_available.1
|
||||
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.wled_rgb_light_firmware',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <BinarySensorDeviceClass.UPDATE: 'update'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Firmware',
|
||||
'platform': 'wled',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'firmware',
|
||||
'unique_id': 'aabbccddeeff_update',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_update_available.2
|
||||
DeviceRegistryEntrySnapshot({
|
||||
'area_id': None,
|
||||
'config_entries': <ANY>,
|
||||
'configuration_url': 'http://127.0.0.1',
|
||||
'connections': set({
|
||||
tuple(
|
||||
'mac',
|
||||
'aa:bb:cc:dd:ee:ff',
|
||||
),
|
||||
}),
|
||||
'disabled_by': None,
|
||||
'entry_type': None,
|
||||
'hw_version': 'esp8266',
|
||||
'id': <ANY>,
|
||||
'identifiers': set({
|
||||
tuple(
|
||||
'wled',
|
||||
'aabbccddeeff',
|
||||
),
|
||||
}),
|
||||
'is_new': False,
|
||||
'labels': set({
|
||||
}),
|
||||
'manufacturer': 'WLED',
|
||||
'model': 'DIY light',
|
||||
'name': 'WLED RGB Light',
|
||||
'name_by_user': None,
|
||||
'serial_number': None,
|
||||
'suggested_area': None,
|
||||
'sw_version': '0.8.5',
|
||||
'via_device_id': None,
|
||||
})
|
||||
# ---
|
|
@ -1,48 +0,0 @@
|
|||
"""Tests for the WLED binary sensor platform."""
|
||||
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import STATE_OFF
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("init_integration")
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_update_available(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test the firmware update binary sensor."""
|
||||
assert (state := hass.states.get("binary_sensor.wled_rgb_light_firmware"))
|
||||
assert state == snapshot
|
||||
|
||||
assert (entity_entry := entity_registry.async_get(state.entity_id))
|
||||
assert entity_entry == snapshot
|
||||
|
||||
assert entity_entry.device_id
|
||||
assert (device_entry := device_registry.async_get(entity_entry.device_id))
|
||||
assert device_entry == snapshot
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
@pytest.mark.parametrize("device_fixture", ["rgb_websocket"])
|
||||
async def test_no_update_available(hass: HomeAssistant) -> None:
|
||||
"""Test the update binary sensor. There is no update available."""
|
||||
assert (state := hass.states.get("binary_sensor.wled_websocket_firmware"))
|
||||
assert state.state == STATE_OFF
|
||||
|
||||
|
||||
async def test_disabled_by_default(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry
|
||||
) -> None:
|
||||
"""Test that the binary update sensor is disabled by default."""
|
||||
assert not hass.states.get("binary_sensor.wled_rgb_light_firmware")
|
||||
|
||||
assert (entry := entity_registry.async_get("binary_sensor.wled_rgb_light_firmware"))
|
||||
assert entry.disabled
|
||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
Loading…
Reference in New Issue