| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d63f43a commit 35dbda7
13 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -609,16 +609,7 @@ async def state(ctx, dev: Device): | |||
| 609 | 609 | echo(f"\tMAC (rssi): {dev.mac} ({dev.rssi})") | |
| 610 | 610 | echo(f"\tLocation: {dev.location}") | |
| 611 | 611 | ||
| 612 | - echo("\n\t[bold]== Device specific information ==[/bold]") | ||
| 613 | - for info_name, info_data in dev.state_information.items(): | ||
| 614 | - if isinstance(info_data, list): | ||
| 615 | - echo(f"\t{info_name}:") | ||
| 616 | - for item in info_data: | ||
| 617 | - echo(f"\t\t{item}") | ||
| 618 | - else: | ||
| 619 | - echo(f"\t{info_name}: {info_data}") | ||
| 620 | - | ||
| 621 | - echo("\n\t[bold]== Features == [/bold]") | ||
| 612 | + echo("\n\t[bold]== Device-specific information == [/bold]") | ||
| 622 | 613 | for id_, feature in dev.features.items(): | |
| 623 | 614 | echo(f"\t{feature.name} ({id_}): {feature.value}") | |
| 624 | 615 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -304,9 +304,9 @@ def internal_state(self) -> Any: | |||
| 304 | 304 | """Return all the internal state data.""" | |
| 305 | 305 | ||
| 306 | 306 | @property | |
| 307 | - @abstractmethod | ||
| 308 | 307 | def state_information(self) -> Dict[str, Any]: | |
| 309 | - """Return the key state information.""" | ||
| 308 | + """Return available features and their values.""" | ||
| 309 | + return {feat.name: feat.value for feat in self._features.values()} | ||
| 310 | 310 | ||
| 311 | 311 | @property | |
| 312 | 312 | def features(self) -> Dict[str, Feature]: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,7 @@ | |||
| 2 | 2 | import logging | |
| 3 | 3 | import re | |
| 4 | 4 | from enum import Enum | |
| 5 | - from typing import Any, Dict, List, Optional, cast | ||
| 5 | + from typing import Dict, List, Optional, cast | ||
| 6 | 6 | ||
| 7 | 7 | try: | |
| 8 | 8 | from pydantic.v1 import BaseModel, Field, root_validator | |
@@ -462,23 +462,6 @@ async def set_brightness( | |||
| 462 | 462 | light_state = {"brightness": brightness} | |
| 463 | 463 | return await self.set_light_state(light_state, transition=transition) | |
| 464 | 464 | ||
| 465 | - @property # type: ignore | ||
| 466 | - @requires_update | ||
| 467 | - def state_information(self) -> Dict[str, Any]: | ||
| 468 | - """Return bulb-specific state information.""" | ||
| 469 | - info: Dict[str, Any] = { | ||
| 470 | - "Brightness": self.brightness, | ||
| 471 | - "Is dimmable": self.is_dimmable, | ||
| 472 | - } | ||
| 473 | - if self.is_variable_color_temp: | ||
| 474 | - info["Color temperature"] = self.color_temp | ||
| 475 | - info["Valid temperature range"] = self.valid_temperature_range | ||
| 476 | - if self.is_color: | ||
| 477 | - info["HSV"] = self.hsv | ||
| 478 | - info["Presets"] = self.presets | ||
| 479 | - | ||
| 480 | - return info | ||
| 481 | - | ||
| 482 | 465 | @property # type: ignore | |
| 483 | 466 | @requires_update | |
| 484 | 467 | def is_on(self) -> bool: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -615,12 +615,6 @@ def on_since(self) -> Optional[datetime]: | |||
| 615 | 615 | ||
| 616 | 616 | return datetime.now().replace(microsecond=0) - timedelta(seconds=on_time) | |
| 617 | 617 | ||
| 618 | - @property # type: ignore | ||
| 619 | - @requires_update | ||
| 620 | - def state_information(self) -> Dict[str, Any]: | ||
| 621 | - """Return device-type specific, end-user friendly state information.""" | ||
| 622 | - raise NotImplementedError("Device subclass needs to implement this.") | ||
| 623 | - | ||
| 624 | 618 | @property # type: ignore | |
| 625 | 619 | @requires_update | |
| 626 | 620 | def device_id(self) -> str: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -232,12 +232,3 @@ def is_dimmable(self) -> bool: | |||
| 232 | 232 | """Whether the switch supports brightness changes.""" | |
| 233 | 233 | sys_info = self.sys_info | |
| 234 | 234 | return "brightness" in sys_info | |
| 235 | - | ||
| 236 | - @property # type: ignore | ||
| 237 | - @requires_update | ||
| 238 | - def state_information(self) -> Dict[str, Any]: | ||
| 239 | - """Return switch-specific state information.""" | ||
| 240 | - info = super().state_information | ||
| 241 | - info["Brightness"] = self.brightness | ||
| 242 | - | ||
| 243 | - return info | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | """Module for light strips (KL430).""" | |
| 2 | - from typing import Any, Dict, List, Optional | ||
| 2 | + from typing import Dict, List, Optional | ||
| 3 | 3 | ||
| 4 | 4 | from ..device_type import DeviceType | |
| 5 | 5 | from ..deviceconfig import DeviceConfig | |
@@ -84,18 +84,6 @@ def effect_list(self) -> Optional[List[str]]: | |||
| 84 | 84 | """ | |
| 85 | 85 | return EFFECT_NAMES_V1 if self.has_effects else None | |
| 86 | 86 | ||
| 87 | - @property # type: ignore | ||
| 88 | - @requires_update | ||
| 89 | - def state_information(self) -> Dict[str, Any]: | ||
| 90 | - """Return strip specific state information.""" | ||
| 91 | - info = super().state_information | ||
| 92 | - | ||
| 93 | - info["Length"] = self.length | ||
| 94 | - if self.has_effects: | ||
| 95 | - info["Effect"] = self.effect["name"] | ||
| 96 | - | ||
| 97 | - return info | ||
| 98 | - | ||
| 99 | 87 | @requires_update | |
| 100 | 88 | async def set_effect( | |
| 101 | 89 | self, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | """Module for smart plugs (HS100, HS110, ..).""" | |
| 2 | 2 | import logging | |
| 3 | - from typing import Any, Dict, Optional | ||
| 3 | + from typing import Optional | ||
| 4 | 4 | ||
| 5 | 5 | from ..device_type import DeviceType | |
| 6 | 6 | from ..deviceconfig import DeviceConfig | |
@@ -99,12 +99,6 @@ async def set_led(self, state: bool): | |||
| 99 | 99 | "system", "set_led_off", {"off": int(not state)} | |
| 100 | 100 | ) | |
| 101 | 101 | ||
| 102 | - @property # type: ignore | ||
| 103 | - @requires_update | ||
| 104 | - def state_information(self) -> Dict[str, Any]: | ||
| 105 | - """Return switch-specific state information.""" | ||
| 106 | - return {} | ||
| 107 | - | ||
| 108 | 102 | ||
| 109 | 103 | class IotWallSwitch(IotPlug): | |
| 110 | 104 | """Representation of a TP-Link Smart Wall Switch.""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -154,19 +154,6 @@ async def set_led(self, state: bool): | |||
| 154 | 154 | """Set the state of the led (night mode).""" | |
| 155 | 155 | await self._query_helper("system", "set_led_off", {"off": int(not state)}) | |
| 156 | 156 | ||
| 157 | - @property # type: ignore | ||
| 158 | - @requires_update | ||
| 159 | - def state_information(self) -> Dict[str, Any]: | ||
| 160 | - """Return strip-specific state information. | ||
| 161 | - | ||
| 162 | - :return: Strip information dict, keys in user-presentable form. | ||
| 163 | - """ | ||
| 164 | - return { | ||
| 165 | - "LED state": self.led, | ||
| 166 | - "Childs count": len(self.children), | ||
| 167 | - "On since": self.on_since, | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | 157 | async def current_consumption(self) -> float: | |
| 171 | 158 | """Get the current power consumption in watts.""" | |
| 172 | 159 | return sum([await plug.current_consumption() for plug in self.children]) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | """Module for tapo-branded smart bulbs (L5**).""" | |
| 2 | - from typing import Any, Dict, List, Optional | ||
| 2 | + from typing import Dict, List, Optional | ||
| 3 | 3 | ||
| 4 | 4 | from ..bulb import Bulb | |
| 5 | 5 | from ..exceptions import KasaException | |
@@ -238,25 +238,6 @@ async def set_effect( | |||
| 238 | 238 | } | |
| 239 | 239 | ) | |
| 240 | 240 | ||
| 241 | - @property # type: ignore | ||
| 242 | - def state_information(self) -> Dict[str, Any]: | ||
| 243 | - """Return bulb-specific state information.""" | ||
| 244 | - info: Dict[str, Any] = { | ||
| 245 | - # TODO: re-enable after we don't inherit from smartbulb | ||
| 246 | - # **super().state_information | ||
| 247 | - "Is dimmable": self.is_dimmable, | ||
| 248 | - } | ||
| 249 | - if self.is_dimmable: | ||
| 250 | - info["Brightness"] = self.brightness | ||
| 251 | - if self.is_variable_color_temp: | ||
| 252 | - info["Color temperature"] = self.color_temp | ||
| 253 | - info["Valid temperature range"] = self.valid_temperature_range | ||
| 254 | - if self.is_color: | ||
| 255 | - info["HSV"] = self.hsv | ||
| 256 | - info["Presets"] = self.presets | ||
| 257 | - | ||
| 258 | - return info | ||
| 259 | - | ||
| 260 | 241 | @property | |
| 261 | 242 | def presets(self) -> List[BulbPreset]: | |
| 262 | 243 | """Return a list of available bulb setting presets.""" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -334,15 +334,6 @@ def ssid(self) -> str: | |||
| 334 | 334 | ssid = base64.b64decode(ssid).decode() if ssid else "No SSID" | |
| 335 | 335 | return ssid | |
| 336 | 336 | ||
| 337 | - @property | ||
| 338 | - def state_information(self) -> Dict[str, Any]: | ||
| 339 | - """Return the key state information.""" | ||
| 340 | - return { | ||
| 341 | - "overheated": self._info.get("overheated"), | ||
| 342 | - "signal_level": self._info.get("signal_level"), | ||
| 343 | - "SSID": self.ssid, | ||
| 344 | - } | ||
| 345 | - | ||
| 346 | 337 | @property | |
| 347 | 338 | def has_emeter(self) -> bool: | |
| 348 | 339 | """Return if the device has emeter.""" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments