Skip to content

Commit

Permalink
Merge branch 'release/0.0.52'
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey committed Jan 20, 2021
2 parents 4bf6e8a + 608ab7c commit 6bd2bcf
Show file tree
Hide file tree
Showing 31 changed files with 739 additions and 34 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from setuptools import find_packages, setup

VERSION = "0.0.51"
VERSION = "0.0.52"


def readme():
Expand Down
10 changes: 10 additions & 0 deletions tests/test_quirks.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,13 @@ def _check_range(cluster):
node_desc = ep_data.get(NODE_DESCRIPTOR)
if node_desc is not None:
assert isinstance(node_desc, zigpy.zdo.types.NodeDescriptor)


@pytest.mark.parametrize("quirk", ALL_QUIRK_CLASSES)
def test_quirk_importable(quirk):
"""Ensure all quirks can be imported with a normal Python `import` statement."""

path = f"{quirk.__module__}.{quirk.__name__}"
assert all(
[m and m.isidentifier() for m in path.split(".")]
), f"{path} is not importable"
28 changes: 26 additions & 2 deletions tests/test_xiaomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,19 @@ class XiaomiQuirk(XiaomiQuickInitDevice):
assert raw_device.application.device_initialized.call_count == 1


@pytest.mark.parametrize("voltage, bpr", ((3000, 200), (2800, 0), (2600, 0)))
@pytest.mark.parametrize(
"voltage, bpr",
(
(3240, 200),
(3200, 200),
(3000, 129),
(2985, 118),
(2860, 29),
(2845, 18),
(2830, 7),
(2600, 0),
),
)
async def test_xiaomi_battery(zigpy_device_from_quirk, voltage, bpr):
"""Test xiaomi batter voltage to % battery left."""
data_1 = b'\x1c_\x11I\n\x01\xffB"\x01!'
Expand All @@ -264,7 +276,19 @@ async def test_xiaomi_battery(zigpy_device_from_quirk, voltage, bpr):
assert power_cluster["battery_percentage_remaining"] == bpr


@pytest.mark.parametrize("voltage, bpr", ((3000, 200), (2800, 0), (2600, 0)))
@pytest.mark.parametrize(
"voltage, bpr",
(
(3240, 200),
(3200, 200),
(3000, 129),
(2985, 118),
(2860, 29),
(2845, 18),
(2830, 7),
(2600, 0),
),
)
async def test_mija_battery(zigpy_device_from_quirk, voltage, bpr):
"""Test xiaomi batter voltage to % battery left."""
data_1 = b"\x1c4\x12\x02\n\x02\xffL\x06\x00\x10\x01!"
Expand Down
6 changes: 2 additions & 4 deletions zhaquirks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,8 @@ def _calculate_battery_percentage(self, raw_value):
((volts - self.MIN_VOLTS) / (self.MAX_VOLTS - self.MIN_VOLTS)) * 200
)

_LOGGER.debug(
"%s %s, Voltage [RAW]:%s [Max]:%s [Min]:%s, Battery Percent: %s",
self.endpoint.device.manufacturer,
self.endpoint.device.model,
self.debug(
"Voltage [RAW]:%s [Max]:%s [Min]:%s, Battery Percent: %s",
raw_value,
self.MAX_VOLTS,
self.MIN_VOLTS,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
68 changes: 68 additions & 0 deletions zhaquirks/osram/osramplug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""Osram Smart+ Plug device."""
from zigpy.profiles import zll
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import Basic, Groups, Identify, OnOff, Ota, Scenes
from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
from zigpy.zcl.clusters.lightlink import LightLink

from . import OSRAM, OsramLightCluster
from ..const import (
DEVICE_TYPE,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
)


class OsramPlug(CustomDevice):
"""Osram Smart+ Plug."""

signature = {
MODELS_INFO: [(OSRAM, "Plug 01")],
ENDPOINTS: {
# <SimpleDescriptor endpoint=3 profile=49246 device_type=16
# device_version=2
# input_clusters=[4096, 0, 3, 4, 5, 6, 2820, 64527]
# output_clusters=[25]>
3: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.ON_OFF_PLUGIN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
ElectricalMeasurement.cluster_id,
LightLink.cluster_id,
OsramLightCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}

replacement = {
ENDPOINTS: {
3: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.ON_OFF_PLUGIN_UNIT,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
Scenes.cluster_id,
OnOff.cluster_id,
LightLink.cluster_id,
OsramLightCluster.cluster_id,
],
OUTPUT_CLUSTERS: [
Ota.cluster_id,
],
},
},
}
1 change: 1 addition & 0 deletions zhaquirks/philips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

DIAGNOSTICS_CLUSTER_ID = 0x0B05 # decimal = 2821
PHILIPS = "Philips"
SIGNIFY = "Signify Netherlands B.V."
_LOGGER = logging.getLogger(__name__)

HUE_REMOTE_DEVICE_TRIGGERS = {
Expand Down
20 changes: 15 additions & 5 deletions zhaquirks/philips/rom001.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@
from . import PhilipsBasicCluster, PhilipsRemoteCluster
from ..const import (
COMMAND,
COMMAND_OFF_WITH_EFFECT,
COMMAND_ON,
DEVICE_TYPE,
DOUBLE_PRESS,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
LONG_RELEASE,
OUTPUT_CLUSTERS,
PROFILE_ID,
QUADRUPLE_PRESS,
QUINTUPLE_PRESS,
SHORT_PRESS,
TURN_OFF,
SHORT_RELEASE,
TRIPLE_PRESS,
TURN_ON,
)

Expand Down Expand Up @@ -91,6 +95,12 @@ class PhilipsROM001(CustomDevice):
}

device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON},
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF_WITH_EFFECT},
(SHORT_PRESS, TURN_ON): {COMMAND: "on_press"},
(LONG_PRESS, TURN_ON): {COMMAND: "on_hold"},
(DOUBLE_PRESS, TURN_ON): {COMMAND: "on_double_press"},
(TRIPLE_PRESS, TURN_ON): {COMMAND: "on_triple_press"},
(QUADRUPLE_PRESS, TURN_ON): {COMMAND: "on_quadruple_press"},
(QUINTUPLE_PRESS, TURN_ON): {COMMAND: "on_quintuple_press"},
(SHORT_RELEASE, TURN_ON): {COMMAND: "on_short_release"},
(LONG_RELEASE, TURN_ON): {COMMAND: "on_long_release"},
}
9 changes: 7 additions & 2 deletions zhaquirks/philips/zhadimmablelight.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
OUTPUT_CLUSTERS,
PROFILE_ID,
)
from zhaquirks.philips import PHILIPS, PhilipsLevelControlCluster, PhilipsOnOffCluster
from zhaquirks.philips import (
PHILIPS,
SIGNIFY,
PhilipsLevelControlCluster,
PhilipsOnOffCluster,
)


class ZHADimmableLight(CustomDevice):
"""Philips ZigBee HomeAutomation dimmable bulb device."""

signature = {
MODELS_INFO: [(PHILIPS, "LWV001")],
MODELS_INFO: [(PHILIPS, "LWV001"), (SIGNIFY, "LWV001")],
ENDPOINTS: {
11: {
# <SimpleDescriptor endpoint=11 profile=260 device_type=528
Expand Down
14 changes: 14 additions & 0 deletions zhaquirks/philips/zhaextendedcolorlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)
from zhaquirks.philips import (
PHILIPS,
SIGNIFY,
PhilipsColorCluster,
PhilipsLevelControlCluster,
PhilipsOnOffCluster,
Expand All @@ -40,6 +41,11 @@ class ZHAExtendedColorLight(CustomDevice):
(PHILIPS, "LCB001"),
(PHILIPS, "LCE002"),
(PHILIPS, "LCG002"),
(SIGNIFY, "LCA001"),
(SIGNIFY, "LCA003"),
(SIGNIFY, "LCB001"),
(SIGNIFY, "LCE002"),
(SIGNIFY, "LCG002"),
],
ENDPOINTS: {
11: {
Expand Down Expand Up @@ -112,8 +118,16 @@ class ZHAExtendedColorLight2(CustomDevice):
MODELS_INFO: [
(PHILIPS, "LCL001"),
(PHILIPS, "LCT026"),
(PHILIPS, "4090330P9_01"),
(PHILIPS, "4090330P9_02"),
(PHILIPS, "929002376001"),
(PHILIPS, "929002375901"),
(SIGNIFY, "LCL001"),
(SIGNIFY, "LCT026"),
(SIGNIFY, "4090330P9_01"),
(SIGNIFY, "4090330P9_02"),
(SIGNIFY, "929002376001"),
(SIGNIFY, "929002375901"),
],
ENDPOINTS: {
11: {
Expand Down
1 change: 1 addition & 0 deletions zhaquirks/philips/zllextendedcolorlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ZLLExtendedColorLight(CustomDevice):
(PHILIPS, "LLC020"),
(PHILIPS, "LCF002"),
(PHILIPS, "LCS001"),
(PHILIPS, "LST004"),
],
ENDPOINTS: {
11: {
Expand Down
1 change: 1 addition & 0 deletions zhaquirks/sengled/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module for Sengled quirks implementations."""
Loading

0 comments on commit 6bd2bcf

Please sign in to comment.