mirror of
				https://github.com/python-kasa/python-kasa.git
				synced 2025-11-04 06:32:07 +00:00 
			
		
		
		
	fix mympy's error "Decorated property not supported" (mypy bug)
See https://github.com/python/mypy/issues/1362
This commit is contained in:
		@@ -94,7 +94,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        self._device_type = DeviceType.Bulb
 | 
			
		||||
        self._light_state = None
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_color(self) -> bool:
 | 
			
		||||
        """Whether the bulb supports color changes.
 | 
			
		||||
@@ -105,7 +105,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        sys_info = self.sys_info
 | 
			
		||||
        return bool(sys_info["is_color"])
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_dimmable(self) -> bool:
 | 
			
		||||
        """Whether the bulb supports brightness changes.
 | 
			
		||||
@@ -116,7 +116,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        sys_info = self.sys_info
 | 
			
		||||
        return bool(sys_info["is_dimmable"])
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_variable_color_temp(self) -> bool:
 | 
			
		||||
        """Whether the bulb supports color temperature changes.
 | 
			
		||||
@@ -128,7 +128,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        sys_info = self.sys_info
 | 
			
		||||
        return bool(sys_info["is_variable_color_temp"])
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def valid_temperature_range(self) -> Tuple[int, int]:
 | 
			
		||||
        """Return the device-specific white temperature range (in Kelvin).
 | 
			
		||||
@@ -149,7 +149,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        self._sys_info = await self.get_sys_info()
 | 
			
		||||
        self._light_state = await self.get_light_state()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def light_state(self) -> Optional[Dict[str, Dict]]:
 | 
			
		||||
        """Query the light state."""
 | 
			
		||||
@@ -167,7 +167,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        await self.update()
 | 
			
		||||
        return light_state
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def hsv(self) -> Tuple[int, int, int]:
 | 
			
		||||
        """Return the current HSV state of the bulb.
 | 
			
		||||
@@ -228,7 +228,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        }
 | 
			
		||||
        await self.set_light_state(light_state)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def color_temp(self) -> int:
 | 
			
		||||
        """Return color temperature of the device.
 | 
			
		||||
@@ -264,7 +264,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        light_state = {"color_temp": temp}
 | 
			
		||||
        await self.set_light_state(light_state)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def brightness(self) -> int:
 | 
			
		||||
        """Return the current brightness.
 | 
			
		||||
@@ -295,7 +295,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        light_state = {"brightness": brightness}
 | 
			
		||||
        await self.set_light_state(light_state)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def state_information(self) -> Dict[str, Any]:
 | 
			
		||||
        """Return bulb-specific state information.
 | 
			
		||||
@@ -315,7 +315,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
 | 
			
		||||
        return info
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_on(self) -> bool:
 | 
			
		||||
        """Return whether the device is on."""
 | 
			
		||||
@@ -330,7 +330,7 @@ class SmartBulb(SmartDevice):
 | 
			
		||||
        """Turn the bulb on."""
 | 
			
		||||
        await self.set_light_state({"on_off": 1})
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def has_emeter(self) -> bool:
 | 
			
		||||
        """Return that the bulb has an emeter."""
 | 
			
		||||
 
 | 
			
		||||
@@ -244,7 +244,7 @@ class SmartDevice:
 | 
			
		||||
        """
 | 
			
		||||
        self._sys_info = await self.get_sys_info()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def sys_info(self) -> Dict[str, Any]:
 | 
			
		||||
        """Retrieve system information.
 | 
			
		||||
@@ -253,9 +253,10 @@ class SmartDevice:
 | 
			
		||||
        :rtype dict
 | 
			
		||||
        :raises SmartDeviceException: on error
 | 
			
		||||
        """
 | 
			
		||||
        assert self._sys_info is not None
 | 
			
		||||
        return self._sys_info
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def model(self) -> str:
 | 
			
		||||
        """Return device model.
 | 
			
		||||
@@ -267,7 +268,7 @@ class SmartDevice:
 | 
			
		||||
        sys_info = self.sys_info
 | 
			
		||||
        return str(sys_info["model"])
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def alias(self) -> str:
 | 
			
		||||
        """Return device name (alias).
 | 
			
		||||
@@ -375,7 +376,7 @@ class SmartDevice:
 | 
			
		||||
        """
 | 
			
		||||
        return await self._query_helper("time", "get_timezone")
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def hw_info(self) -> Dict:
 | 
			
		||||
        """Return hardware information.
 | 
			
		||||
@@ -398,7 +399,7 @@ class SmartDevice:
 | 
			
		||||
        sys_info = self.sys_info
 | 
			
		||||
        return {key: sys_info[key] for key in keys if key in sys_info}
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def location(self) -> Dict:
 | 
			
		||||
        """Return geographical location.
 | 
			
		||||
@@ -420,7 +421,7 @@ class SmartDevice:
 | 
			
		||||
 | 
			
		||||
        return loc
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def rssi(self) -> Optional[int]:
 | 
			
		||||
        """Return WiFi signal strenth (rssi).
 | 
			
		||||
@@ -433,7 +434,7 @@ class SmartDevice:
 | 
			
		||||
            return int(sys_info["rssi"])
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def mac(self) -> str:
 | 
			
		||||
        """Return mac address.
 | 
			
		||||
@@ -579,7 +580,7 @@ class SmartDevice:
 | 
			
		||||
        """Turn off the device."""
 | 
			
		||||
        raise NotImplementedError("Device subclass needs to implement this.")
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_off(self) -> bool:
 | 
			
		||||
        """Return True if device is off.
 | 
			
		||||
@@ -593,7 +594,7 @@ class SmartDevice:
 | 
			
		||||
        """Turn device on."""
 | 
			
		||||
        raise NotImplementedError("Device subclass needs to implement this.")
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_on(self) -> bool:
 | 
			
		||||
        """Return if the device is on.
 | 
			
		||||
@@ -604,7 +605,7 @@ class SmartDevice:
 | 
			
		||||
        """
 | 
			
		||||
        raise NotImplementedError("Device subclass needs to implement this.")
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def state_information(self) -> Dict[str, Any]:
 | 
			
		||||
        """Return device-type specific, end-user friendly state information.
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ class SmartPlug(SmartDevice):
 | 
			
		||||
        self.emeter_type = "emeter"
 | 
			
		||||
        self._device_type = DeviceType.Plug
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def brightness(self) -> int:
 | 
			
		||||
        """Return current brightness on dimmers.
 | 
			
		||||
@@ -92,7 +92,7 @@ class SmartPlug(SmartDevice):
 | 
			
		||||
        else:
 | 
			
		||||
            raise ValueError("Brightness value %s is not valid." % value)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_dimmable(self):
 | 
			
		||||
        """Whether the switch supports brightness changes.
 | 
			
		||||
@@ -103,7 +103,7 @@ class SmartPlug(SmartDevice):
 | 
			
		||||
        sys_info = self.sys_info
 | 
			
		||||
        return "brightness" in sys_info
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def has_emeter(self):
 | 
			
		||||
        """Return whether device has an energy meter.
 | 
			
		||||
@@ -115,7 +115,7 @@ class SmartPlug(SmartDevice):
 | 
			
		||||
        features = sys_info["feature"].split(":")
 | 
			
		||||
        return "ENE" in features
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_on(self) -> bool:
 | 
			
		||||
        """Return whether device is on.
 | 
			
		||||
@@ -141,7 +141,7 @@ class SmartPlug(SmartDevice):
 | 
			
		||||
        await self._query_helper("system", "set_relay_state", {"state": 0})
 | 
			
		||||
        await self.update()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def led(self) -> bool:
 | 
			
		||||
        """Return the state of the led.
 | 
			
		||||
@@ -161,7 +161,7 @@ class SmartPlug(SmartDevice):
 | 
			
		||||
        await self._query_helper("system", "set_led_off", {"off": int(not state)})
 | 
			
		||||
        await self.update()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def on_since(self) -> datetime.datetime:
 | 
			
		||||
        """Return pretty-printed on-time.
 | 
			
		||||
@@ -180,7 +180,7 @@ class SmartPlug(SmartDevice):
 | 
			
		||||
 | 
			
		||||
        return datetime.datetime.now() - datetime.timedelta(seconds=on_time)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def state_information(self) -> Dict[str, Any]:
 | 
			
		||||
        """Return switch-specific state information.
 | 
			
		||||
 
 | 
			
		||||
@@ -66,7 +66,7 @@ class SmartStrip(SmartPlug):
 | 
			
		||||
                )
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def is_on(self) -> bool:
 | 
			
		||||
        """Return if any of the outlets are on."""
 | 
			
		||||
@@ -101,13 +101,13 @@ class SmartStrip(SmartPlug):
 | 
			
		||||
        await self._query_helper("system", "set_relay_state", {"state": 0})
 | 
			
		||||
        await self.update()
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def on_since(self) -> datetime.datetime:
 | 
			
		||||
        """Return the maximum on-time of all outlets."""
 | 
			
		||||
        return max(plug.on_since for plug in self.plugs)
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    @property  # type: ignore
 | 
			
		||||
    @requires_update
 | 
			
		||||
    def state_information(self) -> Dict[str, Any]:
 | 
			
		||||
        """Return strip-specific state information.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user