mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Set Sonos alarm and battery entity categories (#58340)
This commit is contained in:
parent
3672889609
commit
5a20d9fce3
@ -7,6 +7,7 @@ from homeassistant.components.binary_sensor import (
|
|||||||
DEVICE_CLASS_BATTERY_CHARGING,
|
DEVICE_CLASS_BATTERY_CHARGING,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
from .const import SONOS_CREATE_BATTERY
|
from .const import SONOS_CREATE_BATTERY
|
||||||
@ -31,6 +32,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
class SonosPowerEntity(SonosEntity, BinarySensorEntity):
|
class SonosPowerEntity(SonosEntity, BinarySensorEntity):
|
||||||
"""Representation of a Sonos power entity."""
|
"""Representation of a Sonos power entity."""
|
||||||
|
|
||||||
|
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return the unique ID of the sensor."""
|
"""Return the unique ID of the sensor."""
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorEntity
|
||||||
from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE
|
from homeassistant.const import (
|
||||||
|
DEVICE_CLASS_BATTERY,
|
||||||
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
|
PERCENTAGE,
|
||||||
|
)
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
|
|
||||||
from .const import SONOS_CREATE_BATTERY
|
from .const import SONOS_CREATE_BATTERY
|
||||||
@ -25,6 +29,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
class SonosBatteryEntity(SonosEntity, SensorEntity):
|
class SonosBatteryEntity(SonosEntity, SensorEntity):
|
||||||
"""Representation of a Sonos Battery entity."""
|
"""Representation of a Sonos Battery entity."""
|
||||||
|
|
||||||
|
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return the unique ID of the sensor."""
|
"""Return the unique ID of the sensor."""
|
||||||
|
@ -178,6 +178,8 @@ class SonosSwitchEntity(SonosEntity, SwitchEntity):
|
|||||||
class SonosAlarmEntity(SonosEntity, SwitchEntity):
|
class SonosAlarmEntity(SonosEntity, SwitchEntity):
|
||||||
"""Representation of a Sonos Alarm entity."""
|
"""Representation of a Sonos Alarm entity."""
|
||||||
|
|
||||||
|
_attr_entity_category = ENTITY_CATEGORY_CONFIG
|
||||||
|
|
||||||
def __init__(self, alarm_id: str, speaker: SonosSpeaker) -> None:
|
def __init__(self, alarm_id: str, speaker: SonosSpeaker) -> None:
|
||||||
"""Initialize the switch."""
|
"""Initialize the switch."""
|
||||||
super().__init__(speaker)
|
super().__init__(speaker)
|
||||||
@ -215,7 +217,7 @@ class SonosAlarmEntity(SonosEntity, SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
return "Sonos Alarm {} {} {}".format(
|
return "{} {} Alarm {}".format(
|
||||||
self.speaker.zone_name,
|
self.speaker.zone_name,
|
||||||
self.alarm.recurrence.title(),
|
self.alarm.recurrence.title(),
|
||||||
str(self.alarm.start_time)[0:5],
|
str(self.alarm.start_time)[0:5],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user