A slim python wrapper of the Kidde HomeSafe private API.
Project description
kidde-homesafe
A slim python wrapper of the Kidde HomeSafe private API. If you're new to python, poke around [the code][kidde_homesafe.py]; it's simple, and you may understand more than you expect.
Basic Usage
Importing and asyncio
The following code snippets assume you have imported the following:
from kidde_homesafe import KiddeClient, KiddeCommand
import asyncio
import json
They should be run in an asyncio loop, like this (see asyncio for details):
async def main() -> None:
# Kidde functions
if __name__ == "__main__":
asyncio.run(main())
Login
Use the from_login
class method to create your first client:
client = await KiddeClient.from_login("test@example.com", "KiddeCloudPassword")
Reuse Cookies
You may save a client's cookies to a file:
with open("kidde_cookies.json", "w") as file:
json.dump(client.cookies, file)
And reuse them later:
with open("kidde_cookies.json") as file:
cookies = json.load(file)
client = KiddeClient(cookies)
Get Data
client.get_data
returns a KiddeDataset
object with locations
, devices
, and events
. You can skip pulling devices
with the get_devices=False
parameter and the same with events
. For example,
dataset = await client.get_data(get_events=False)
print(dataset.devices)
should print something like:
{
"918281": {
"id": 918281,
"serial_number": "00123456789Z",
"model": "wifidetector",
"notify": true,
"location_id": 018271,
"label": "Kithen",
"lost": false,
"hwrev": "WD-ESP32",
"ptt_state": "idle",
"locate_active": false,
"instance_id": "29ba9019ca",
"notify_contact": true,
"last_test_time": "2023-11-10T18:56:02Z",
"motion_active": false,
"weather_active": false,
"capabilities": [
"smoke",
"co"
],
"errors": [],
"smoke_alarm": false,
"co_alarm": false,
"smoke_level": 0,
"smoke_comp": -5,
"too_much_smoke": false,
"smoke_hushed": false,
"co_level": 0,
"fwrev": {
"wm": "2.5",
"net": "4.4.1",
"alarm": "1.10"
},
"life": 535,
"batt_volt": 0,
"battery_state": "ok",
"ptt_active": false,
"identifying": false,
"announcement": "Kitchen",
"notify_eol": true,
"diag_params": {
"ap_rssi": -47
},
"mb_model": 39,
"last_seen": "2023-11-10T18:59:02.932375951Z",
"ssid": "YourHomeWiFi",
"ap_rssi": -47,
"country_code": "US",
"longitude": 0,
"latitude": 0,
"altitude": 0,
"accuracy": 0,
"end_of_life_status": 1
}
}
Sending Device Commands
You can send API commands to your device using the KiddeCommand enum:
await client.device_command(location_id=018271, device_id=918281, KiddeCommand.IDENTIFY)
IDENTIFY is labeled "ping" in the app.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kidde-homesafe-0.0.3.tar.gz
.
File metadata
- Download URL: kidde-homesafe-0.0.3.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c6dc491af45bff31c5645de825257a88339053ad9db9f3f64dd0ed488fd8a60e
|
|
MD5 |
02382a9530e9f5a69826e4c6b1c60209
|
|
BLAKE2b-256 |
a8b3aca5e4d014d05dd28e1a8956fb3d9eaa58d4913672996d4738294d39dd0a
|
File details
Details for the file kidde_homesafe-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: kidde_homesafe-0.0.3-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
7110774ef75269e6e3819ac3894b87f219b7bbeb3a11f18097de31168b676a72
|
|
MD5 |
557f53712d865c64e9d83b578b8c8484
|
|
BLAKE2b-256 |
c8d6ae7a8882608b0122dba6f26e758f4551a25e4fa17bf94e63ec246709f5a5
|