mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 11:13:34 +00:00
Add bare bones homekit modules smart and smartcam devices (#1370)
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.13) (push) Has been cancelled
Some checks failed
CI / Perform linting checks (3.13) (push) Has been cancelled
CodeQL checks / Analyze (python) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, macos-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, ubuntu-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (false, windows-latest, 3.13) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.11) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.12) (push) Has been cancelled
CI / Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }} (true, ubuntu-latest, 3.13) (push) Has been cancelled
This commit is contained in:
parent
59e5073509
commit
c439530f93
@ -154,6 +154,7 @@ class Module(ABC):
|
|||||||
)
|
)
|
||||||
TriggerLogs: Final[ModuleName[smart.TriggerLogs]] = ModuleName("TriggerLogs")
|
TriggerLogs: Final[ModuleName[smart.TriggerLogs]] = ModuleName("TriggerLogs")
|
||||||
|
|
||||||
|
HomeKit: Final[ModuleName[smart.HomeKit]] = ModuleName("HomeKit")
|
||||||
Matter: Final[ModuleName[smart.Matter]] = ModuleName("Matter")
|
Matter: Final[ModuleName[smart.Matter]] = ModuleName("Matter")
|
||||||
|
|
||||||
# SMARTCAM only modules
|
# SMARTCAM only modules
|
||||||
|
@ -16,6 +16,7 @@ from .energy import Energy
|
|||||||
from .fan import Fan
|
from .fan import Fan
|
||||||
from .firmware import Firmware
|
from .firmware import Firmware
|
||||||
from .frostprotection import FrostProtection
|
from .frostprotection import FrostProtection
|
||||||
|
from .homekit import HomeKit
|
||||||
from .humiditysensor import HumiditySensor
|
from .humiditysensor import HumiditySensor
|
||||||
from .led import Led
|
from .led import Led
|
||||||
from .light import Light
|
from .light import Light
|
||||||
@ -67,5 +68,6 @@ __all__ = [
|
|||||||
"Thermostat",
|
"Thermostat",
|
||||||
"SmartLightEffect",
|
"SmartLightEffect",
|
||||||
"OverheatProtection",
|
"OverheatProtection",
|
||||||
|
"HomeKit",
|
||||||
"Matter",
|
"Matter",
|
||||||
]
|
]
|
||||||
|
32
kasa/smart/modules/homekit.py
Normal file
32
kasa/smart/modules/homekit.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
"""Implementation of homekit module."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from ...feature import Feature
|
||||||
|
from ..smartmodule import SmartModule
|
||||||
|
|
||||||
|
|
||||||
|
class HomeKit(SmartModule):
|
||||||
|
"""Implementation of homekit module."""
|
||||||
|
|
||||||
|
QUERY_GETTER_NAME: str = "get_homekit_info"
|
||||||
|
REQUIRED_COMPONENT = "homekit"
|
||||||
|
|
||||||
|
def _initialize_features(self) -> None:
|
||||||
|
"""Initialize features after the initial update."""
|
||||||
|
self._add_feature(
|
||||||
|
Feature(
|
||||||
|
self._device,
|
||||||
|
id="homekit_setup_code",
|
||||||
|
name="Homekit setup code",
|
||||||
|
container=self,
|
||||||
|
attribute_getter=lambda x: x.info["mfi_setup_code"],
|
||||||
|
type=Feature.Type.Sensor,
|
||||||
|
category=Feature.Category.Debug,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def info(self) -> dict[str, str]:
|
||||||
|
"""Homekit mfi setup info."""
|
||||||
|
return self.data
|
@ -4,6 +4,7 @@ from .alarm import Alarm
|
|||||||
from .camera import Camera
|
from .camera import Camera
|
||||||
from .childdevice import ChildDevice
|
from .childdevice import ChildDevice
|
||||||
from .device import DeviceModule
|
from .device import DeviceModule
|
||||||
|
from .homekit import HomeKit
|
||||||
from .led import Led
|
from .led import Led
|
||||||
from .matter import Matter
|
from .matter import Matter
|
||||||
from .pantilt import PanTilt
|
from .pantilt import PanTilt
|
||||||
@ -17,5 +18,6 @@ __all__ = [
|
|||||||
"Led",
|
"Led",
|
||||||
"PanTilt",
|
"PanTilt",
|
||||||
"Time",
|
"Time",
|
||||||
|
"HomeKit",
|
||||||
"Matter",
|
"Matter",
|
||||||
]
|
]
|
||||||
|
16
kasa/smartcam/modules/homekit.py
Normal file
16
kasa/smartcam/modules/homekit.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""Implementation of homekit module."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from ..smartcammodule import SmartCamModule
|
||||||
|
|
||||||
|
|
||||||
|
class HomeKit(SmartCamModule):
|
||||||
|
"""Implementation of homekit module."""
|
||||||
|
|
||||||
|
REQUIRED_COMPONENT = "homekit"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def info(self) -> dict[str, str]:
|
||||||
|
"""Not supported, return empty dict."""
|
||||||
|
return {}
|
@ -114,6 +114,15 @@ class FakeSmartTransport(BaseTransport):
|
|||||||
"type": 0,
|
"type": 0,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
"get_homekit_info": (
|
||||||
|
"homekit",
|
||||||
|
{
|
||||||
|
"mfi_setup_code": "000-00-000",
|
||||||
|
"mfi_setup_id": "0000",
|
||||||
|
"mfi_token_token": "000000000000000000000000000000000",
|
||||||
|
"mfi_token_uuid": "00000000-0000-0000-0000-000000000000",
|
||||||
|
},
|
||||||
|
),
|
||||||
"get_auto_update_info": (
|
"get_auto_update_info": (
|
||||||
"firmware",
|
"firmware",
|
||||||
{"enable": True, "random_range": 120, "time": 180},
|
{"enable": True, "random_range": 120, "time": 180},
|
||||||
|
16
tests/smart/modules/test_homekit.py
Normal file
16
tests/smart/modules/test_homekit.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
from kasa import Module
|
||||||
|
from kasa.smart import SmartDevice
|
||||||
|
|
||||||
|
from ...device_fixtures import parametrize
|
||||||
|
|
||||||
|
homekit = parametrize(
|
||||||
|
"has homekit", component_filter="homekit", protocol_filter={"SMART"}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@homekit
|
||||||
|
async def test_info(dev: SmartDevice):
|
||||||
|
"""Test homekit info."""
|
||||||
|
homekit = dev.modules.get(Module.HomeKit)
|
||||||
|
assert homekit
|
||||||
|
assert homekit.info
|
Loading…
Reference in New Issue
Block a user