mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
parent
cfe57f7e0c
commit
9ef4b2e5f5
@ -35,13 +35,12 @@ class RingBinarySensorEntityDescription(
|
|||||||
BINARY_SENSOR_TYPES: tuple[RingBinarySensorEntityDescription, ...] = (
|
BINARY_SENSOR_TYPES: tuple[RingBinarySensorEntityDescription, ...] = (
|
||||||
RingBinarySensorEntityDescription(
|
RingBinarySensorEntityDescription(
|
||||||
key="ding",
|
key="ding",
|
||||||
name="Ding",
|
translation_key="ding",
|
||||||
category=["doorbots", "authorized_doorbots"],
|
category=["doorbots", "authorized_doorbots"],
|
||||||
device_class=BinarySensorDeviceClass.OCCUPANCY,
|
device_class=BinarySensorDeviceClass.OCCUPANCY,
|
||||||
),
|
),
|
||||||
RingBinarySensorEntityDescription(
|
RingBinarySensorEntityDescription(
|
||||||
key="motion",
|
key="motion",
|
||||||
name="Motion",
|
|
||||||
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
device_class=BinarySensorDeviceClass.MOTION,
|
device_class=BinarySensorDeviceClass.MOTION,
|
||||||
),
|
),
|
||||||
@ -85,7 +84,6 @@ class RingBinarySensor(RingEntityMixin, BinarySensorEntity):
|
|||||||
super().__init__(config_entry_id, device)
|
super().__init__(config_entry_id, device)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._ring = ring
|
self._ring = ring
|
||||||
self._attr_name = f"{device.name} {description.name}"
|
|
||||||
self._attr_unique_id = f"{device.id}-{description.key}"
|
self._attr_unique_id = f"{device.id}-{description.key}"
|
||||||
self._update_alert()
|
self._update_alert()
|
||||||
|
|
||||||
|
@ -48,11 +48,12 @@ async def async_setup_entry(
|
|||||||
class RingCam(RingEntityMixin, Camera):
|
class RingCam(RingEntityMixin, Camera):
|
||||||
"""An implementation of a Ring Door Bell camera."""
|
"""An implementation of a Ring Door Bell camera."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
def __init__(self, config_entry_id, ffmpeg_manager, device):
|
def __init__(self, config_entry_id, ffmpeg_manager, device):
|
||||||
"""Initialize a Ring Door Bell camera."""
|
"""Initialize a Ring Door Bell camera."""
|
||||||
super().__init__(config_entry_id, device)
|
super().__init__(config_entry_id, device)
|
||||||
|
|
||||||
self._name = self._device.name
|
|
||||||
self._ffmpeg_manager = ffmpeg_manager
|
self._ffmpeg_manager = ffmpeg_manager
|
||||||
self._last_event = None
|
self._last_event = None
|
||||||
self._last_video_id = None
|
self._last_video_id = None
|
||||||
@ -90,11 +91,6 @@ class RingCam(RingEntityMixin, Camera):
|
|||||||
self._expires_at = dt_util.utcnow()
|
self._expires_at = dt_util.utcnow()
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Return the name of this camera."""
|
|
||||||
return self._name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
|
@ -10,6 +10,7 @@ class RingEntityMixin(Entity):
|
|||||||
|
|
||||||
_attr_attribution = ATTRIBUTION
|
_attr_attribution = ATTRIBUTION
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, config_entry_id, device):
|
def __init__(self, config_entry_id, device):
|
||||||
"""Initialize a sensor for Ring device."""
|
"""Initialize a sensor for Ring device."""
|
||||||
|
@ -50,6 +50,7 @@ class RingLight(RingEntityMixin, LightEntity):
|
|||||||
|
|
||||||
_attr_color_mode = ColorMode.ONOFF
|
_attr_color_mode = ColorMode.ONOFF
|
||||||
_attr_supported_color_modes = {ColorMode.ONOFF}
|
_attr_supported_color_modes = {ColorMode.ONOFF}
|
||||||
|
_attr_translation_key = "light"
|
||||||
|
|
||||||
def __init__(self, config_entry_id, device):
|
def __init__(self, config_entry_id, device):
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
@ -67,11 +68,6 @@ class RingLight(RingEntityMixin, LightEntity):
|
|||||||
self._light_on = self._device.lights == ON_STATE
|
self._light_on = self._device.lights == ON_STATE
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Name of the light."""
|
|
||||||
return f"{self._device.name} light"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
|
@ -13,7 +13,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||||||
from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.icon import icon_for_battery_level
|
|
||||||
|
|
||||||
from . import DOMAIN
|
from . import DOMAIN
|
||||||
from .entity import RingEntityMixin
|
from .entity import RingEntityMixin
|
||||||
@ -53,8 +52,6 @@ class RingSensor(RingEntityMixin, SensorEntity):
|
|||||||
"""Initialize a sensor for Ring device."""
|
"""Initialize a sensor for Ring device."""
|
||||||
super().__init__(config_entry_id, device)
|
super().__init__(config_entry_id, device)
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._extra = None
|
|
||||||
self._attr_name = f"{device.name} {description.name}"
|
|
||||||
self._attr_unique_id = f"{device.id}-{description.key}"
|
self._attr_unique_id = f"{device.id}-{description.key}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -67,18 +64,6 @@ class RingSensor(RingEntityMixin, SensorEntity):
|
|||||||
if sensor_type == "battery":
|
if sensor_type == "battery":
|
||||||
return self._device.battery_life
|
return self._device.battery_life
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Icon to use in the frontend, if any."""
|
|
||||||
if (
|
|
||||||
self.entity_description.key == "battery"
|
|
||||||
and self._device.battery_life is not None
|
|
||||||
):
|
|
||||||
return icon_for_battery_level(
|
|
||||||
battery_level=self._device.battery_life, charging=False
|
|
||||||
)
|
|
||||||
return self.entity_description.icon
|
|
||||||
|
|
||||||
|
|
||||||
class HealthDataRingSensor(RingSensor):
|
class HealthDataRingSensor(RingSensor):
|
||||||
"""Ring sensor that relies on health data."""
|
"""Ring sensor that relies on health data."""
|
||||||
@ -204,7 +189,6 @@ class RingSensorEntityDescription(SensorEntityDescription, RingRequiredKeysMixin
|
|||||||
SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
key="battery",
|
key="battery",
|
||||||
name="Battery",
|
|
||||||
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
device_class=SensorDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
@ -212,7 +196,7 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
key="last_activity",
|
key="last_activity",
|
||||||
name="Last Activity",
|
translation_key="last_activity",
|
||||||
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
icon="mdi:history",
|
icon="mdi:history",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
@ -220,7 +204,7 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
key="last_ding",
|
key="last_ding",
|
||||||
name="Last Ding",
|
translation_key="last_ding",
|
||||||
category=["doorbots", "authorized_doorbots"],
|
category=["doorbots", "authorized_doorbots"],
|
||||||
icon="mdi:history",
|
icon="mdi:history",
|
||||||
kind="ding",
|
kind="ding",
|
||||||
@ -229,7 +213,7 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
key="last_motion",
|
key="last_motion",
|
||||||
name="Last Motion",
|
translation_key="last_motion",
|
||||||
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
icon="mdi:history",
|
icon="mdi:history",
|
||||||
kind="motion",
|
kind="motion",
|
||||||
@ -238,21 +222,21 @@ SENSOR_TYPES: tuple[RingSensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
key="volume",
|
key="volume",
|
||||||
name="Volume",
|
translation_key="volume",
|
||||||
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
icon="mdi:bell-ring",
|
icon="mdi:bell-ring",
|
||||||
cls=RingSensor,
|
cls=RingSensor,
|
||||||
),
|
),
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
key="wifi_signal_category",
|
key="wifi_signal_category",
|
||||||
name="WiFi Signal Category",
|
translation_key="wifi_signal_category",
|
||||||
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
icon="mdi:wifi",
|
icon="mdi:wifi",
|
||||||
cls=HealthDataRingSensor,
|
cls=HealthDataRingSensor,
|
||||||
),
|
),
|
||||||
RingSensorEntityDescription(
|
RingSensorEntityDescription(
|
||||||
key="wifi_signal_strength",
|
key="wifi_signal_strength",
|
||||||
name="WiFi Signal Strength",
|
translation_key="wifi_signal_strength",
|
||||||
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
category=["chimes", "doorbots", "authorized_doorbots", "stickup_cams"],
|
||||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
icon="mdi:wifi",
|
icon="mdi:wifi",
|
||||||
|
@ -33,16 +33,15 @@ async def async_setup_entry(
|
|||||||
class RingChimeSiren(RingEntityMixin, SirenEntity):
|
class RingChimeSiren(RingEntityMixin, SirenEntity):
|
||||||
"""Creates a siren to play the test chimes of a Chime device."""
|
"""Creates a siren to play the test chimes of a Chime device."""
|
||||||
|
|
||||||
|
_attr_available_tones = CHIME_TEST_SOUND_KINDS
|
||||||
|
_attr_supported_features = SirenEntityFeature.TURN_ON | SirenEntityFeature.TONES
|
||||||
|
_attr_translation_key = "siren"
|
||||||
|
|
||||||
def __init__(self, config_entry: ConfigEntry, device) -> None:
|
def __init__(self, config_entry: ConfigEntry, device) -> None:
|
||||||
"""Initialize a Ring Chime siren."""
|
"""Initialize a Ring Chime siren."""
|
||||||
super().__init__(config_entry.entry_id, device)
|
super().__init__(config_entry.entry_id, device)
|
||||||
# Entity class attributes
|
# Entity class attributes
|
||||||
self._attr_name = f"{self._device.name} Siren"
|
|
||||||
self._attr_unique_id = f"{self._device.id}-siren"
|
self._attr_unique_id = f"{self._device.id}-siren"
|
||||||
self._attr_available_tones = CHIME_TEST_SOUND_KINDS
|
|
||||||
self._attr_supported_features = (
|
|
||||||
SirenEntityFeature.TURN_ON | SirenEntityFeature.TONES
|
|
||||||
)
|
|
||||||
|
|
||||||
def turn_on(self, **kwargs: Any) -> None:
|
def turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Play the test sound on a Ring Chime device."""
|
"""Play the test sound on a Ring Chime device."""
|
||||||
|
@ -22,5 +22,47 @@
|
|||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"binary_sensor": {
|
||||||
|
"ding": {
|
||||||
|
"name": "Ding"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"light": {
|
||||||
|
"light": {
|
||||||
|
"name": "[%key:component::light::title%]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"siren": {
|
||||||
|
"siren": {
|
||||||
|
"name": "[%key:component::siren::title%]"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"last_activity": {
|
||||||
|
"name": "Last activity"
|
||||||
|
},
|
||||||
|
"last_ding": {
|
||||||
|
"name": "Last ding"
|
||||||
|
},
|
||||||
|
"last_motion": {
|
||||||
|
"name": "Last motion"
|
||||||
|
},
|
||||||
|
"volume": {
|
||||||
|
"name": "Volume"
|
||||||
|
},
|
||||||
|
"wifi_signal_category": {
|
||||||
|
"name": "Wi-Fi signal category"
|
||||||
|
},
|
||||||
|
"wifi_signal_strength": {
|
||||||
|
"name": "Wi-Fi signal strength"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"switch": {
|
||||||
|
"siren": {
|
||||||
|
"name": "[%key:component::siren::title%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,11 +52,6 @@ class BaseRingSwitch(RingEntityMixin, SwitchEntity):
|
|||||||
self._device_type = device_type
|
self._device_type = device_type
|
||||||
self._unique_id = f"{self._device.id}-{self._device_type}"
|
self._unique_id = f"{self._device.id}-{self._device_type}"
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self):
|
|
||||||
"""Name of the device."""
|
|
||||||
return f"{self._device.name} {self._device_type}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique ID."""
|
"""Return a unique ID."""
|
||||||
@ -66,6 +61,8 @@ class BaseRingSwitch(RingEntityMixin, SwitchEntity):
|
|||||||
class SirenSwitch(BaseRingSwitch):
|
class SirenSwitch(BaseRingSwitch):
|
||||||
"""Creates a switch to turn the ring cameras siren on and off."""
|
"""Creates a switch to turn the ring cameras siren on and off."""
|
||||||
|
|
||||||
|
_attr_translation_key = "siren"
|
||||||
|
|
||||||
def __init__(self, config_entry_id, device):
|
def __init__(self, config_entry_id, device):
|
||||||
"""Initialize the switch for a device with a siren."""
|
"""Initialize the switch for a device with a siren."""
|
||||||
super().__init__(config_entry_id, device, "siren")
|
super().__init__(config_entry_id, device, "siren")
|
||||||
|
@ -32,7 +32,7 @@ async def test_light_off_reports_correctly(
|
|||||||
|
|
||||||
state = hass.states.get("light.front_light")
|
state = hass.states.get("light.front_light")
|
||||||
assert state.state == "off"
|
assert state.state == "off"
|
||||||
assert state.attributes.get("friendly_name") == "Front light"
|
assert state.attributes.get("friendly_name") == "Front Light"
|
||||||
|
|
||||||
|
|
||||||
async def test_light_on_reports_correctly(
|
async def test_light_on_reports_correctly(
|
||||||
@ -43,7 +43,7 @@ async def test_light_on_reports_correctly(
|
|||||||
|
|
||||||
state = hass.states.get("light.internal_light")
|
state = hass.states.get("light.internal_light")
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
assert state.attributes.get("friendly_name") == "Internal light"
|
assert state.attributes.get("friendly_name") == "Internal Light"
|
||||||
|
|
||||||
|
|
||||||
async def test_light_can_be_turned_on(
|
async def test_light_can_be_turned_on(
|
||||||
|
@ -32,7 +32,7 @@ async def test_siren_off_reports_correctly(
|
|||||||
|
|
||||||
state = hass.states.get("switch.front_siren")
|
state = hass.states.get("switch.front_siren")
|
||||||
assert state.state == "off"
|
assert state.state == "off"
|
||||||
assert state.attributes.get("friendly_name") == "Front siren"
|
assert state.attributes.get("friendly_name") == "Front Siren"
|
||||||
|
|
||||||
|
|
||||||
async def test_siren_on_reports_correctly(
|
async def test_siren_on_reports_correctly(
|
||||||
@ -43,7 +43,7 @@ async def test_siren_on_reports_correctly(
|
|||||||
|
|
||||||
state = hass.states.get("switch.internal_siren")
|
state = hass.states.get("switch.internal_siren")
|
||||||
assert state.state == "on"
|
assert state.state == "on"
|
||||||
assert state.attributes.get("friendly_name") == "Internal siren"
|
assert state.attributes.get("friendly_name") == "Internal Siren"
|
||||||
assert state.attributes.get("icon") == "mdi:alarm-bell"
|
assert state.attributes.get("icon") == "mdi:alarm-bell"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user