From 3323f84c22d8d41a5489418cc35d747c80dc63f8 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 19 Feb 2026 14:47:10 +0100 Subject: [PATCH] Use shorthand attributes in hikvisioncam switch (#163504) --- .../components/hikvisioncam/switch.py | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/homeassistant/components/hikvisioncam/switch.py b/homeassistant/components/hikvisioncam/switch.py index aa16097f402..85ad3ba2f7a 100644 --- a/homeassistant/components/hikvisioncam/switch.py +++ b/homeassistant/components/hikvisioncam/switch.py @@ -19,8 +19,6 @@ from homeassistant.const import ( CONF_PASSWORD, CONF_PORT, CONF_USERNAME, - STATE_OFF, - STATE_ON, ) from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv @@ -79,19 +77,9 @@ class HikvisionMotionSwitch(SwitchEntity): def __init__(self, name, hikvision_cam): """Initialize the switch.""" - self._name = name + self._attr_name = name self._hikvision_cam = hikvision_cam - self._state = STATE_OFF - - @property - def name(self): - """Return the name of the device if any.""" - return self._name - - @property - def is_on(self): - """Return true if device is on.""" - return self._state == STATE_ON + self._attr_is_on = False def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" @@ -105,7 +93,5 @@ class HikvisionMotionSwitch(SwitchEntity): def update(self) -> None: """Update Motion Detection state.""" - enabled = self._hikvision_cam.is_motion_detection_enabled() - _LOGGING.info("enabled: %s", enabled) - - self._state = STATE_ON if enabled else STATE_OFF + self._attr_is_on = self._hikvision_cam.is_motion_detection_enabled() + _LOGGING.info("enabled: %s", self._attr_is_on)