mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Codereview fixes. (#53452)
This commit is contained in:
parent
5741a59d08
commit
5e6853b9e1
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from types import MappingProxyType
|
from types import MappingProxyType
|
||||||
from typing import Any, Callable
|
from typing import Any
|
||||||
|
|
||||||
from motioneye_client.client import MotionEyeClient
|
from motioneye_client.client import MotionEyeClient
|
||||||
from motioneye_client.const import (
|
from motioneye_client.const import (
|
||||||
@ -18,6 +18,7 @@ from motioneye_client.const import (
|
|||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||||
|
|
||||||
from . import MotionEyeEntity, get_camera_from_cameras, listen_for_new_cameras
|
from . import MotionEyeEntity, get_camera_from_cameras, listen_for_new_cameras
|
||||||
@ -34,8 +35,8 @@ MOTIONEYE_SWITCHES = [
|
|||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
) -> bool:
|
) -> None:
|
||||||
"""Set up motionEye from a config entry."""
|
"""Set up motionEye from a config entry."""
|
||||||
entry_data = hass.data[DOMAIN][entry.entry_id]
|
entry_data = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
@ -59,7 +60,6 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
listen_for_new_cameras(hass, entry, camera_add)
|
listen_for_new_cameras(hass, entry, camera_add)
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class MotionEyeSwitch(MotionEyeEntity, SwitchEntity):
|
class MotionEyeSwitch(MotionEyeEntity, SwitchEntity):
|
||||||
@ -79,8 +79,7 @@ class MotionEyeSwitch(MotionEyeEntity, SwitchEntity):
|
|||||||
"""Initialize the switch."""
|
"""Initialize the switch."""
|
||||||
self._switch_key = switch_key
|
self._switch_key = switch_key
|
||||||
self._switch_key_friendly_name = switch_key_friendly_name
|
self._switch_key_friendly_name = switch_key_friendly_name
|
||||||
MotionEyeEntity.__init__(
|
super().__init__(
|
||||||
self,
|
|
||||||
config_entry_id,
|
config_entry_id,
|
||||||
f"{TYPE_MOTIONEYE_SWITCH_BASE}_{switch_key}",
|
f"{TYPE_MOTIONEYE_SWITCH_BASE}_{switch_key}",
|
||||||
camera,
|
camera,
|
||||||
@ -93,8 +92,8 @@ class MotionEyeSwitch(MotionEyeEntity, SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the switch."""
|
"""Return the name of the switch."""
|
||||||
camera_name = self._camera[KEY_NAME] if self._camera else ""
|
camera_prepend = f"{self._camera[KEY_NAME]} " if self._camera else ""
|
||||||
return f"{camera_name} {self._switch_key_friendly_name}"
|
return f"{camera_prepend}{self._switch_key_friendly_name}"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user