FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add screensetting module by rytilahti · Pull Request #1142 · python-kasa/python-kasa · GitHub

Repository navigation

Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion kasa/cli/main.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ async def cli(
# Skip update on specific commands, or if device factory,
# that performs an update was used for the device.
if ctx.invoked_subcommand not in SKIP_UPDATE_COMMANDS and not device_updated:
await dev.update()
await dev.update(update_children=True)

@asynccontextmanager
async def async_wrapped_device(device: Device):
Expand Down
2 changes: 2 additions & 0 deletions kasa/smart/modules/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from .lighttransition import LightTransition
from .motionsensor import MotionSensor
from .reportmode import ReportMode
from .screensetting import ScreenSetting
from .temperaturecontrol import TemperatureControl
from .temperaturesensor import TemperatureSensor
from .time import Time
Expand Down Expand Up @@ -58,4 +59,5 @@
"MotionSensor",
"FrostProtection",
"SmartLightEffect",
"ScreenSetting",
]
36 changes: 36 additions & 0 deletions kasa/smart/modules/screensetting.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Screen setting module."""

from __future__ import annotations

from ...feature import Feature
from ..smartmodule import SmartModule


class ScreenSetting(SmartModule):
"""Implementation for display rotation."""

REQUIRED_COMPONENT = "screen_setting"
QUERY_GETTER_NAME = "get_screen_setting_info"

def _initialize_features(self):
"""Initialize features after the initial update."""
self._add_feature(
Feature(
device=self._device,
id="rotate_display",
name="Rotate display",
container=self,
attribute_getter="rotate_display",
attribute_setter="set_rotate_display",
type=Feature.Type.Switch,
)
)

@property
def rotate_display(self) -> bool:
"""Return screen orientation."""
return self.data["led_rotation"]

async def set_rotate_display(self, enabled: bool) -> None:
"""Set screen orientation."""
await self.call("set_screen_setting_info", {"led_rotation": enabled})

Back | FazBrowse Home | New Git URL