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

Merge branch 'master' into experimental · python-kasa/python-kasa@72da71a · GitHub

Repository navigation

Commit 72da71a

Browse files
authored
Merge branch 'master' into experimental
2 parents 6d9ded4 + 70c96b5 commit 72da71a

10 files changed

Lines changed: 286 additions & 57 deletions

File tree

‎kasa/cli/device.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,13 @@ async def update_credentials(dev, username, password):
193193
click.confirm("Do you really want to replace the existing credentials?", abort=True)
194194

195195
return await dev.update_credentials(username, password)
196+
197+
198+
@device.command(name="logs")
199+
@pass_dev_or_child
200+
async def child_logs(dev):
201+
"""Print child device trigger logs."""
202+
if logs := dev.modules.get(Module.TriggerLogs):
203+
await dev.update(update_children=True)
204+
for entry in logs.logs:
205+
print(entry)

‎kasa/module.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class Module(ABC):
127127
WaterleakSensor: Final[ModuleName[smart.WaterleakSensor]] = ModuleName(
128128
"WaterleakSensor"
129129
)
130+
TriggerLogs: Final[ModuleName[smart.TriggerLogs]] = ModuleName("TriggerLogs")
130131

131132
# SMARTCAMERA only modules
132133
Camera: Final[ModuleName[experimental.Camera]] = ModuleName("Camera")

‎kasa/smart/modules/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from .temperaturecontrol import TemperatureControl
2828
from .temperaturesensor import TemperatureSensor
2929
from .time import Time
30+
from .triggerlogs import TriggerLogs
3031
from .waterleaksensor import WaterleakSensor
3132

3233
__all__ = [
@@ -56,6 +57,7 @@
5657
"WaterleakSensor",
5758
"ContactSensor",
5859
"MotionSensor",
60+
"TriggerLogs",
5961
"FrostProtection",
6062
"SmartLightEffect",
6163
]

‎kasa/smart/modules/triggerlogs.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Implementation of trigger logs module."""
2+
3+
from __future__ import annotations
4+
5+
from datetime import datetime
6+
7+
from pydantic.v1 import BaseModel, Field, parse_obj_as
8+
9+
from ..smartmodule import SmartModule
10+
11+
12+
class LogEntry(BaseModel):
13+
"""Presentation of a single log entry."""
14+
15+
id: int
16+
event_id: str = Field(alias="eventId")
17+
timestamp: datetime
18+
event: str
19+
20+
21+
class TriggerLogs(SmartModule):
22+
"""Implementation of trigger logs."""
23+
24+
REQUIRED_COMPONENT = "trigger_log"
25+
MINIMUM_UPDATE_INTERVAL_SECS = 60 * 60
26+
27+
def query(self) -> dict:
28+
"""Query to execute during the update cycle."""
29+
return {"get_trigger_logs": {"start_id": 0}}
30+
31+
@property
32+
def logs(self) -> list[LogEntry]:
33+
"""Return logs."""
34+
return parse_obj_as(list[LogEntry], self.data["logs"])

‎kasa/tests/fixtures/smart/child/S200B(US)_1.0_1.12.0.json‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
"fw_ver": "1.12.0 Build 231121 Rel.092508",
6969
"hw_id": "00000000000000000000000000000000",
7070
"hw_ver": "1.0",
71-
"jamming_rssi": -104,
72-
"jamming_signal_level": 2,
71+
"jamming_rssi": -113,
72+
"jamming_signal_level": 1,
7373
"lastOnboardingTimestamp": 1724636886,
7474
"mac": "98254A000000",
7575
"model": "S200B",
@@ -78,7 +78,7 @@
7878
"parent_device_id": "0000000000000000000000000000000000000000",
7979
"region": "Australia/Canberra",
8080
"report_interval": 16,
81-
"rssi": -36,
81+
"rssi": -56,
8282
"signal_level": 3,
8383
"specs": "US",
8484
"status": "online",
@@ -87,6 +87,9 @@
8787
},
8888
"get_device_time": -1001,
8989
"get_device_usage": -1001,
90+
"get_double_click_info": {
91+
"enable": false
92+
},
9093
"get_fw_download_state": {
9194
"cloud_cache_seconds": 1,
9295
"download_progress": 0,
@@ -104,5 +107,10 @@
104107
"release_note": "",
105108
"type": 0
106109
},
110+
"get_trigger_logs": {
111+
"logs": [],
112+
"start_id": 0,
113+
"sum": 0
114+
},
107115
"qs_component_nego": -1001
108116
}

‎kasa/tests/fixtures/smart/child/T110(US)_1.0_1.9.0.json‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"fw_ver": "1.9.0 Build 230704 Rel.154559",
6565
"hw_id": "00000000000000000000000000000000",
6666
"hw_ver": "1.0",
67-
"jamming_rssi": -116,
67+
"jamming_rssi": -113,
6868
"jamming_signal_level": 1,
6969
"lastOnboardingTimestamp": 1724635267,
7070
"mac": "A86E84000000",
@@ -75,7 +75,7 @@
7575
"parent_device_id": "0000000000000000000000000000000000000000",
7676
"region": "Australia/Canberra",
7777
"report_interval": 16,
78-
"rssi": -55,
78+
"rssi": -56,
7979
"signal_level": 3,
8080
"specs": "US",
8181
"status": "online",
@@ -101,5 +101,10 @@
101101
"release_note": "",
102102
"type": 0
103103
},
104+
"get_trigger_logs": {
105+
"logs": [],
106+
"start_id": 0,
107+
"sum": 0
108+
},
104109
"qs_component_nego": -1001
105110
}

‎kasa/tests/fixtures/smart/child/T310(US)_1.0_1.5.0.json‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@
8484
"avatar": "sensor_t310",
8585
"bind_count": 1,
8686
"category": "subg.trigger.temp-hmdt-sensor",
87-
"current_humidity": 51,
87+
"current_humidity": 49,
8888
"current_humidity_exception": 0,
89-
"current_temp": 19.4,
90-
"current_temp_exception": -0.6,
89+
"current_temp": 21.7,
90+
"current_temp_exception": 0,
9191
"device_id": "SCRUBBED_CHILD_DEVICE_ID_1",
9292
"fw_ver": "1.5.0 Build 230105 Rel.180832",
9393
"hw_id": "00000000000000000000000000000000",
9494
"hw_ver": "1.0",
95-
"jamming_rssi": -113,
95+
"jamming_rssi": -111,
9696
"jamming_signal_level": 1,
9797
"lastOnboardingTimestamp": 1724637745,
9898
"mac": "F0A731000000",
@@ -102,7 +102,7 @@
102102
"parent_device_id": "0000000000000000000000000000000000000000",
103103
"region": "Australia/Canberra",
104104
"report_interval": 16,
105-
"rssi": -36,
105+
"rssi": -46,
106106
"signal_level": 3,
107107
"specs": "US",
108108
"status": "online",
@@ -129,5 +129,10 @@
129129
"release_note": "",
130130
"type": 0
131131
},
132+
"get_trigger_logs": {
133+
"logs": [],
134+
"start_id": 0,
135+
"sum": 0
136+
},
132137
"qs_component_nego": -1001
133138
}

‎kasa/tests/fixtures/smart/child/T315(US)_1.0_1.8.0.json‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@
8585
"battery_percentage": 100,
8686
"bind_count": 1,
8787
"category": "subg.trigger.temp-hmdt-sensor",
88-
"current_humidity": 53,
88+
"current_humidity": 51,
8989
"current_humidity_exception": 0,
90-
"current_temp": 18.3,
91-
"current_temp_exception": -0.7,
90+
"current_temp": 21.5,
91+
"current_temp_exception": 0,
9292
"device_id": "SCRUBBED_CHILD_DEVICE_ID_2",
9393
"fw_ver": "1.8.0 Build 230921 Rel.091519",
9494
"hw_id": "00000000000000000000000000000000",
9595
"hw_ver": "1.0",
96-
"jamming_rssi": -114,
96+
"jamming_rssi": -113,
9797
"jamming_signal_level": 1,
9898
"lastOnboardingTimestamp": 1724637369,
9999
"mac": "202351000000",
@@ -103,7 +103,7 @@
103103
"parent_device_id": "0000000000000000000000000000000000000000",
104104
"region": "Australia/Canberra",
105105
"report_interval": 16,
106-
"rssi": -50,
106+
"rssi": -44,
107107
"signal_level": 3,
108108
"specs": "US",
109109
"status": "online",
@@ -130,5 +130,10 @@
130130
"release_note": "",
131131
"type": 0
132132
},
133+
"get_trigger_logs": {
134+
"logs": [],
135+
"start_id": 0,
136+
"sum": 0
137+
},
133138
"qs_component_nego": -1001
134139
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL