diff --git a/homeassistant/components/motioneye/__init__.py b/homeassistant/components/motioneye/__init__.py index c7aa8edc6c9..b936497cfc6 100644 --- a/homeassistant/components/motioneye/__init__.py +++ b/homeassistant/components/motioneye/__init__.py @@ -536,6 +536,8 @@ def get_media_url( class MotionEyeEntity(CoordinatorEntity): """Base class for motionEye entities.""" + _attr_has_entity_name = True + def __init__( self, config_entry_id: str, diff --git a/homeassistant/components/motioneye/camera.py b/homeassistant/components/motioneye/camera.py index 189296039aa..683308e081c 100644 --- a/homeassistant/components/motioneye/camera.py +++ b/homeassistant/components/motioneye/camera.py @@ -12,7 +12,6 @@ from motioneye_client.const import ( DEFAULT_SURVEILLANCE_USERNAME, KEY_ACTION_SNAPSHOT, KEY_MOTION_DETECTION, - KEY_NAME, KEY_STREAMING_AUTH_MODE, KEY_TEXT_OVERLAY_CAMERA_NAME, KEY_TEXT_OVERLAY_CUSTOM_TEXT, @@ -144,8 +143,6 @@ async def async_setup_entry( class MotionEyeMjpegCamera(MotionEyeEntity, MjpegCamera): """motionEye mjpeg camera.""" - _name: str - def __init__( self, config_entry_id: str, @@ -203,7 +200,7 @@ class MotionEyeMjpegCamera(MotionEyeEntity, MjpegCamera): streaming_url = self._client.get_camera_stream_url(camera) return { - CONF_NAME: camera[KEY_NAME], + CONF_NAME: None, CONF_USERNAME: self._surveillance_username if auth is not None else None, CONF_PASSWORD: self._surveillance_password if auth is not None else "", CONF_MJPEG_URL: streaming_url or "", @@ -218,7 +215,6 @@ class MotionEyeMjpegCamera(MotionEyeEntity, MjpegCamera): # Sets the state of the underlying (inherited) MjpegCamera based on the updated # MotionEye camera dictionary. properties = self._get_mjpeg_camera_properties_for_camera(camera) - self._name = properties[CONF_NAME] self._username = properties[CONF_USERNAME] self._password = properties[CONF_PASSWORD] self._mjpeg_url = properties[CONF_MJPEG_URL] diff --git a/homeassistant/components/motioneye/sensor.py b/homeassistant/components/motioneye/sensor.py index c8b7679149c..4d0abb84d46 100644 --- a/homeassistant/components/motioneye/sensor.py +++ b/homeassistant/components/motioneye/sensor.py @@ -6,7 +6,7 @@ from types import MappingProxyType from typing import Any from motioneye_client.client import MotionEyeClient -from motioneye_client.const import KEY_ACTIONS, KEY_NAME +from motioneye_client.const import KEY_ACTIONS from homeassistant.components.sensor import SensorEntity, SensorEntityDescription from homeassistant.config_entries import ConfigEntry @@ -48,6 +48,8 @@ async def async_setup_entry( class MotionEyeActionSensor(MotionEyeEntity, SensorEntity): """motionEye action sensor camera.""" + _attr_translation_key = "actions" + def __init__( self, config_entry_id: str, @@ -69,12 +71,6 @@ class MotionEyeActionSensor(MotionEyeEntity, SensorEntity): ), ) - @property - def name(self) -> str: - """Return the name of the sensor.""" - camera_prepend = f"{self._camera[KEY_NAME]} " if self._camera else "" - return f"{camera_prepend}Actions" - @property def native_value(self) -> StateType: """Return the value reported by the sensor.""" diff --git a/homeassistant/components/motioneye/strings.json b/homeassistant/components/motioneye/strings.json index fdf73cd8cf8..ea7901617cb 100644 --- a/homeassistant/components/motioneye/strings.json +++ b/homeassistant/components/motioneye/strings.json @@ -37,6 +37,33 @@ } } }, + "entity": { + "sensor": { + "actions": { + "name": "Actions" + } + }, + "switch": { + "motion_detection": { + "name": "Motion detection" + }, + "text_overlay": { + "name": "Text overlay" + }, + "video_streaming": { + "name": "Video streaming" + }, + "still_images": { + "name": "Still images" + }, + "movies": { + "name": "Movies" + }, + "upload_enabled": { + "name": "Upload enabled" + } + } + }, "services": { "set_text_overlay": { "name": "Set text overlay", diff --git a/homeassistant/components/motioneye/switch.py b/homeassistant/components/motioneye/switch.py index 3be1c20981d..069c5edaad7 100644 --- a/homeassistant/components/motioneye/switch.py +++ b/homeassistant/components/motioneye/switch.py @@ -8,7 +8,6 @@ from motioneye_client.client import MotionEyeClient from motioneye_client.const import ( KEY_MOTION_DETECTION, KEY_MOVIES, - KEY_NAME, KEY_STILL_IMAGES, KEY_TEXT_OVERLAY, KEY_UPLOAD_ENABLED, @@ -28,37 +27,37 @@ from .const import CONF_CLIENT, CONF_COORDINATOR, DOMAIN, TYPE_MOTIONEYE_SWITCH_ MOTIONEYE_SWITCHES = [ SwitchEntityDescription( key=KEY_MOTION_DETECTION, - name="Motion Detection", + translation_key="motion_detection", entity_registry_enabled_default=True, entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=KEY_TEXT_OVERLAY, - name="Text Overlay", + translation_key="text_overlay", entity_registry_enabled_default=False, entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=KEY_VIDEO_STREAMING, - name="Video Streaming", + translation_key="video_streaming", entity_registry_enabled_default=False, entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=KEY_STILL_IMAGES, - name="Still Images", + translation_key="still_images", entity_registry_enabled_default=True, entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=KEY_MOVIES, - name="Movies", + translation_key="movies", entity_registry_enabled_default=True, entity_category=EntityCategory.CONFIG, ), SwitchEntityDescription( key=KEY_UPLOAD_ENABLED, - name="Upload Enabled", + translation_key="upload_enabled", entity_registry_enabled_default=False, entity_category=EntityCategory.CONFIG, ), @@ -114,12 +113,6 @@ class MotionEyeSwitch(MotionEyeEntity, SwitchEntity): entity_description, ) - @property - def name(self) -> str: - """Return the name of the switch.""" - camera_prepend = f"{self._camera[KEY_NAME]} " if self._camera else "" - return f"{camera_prepend}{self.entity_description.name}" - @property def is_on(self) -> bool: """Return true if the switch is on."""