* squeezebox add binary sensor + coordinator
* squeezebox add connected via for media_player
* squeezebox add Player type for player
* Add more type info
* Fix linter errors
* squeezebox use our own status entity
* squeezebox rework device handling based on freedback
* Fix device creation
* squeezebox rework coordinator error handling
* Fix lint type error
* Correct spelling
* Correct spelling
* remove large comments
* insert small comment
* add translation support
* Simply sensor
* clean update function, minimise comments to the useful bits
* Fix after testing
* Update homeassistant/components/squeezebox/entity.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
* move data prep out of Device assign for clarity
* stop being a generic api
* Humans need to read the sensors...
* ruff format
* Humans need to read the sensors...
* Revert "ruff format"
This reverts commit 8fcb8143e7
.
* ruff format
* Humans need to read the sensors...
* errors after testing
* infered
* drop context
* cutdown coordinator for the binary sensors
* add tests for binary sensors
* Fix import
* add some basic media_player tests
* Fix spelling and file headers
* Fix spelling
* remove uuid and use service device cat
* use diag device
* assert execpted value
* ruff format
* Update homeassistant/components/squeezebox/__init__.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
* Simplify T/F
* Fix file header
* remove redudant check
* remove player tests from this commit
* Fix formatting
* remove unused
* Fix function Type
* Fix Any to bool
* Fix browser tests
* Patch our squeebox componemt not the server in the lib
* ruff
---------
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
"""Binary sensor platform for Squeezebox integration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
|
|
from homeassistant.components.binary_sensor import (
|
|
BinarySensorDeviceClass,
|
|
BinarySensorEntity,
|
|
BinarySensorEntityDescription,
|
|
)
|
|
from homeassistant.const import EntityCategory
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|
|
|
from . import SqueezeboxConfigEntry
|
|
from .const import STATUS_SENSOR_NEEDSRESTART, STATUS_SENSOR_RESCAN
|
|
from .entity import LMSStatusEntity
|
|
|
|
SENSORS: tuple[BinarySensorEntityDescription, ...] = (
|
|
BinarySensorEntityDescription(
|
|
key=STATUS_SENSOR_RESCAN,
|
|
device_class=BinarySensorDeviceClass.RUNNING,
|
|
),
|
|
BinarySensorEntityDescription(
|
|
key=STATUS_SENSOR_NEEDSRESTART,
|
|
device_class=BinarySensorDeviceClass.UPDATE,
|
|
entity_category=EntityCategory.DIAGNOSTIC,
|
|
),
|
|
)
|
|
|
|
_LOGGER = logging.getLogger(__name__)
|
|
|
|
|
|
async def async_setup_entry(
|
|
hass: HomeAssistant,
|
|
entry: SqueezeboxConfigEntry,
|
|
async_add_entities: AddEntitiesCallback,
|
|
) -> None:
|
|
"""Platform setup using common elements."""
|
|
|
|
async_add_entities(
|
|
ServerStatusBinarySensor(entry.runtime_data.coordinator, description)
|
|
for description in SENSORS
|
|
)
|
|
|
|
|
|
class ServerStatusBinarySensor(LMSStatusEntity, BinarySensorEntity):
|
|
"""LMS Status based sensor from LMS via cooridnatior."""
|
|
|
|
@property
|
|
def is_on(self) -> bool:
|
|
"""LMS Status directly from coordinator data."""
|
|
return bool(self.coordinator.data[self.entity_description.key])
|