mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Add cloud module for smartdevice (#767)
Add initial support for the cloud module. Adds a new binary sensor: `Cloud connection (cloud_connection): False`
This commit is contained in:
parent
520b6bbae3
commit
f5175c5632
@ -1,5 +1,6 @@
|
||||
"""Modules for SMART devices."""
|
||||
from .childdevicemodule import ChildDeviceModule
|
||||
from .cloudmodule import CloudModule
|
||||
from .devicemodule import DeviceModule
|
||||
from .energymodule import EnergyModule
|
||||
from .lighttransitionmodule import LightTransitionModule
|
||||
@ -10,5 +11,6 @@ __all__ = [
|
||||
"EnergyModule",
|
||||
"DeviceModule",
|
||||
"ChildDeviceModule",
|
||||
"CloudModule",
|
||||
"LightTransitionModule",
|
||||
]
|
||||
|
34
kasa/smart/modules/cloudmodule.py
Normal file
34
kasa/smart/modules/cloudmodule.py
Normal file
@ -0,0 +1,34 @@
|
||||
"""Implementation of cloud module."""
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...feature import Feature, FeatureType
|
||||
from ..smartmodule import SmartModule
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..smartdevice import SmartDevice
|
||||
|
||||
|
||||
class CloudModule(SmartModule):
|
||||
"""Implementation of cloud module."""
|
||||
|
||||
QUERY_GETTER_NAME = "get_connect_cloud_state"
|
||||
REQUIRED_COMPONENT = "cloud_connect"
|
||||
|
||||
def __init__(self, device: "SmartDevice", module: str):
|
||||
super().__init__(device, module)
|
||||
|
||||
self._add_feature(
|
||||
Feature(
|
||||
device,
|
||||
"Cloud connection",
|
||||
container=self,
|
||||
attribute_getter="is_connected",
|
||||
icon="mdi:cloud",
|
||||
type=FeatureType.BinarySensor,
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def is_connected(self):
|
||||
"""Return True if device is connected to the cloud."""
|
||||
return self.data["status"] == 0
|
@ -46,6 +46,7 @@ class FakeSmartTransport(BaseTransport):
|
||||
|
||||
FIXTURE_MISSING_MAP = {
|
||||
"get_wireless_scan_info": ("wireless", {"ap_list": [], "wep_supported": False}),
|
||||
"get_connect_cloud_state": ("cloud_connect", {"status": 1}),
|
||||
"get_on_off_gradually_info": ("on_off_gradually", {"enable": True}),
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user