mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Migrate Axis to new entity naming style (#74735)
This commit is contained in:
parent
124bfe1629
commit
874043f596
@ -10,6 +10,8 @@ from .const import DOMAIN as AXIS_DOMAIN
|
|||||||
class AxisEntityBase(Entity):
|
class AxisEntityBase(Entity):
|
||||||
"""Base common to all Axis entities."""
|
"""Base common to all Axis entities."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(self, device):
|
def __init__(self, device):
|
||||||
"""Initialize the Axis event."""
|
"""Initialize the Axis event."""
|
||||||
self.device = device
|
self.device = device
|
||||||
@ -47,7 +49,7 @@ class AxisEventBase(AxisEntityBase):
|
|||||||
super().__init__(device)
|
super().__init__(device)
|
||||||
self.event = event
|
self.event = event
|
||||||
|
|
||||||
self._attr_name = f"{device.name} {event.TYPE} {event.id}"
|
self._attr_name = f"{event.TYPE} {event.id}"
|
||||||
self._attr_unique_id = f"{device.unique_id}-{event.topic}-{event.id}"
|
self._attr_unique_id = f"{device.unique_id}-{event.topic}-{event.id}"
|
||||||
|
|
||||||
self._attr_device_class = event.CLASS
|
self._attr_device_class = event.CLASS
|
||||||
|
@ -110,9 +110,7 @@ class AxisBinarySensor(AxisEventBase, BinarySensorEntity):
|
|||||||
and self.event.id in self.device.api.vapix.ports
|
and self.event.id in self.device.api.vapix.ports
|
||||||
and self.device.api.vapix.ports[self.event.id].name
|
and self.device.api.vapix.ports[self.event.id].name
|
||||||
):
|
):
|
||||||
return (
|
return self.device.api.vapix.ports[self.event.id].name
|
||||||
f"{self.device.name} {self.device.api.vapix.ports[self.event.id].name}"
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.event.CLASS == CLASS_MOTION:
|
if self.event.CLASS == CLASS_MOTION:
|
||||||
|
|
||||||
@ -128,6 +126,6 @@ class AxisBinarySensor(AxisEventBase, BinarySensorEntity):
|
|||||||
and event_data
|
and event_data
|
||||||
and self.event.id in event_data
|
and self.event.id in event_data
|
||||||
):
|
):
|
||||||
return f"{self.device.name} {self.event.TYPE} {event_data[self.event.id].name}"
|
return f"{self.event.TYPE} {event_data[self.event.id].name}"
|
||||||
|
|
||||||
return self._attr_name
|
return self._attr_name
|
||||||
|
@ -40,7 +40,6 @@ class AxisCamera(AxisEntityBase, MjpegCamera):
|
|||||||
|
|
||||||
MjpegCamera.__init__(
|
MjpegCamera.__init__(
|
||||||
self,
|
self,
|
||||||
name=device.name,
|
|
||||||
username=device.username,
|
username=device.username,
|
||||||
password=device.password,
|
password=device.password,
|
||||||
mjpeg_url=self.mjpeg_source,
|
mjpeg_url=self.mjpeg_source,
|
||||||
|
@ -53,7 +53,7 @@ class AxisLight(AxisEventBase, LightEntity):
|
|||||||
self.max_intensity = 0
|
self.max_intensity = 0
|
||||||
|
|
||||||
light_type = device.api.vapix.light_control[self.light_id].light_type
|
light_type = device.api.vapix.light_control[self.light_id].light_type
|
||||||
self._attr_name = f"{device.name} {light_type} {event.TYPE} {event.id}"
|
self._attr_name = f"{light_type} {event.TYPE} {event.id}"
|
||||||
|
|
||||||
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
self._attr_color_mode = ColorMode.BRIGHTNESS
|
self._attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
|
@ -40,7 +40,7 @@ class AxisSwitch(AxisEventBase, SwitchEntity):
|
|||||||
super().__init__(event, device)
|
super().__init__(event, device)
|
||||||
|
|
||||||
if event.id and device.api.vapix.ports[event.id].name:
|
if event.id and device.api.vapix.ports[event.id].name:
|
||||||
self._attr_name = f"{device.name} {device.api.vapix.ports[event.id].name}"
|
self._attr_name = device.api.vapix.ports[event.id].name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user