mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
Add support for contact sensor (T110) (#877)
Initial support for T110 contact sensor & T110 fixture by courtesy of @ngaertner.
This commit is contained in:
@@ -109,7 +109,7 @@ DIMMERS = {
|
||||
}
|
||||
|
||||
HUBS_SMART = {"H100", "KH100"}
|
||||
SENSORS_SMART = {"T310", "T315", "T300"}
|
||||
SENSORS_SMART = {"T310", "T315", "T300", "T110"}
|
||||
THERMOSTATS_SMART = {"KE100"}
|
||||
|
||||
WITH_EMETER_IOT = {"HS110", "HS300", "KP115", "KP125", *BULBS_IOT}
|
||||
|
526
kasa/tests/fixtures/smart/child/T110(EU)_1.0_1.8.0.json
vendored
Normal file
526
kasa/tests/fixtures/smart/child/T110(EU)_1.0_1.8.0.json
vendored
Normal file
@@ -0,0 +1,526 @@
|
||||
{
|
||||
"component_nego": {
|
||||
"component_list": [
|
||||
{
|
||||
"id": "device",
|
||||
"ver_code": 2
|
||||
},
|
||||
{
|
||||
"id": "quick_setup",
|
||||
"ver_code": 3
|
||||
},
|
||||
{
|
||||
"id": "trigger_log",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "time",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "device_local_time",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "account",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "synchronize",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "cloud_connect",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "iot_cloud",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "firmware",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "localSmart",
|
||||
"ver_code": 1
|
||||
},
|
||||
{
|
||||
"id": "battery_detect",
|
||||
"ver_code": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"get_connect_cloud_state": {
|
||||
"status": 0
|
||||
},
|
||||
"get_device_info": {
|
||||
"at_low_battery": false,
|
||||
"avatar": "sensor_t110",
|
||||
"bind_count": 1,
|
||||
"category": "subg.trigger.contact-sensor",
|
||||
"device_id": "SCRUBBED_CHILD_DEVICE_ID_2",
|
||||
"fw_ver": "1.8.0 Build 220728 Rel.160024",
|
||||
"hw_id": "00000000000000000000000000000000",
|
||||
"hw_ver": "1.0",
|
||||
"jamming_rssi": -113,
|
||||
"jamming_signal_level": 1,
|
||||
"lastOnboardingTimestamp": 1714661626,
|
||||
"mac": "E4FAC4000000",
|
||||
"model": "T110",
|
||||
"nickname": "I01BU0tFRF9OQU1FIw==",
|
||||
"oem_id": "00000000000000000000000000000000",
|
||||
"open": false,
|
||||
"parent_device_id": "0000000000000000000000000000000000000000",
|
||||
"region": "Europe/Berlin",
|
||||
"report_interval": 16,
|
||||
"rssi": -54,
|
||||
"signal_level": 3,
|
||||
"specs": "EU",
|
||||
"status": "online",
|
||||
"status_follow_edge": false,
|
||||
"type": "SMART.TAPOSENSOR"
|
||||
},
|
||||
"get_fw_download_state": {
|
||||
"cloud_cache_seconds": 1,
|
||||
"download_progress": 30,
|
||||
"reboot_time": 5,
|
||||
"status": 4,
|
||||
"upgrade_time": 5
|
||||
},
|
||||
"get_latest_fw": {
|
||||
"fw_ver": "1.9.0 Build 230704 Rel.154531",
|
||||
"hw_id": "00000000000000000000000000000000",
|
||||
"need_to_upgrade": true,
|
||||
"oem_id": "00000000000000000000000000000000",
|
||||
"release_date": "2023-10-30",
|
||||
"release_note": "Modifications and Bug Fixes:\n1. Reduced power consumption.\n2. Fixed some minor bugs.",
|
||||
"type": 2
|
||||
},
|
||||
"get_temp_humidity_records": {
|
||||
"local_time": 1714681046,
|
||||
"past24h_humidity": [
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000
|
||||
],
|
||||
"past24h_humidity_exception": [
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000
|
||||
],
|
||||
"past24h_temp": [
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000
|
||||
],
|
||||
"past24h_temp_exception": [
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000,
|
||||
-1000
|
||||
],
|
||||
"temp_unit": "celsius"
|
||||
},
|
||||
"get_trigger_logs": {
|
||||
"logs": [
|
||||
{
|
||||
"event": "close",
|
||||
"eventId": "8140289c-c66b-bdd6-63b9-542299442299",
|
||||
"id": 4,
|
||||
"timestamp": 1714661714
|
||||
},
|
||||
{
|
||||
"event": "open",
|
||||
"eventId": "fb4e1439-2f2c-a5e1-c35a-9e7c0d35a1e3",
|
||||
"id": 3,
|
||||
"timestamp": 1714661710
|
||||
},
|
||||
{
|
||||
"event": "close",
|
||||
"eventId": "ddee7733-1180-48ac-56a3-512018048ac5",
|
||||
"id": 2,
|
||||
"timestamp": 1714661657
|
||||
},
|
||||
{
|
||||
"event": "open",
|
||||
"eventId": "ab80951f-da38-49f9-21c5-bf025c7b606d",
|
||||
"id": 1,
|
||||
"timestamp": 1714661638
|
||||
}
|
||||
],
|
||||
"start_id": 4,
|
||||
"sum": 4
|
||||
}
|
||||
}
|
29
kasa/tests/smart/modules/test_contact.py
Normal file
29
kasa/tests/smart/modules/test_contact.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import pytest
|
||||
|
||||
from kasa import SmartDevice
|
||||
from kasa.smart.modules import ContactSensor
|
||||
from kasa.tests.device_fixtures import parametrize
|
||||
|
||||
contact = parametrize(
|
||||
"is contact sensor", model_filter="T110", protocol_filter={"SMART.CHILD"}
|
||||
)
|
||||
|
||||
|
||||
@contact
|
||||
@pytest.mark.parametrize(
|
||||
"feature, type",
|
||||
[
|
||||
("is_open", bool),
|
||||
],
|
||||
)
|
||||
async def test_contact_features(dev: SmartDevice, feature, type):
|
||||
"""Test that features are registered and work as expected."""
|
||||
contact = dev.get_module(ContactSensor)
|
||||
assert contact is not None
|
||||
|
||||
prop = getattr(contact, feature)
|
||||
assert isinstance(prop, type)
|
||||
|
||||
feat = contact._module_features[feature]
|
||||
assert feat.value == prop
|
||||
assert isinstance(feat.value, type)
|
Reference in New Issue
Block a user