Skip to content

Commit

Permalink
Merge pull request #181 from natekspencer/dev
Browse files Browse the repository at this point in the history
Adjust loading of zwave device db
  • Loading branch information
natekspencer authored Jul 8, 2024
2 parents b88512e + 50deca6 commit 2fb27bf
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 17 deletions.
51 changes: 48 additions & 3 deletions vivintpy/zjs_device_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"0x0000:0x0004:0x0004": {
"description": "USB Controller",
"label": "700 Series",
"label": "700/800 Series",
"manufacturer": "Silicon Labs"
},
"0x0001:0x4243:0x0000": {
Expand Down Expand Up @@ -390,7 +390,7 @@
"manufacturer": "HomeSeer Technologies"
},
"0x000c:0x0004:0x0001": {
"description": "Z-Wave Multi Sensorr",
"description": "Z-Wave Multi Sensor",
"label": "HS-HSM200",
"manufacturer": "HomeSeer Technologies"
},
Expand Down Expand Up @@ -429,6 +429,11 @@
"label": "HS-FC200+",
"manufacturer": "HomeSeer Technologies"
},
"0x000c:0x0204:0x0002": {
"description": "Z-Wave Presence Sensor",
"label": "HS-PS100",
"manufacturer": "HomeSeer Technologies"
},
"0x000c:0x4447:0x3031": {
"description": "Appliance Module",
"label": "HS-PA100+",
Expand Down Expand Up @@ -814,6 +819,16 @@
"label": "ZW4SF",
"manufacturer": "Leviton"
},
"0x001d:0x0041:0x0002": {
"description": "Decora Smart 800 Series Dimmer",
"label": "ZW6HD",
"manufacturer": "Leviton"
},
"0x001d:0x0042:0x0002": {
"description": "Decora Smart 800 Series Switch",
"label": "ZW15S",
"manufacturer": "Leviton"
},
"0x001d:0x0101:0x0328": {
"description": "Scene Capable Plug-In Appliance Module, 300W",
"label": "VRP15",
Expand Down Expand Up @@ -2429,6 +2444,16 @@
"label": "59338 / ZWA4012DV",
"manufacturer": "Enbrighten"
},
"0x0063:0x4952:0x3333": {
"description": "In-Wall Paddle Switch, QFSW, 700S",
"label": "58433 / 59344 / ZWA4011",
"manufacturer": "Enbrighten"
},
"0x0063:0x4952:0x3334": {
"description": "In-Wall Toggle Switch, QFSW, 700S",
"label": "59368 / ZWA4012",
"manufacturer": "UltraPro"
},
"0x0063:0x4952:0x3339": {
"description": "In-Wall Outlet, TR, 700S",
"label": "58449 / ZWA1003",
Expand Down Expand Up @@ -5109,6 +5134,11 @@
"label": "YRD210",
"manufacturer": "Yale"
},
"0x0109:0x0004:0xffff": {
"description": "Push Button Deadbolt",
"label": "YRD210",
"manufacturer": "Yale"
},
"0x0109:0x1001:0x0101": {
"description": "USB Dongle",
"label": "ZU1401",
Expand Down Expand Up @@ -5899,6 +5929,11 @@
"label": "FGR223",
"manufacturer": "Fibargroup"
},
"0x010f:0x0304:0x1000": {
"description": "Roller Shutter 4",
"label": "FGR-224",
"manufacturer": "Fibargroup"
},
"0x010f:0x0400:0x0102": {
"description": "Relay Switch 1x3kW",
"label": "FGS211",
Expand Down Expand Up @@ -12525,6 +12560,11 @@
"label": "ZEN34",
"manufacturer": "Zooz"
},
"0x027a:0x7000:0xf003": {
"description": "Wall Remote",
"label": "ZEN37 800LR",
"manufacturer": "Zooz"
},
"0x027a:0xa000:0xa001": {
"description": "Z-Wave Plus S2 ON/OFF Switch",
"label": "ZEN26",
Expand Down Expand Up @@ -14396,6 +14436,11 @@
"label": "ZWA012",
"manufacturer": "Aeotec Ltd."
},
"0x0371:0x0202:0x0018": {
"description": "MultiSensor 7",
"label": "ZWA024",
"manufacturer": "Aeotec Ltd."
},
"0x0371:0x0202:0x0029": {
"description": "Door/Window Sensor 7",
"label": "ZWA011",
Expand Down Expand Up @@ -15351,5 +15396,5 @@
"label": "BW8120",
"manufacturer": "Remotec"
},
"updated_at": "2024-04-06T22:22:20.961929"
"updated_at": "2024-07-08T02:36:24.368049"
}
21 changes: 7 additions & 14 deletions vivintpy/zjs_device_config_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,20 @@

import json
import os
from typing import Final

ZJS_DEVICE_CONFIG_DB_FILE = os.path.join(
os.path.dirname(__file__), "zjs_device_config_db.json"
)
ZJS_DEVICE_DB: dict[str, str | dict[str, str]] = {}
with open(
os.path.join(os.path.dirname(__file__), "zjs_device_config_db.json"),
encoding="utf8",
) as file:
ZJS_DEVICE_DB: Final[dict[str, str | dict[str, str]]] = json.load(file)


def get_zwave_device_info(
manufacturer_id: int | None, product_type: int | None, product_id: int | None
) -> dict[str, str]:
"""Lookup the Z-Wave device based on the manufacturer id, product type and product id."""
key = f"0x{manufacturer_id:04x}:0x{product_type:04x}:0x{product_id:04x}"
if isinstance((device_info := _get_zjs_db().get(key)), dict):
if isinstance((device_info := ZJS_DEVICE_DB.get(key)), dict):
return device_info
return {}


def _get_zjs_db() -> dict[str, str | dict[str, str]]:
"""Load the Z-Wave JS device config from the saved JSON file."""
global ZJS_DEVICE_DB # pylint: disable=global-statement
if not ZJS_DEVICE_DB:
with open(ZJS_DEVICE_CONFIG_DB_FILE, encoding="utf-8") as device_file:
ZJS_DEVICE_DB = json.load(device_file)
return ZJS_DEVICE_DB

0 comments on commit 2fb27bf

Please sign in to comment.