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

Add bare bones homekit modules smart and smartcam devices by sdb9696 · Pull Request #1370 · python-kasa/python-kasa · GitHub

Repository navigation

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

Filter by extension

Filter by extension .py  (7) 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
1 change: 1 addition & 0 deletions kasa/module.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 @@ -154,6 +154,7 @@ class Module(ABC):
)
TriggerLogs: Final[ModuleName[smart.TriggerLogs]] = ModuleName("TriggerLogs")

HomeKit: Final[ModuleName[smart.HomeKit]] = ModuleName("HomeKit")
Matter: Final[ModuleName[smart.Matter]] = ModuleName("Matter")

# SMARTCAM only modules
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 @@ -16,6 +16,7 @@
from .fan import Fan
from .firmware import Firmware
from .frostprotection import FrostProtection
from .homekit import HomeKit
from .humiditysensor import HumiditySensor
from .led import Led
from .light import Light
Expand Down Expand Up @@ -67,5 +68,6 @@
"Thermostat",
"SmartLightEffect",
"OverheatProtection",
"HomeKit",
"Matter",
]
32 changes: 32 additions & 0 deletions kasa/smart/modules/homekit.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,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"],
Comment thread
rytilahti marked this conversation as resolved.
type=Feature.Type.Sensor,
category=Feature.Category.Debug,
)
)

@property
def info(self) -> dict[str, str]:
"""Homekit mfi setup info."""
return self.data
2 changes: 2 additions & 0 deletions kasa/smartcam/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 @@ -4,6 +4,7 @@
from .camera import Camera
from .childdevice import ChildDevice
from .device import DeviceModule
from .homekit import HomeKit
from .led import Led
from .matter import Matter
from .pantilt import PanTilt
Expand All @@ -17,5 +18,6 @@
"Led",
"PanTilt",
"Time",
"HomeKit",
"Matter",
]
16 changes: 16 additions & 0 deletions kasa/smartcam/modules/homekit.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,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."""
Comment thread
rytilahti marked this conversation as resolved.
return {}
9 changes: 9 additions & 0 deletions tests/fakeprotocol_smart.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 @@ -114,6 +114,15 @@ def credentials_hash(self):
"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": (
"firmware",
{"enable": True, "random_range": 120, "time": 180},
Expand Down
16 changes: 16 additions & 0 deletions tests/smart/modules/test_homekit.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,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

Back | FazBrowse Home | New Git URL