Skip to content

Commit

Permalink
Merge branch 'release/0.0.38'
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey committed Apr 1, 2020
2 parents b7d2af9 + b58a550 commit fe754af
Show file tree
Hide file tree
Showing 8 changed files with 510 additions and 4 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.37"
VERSION = "0.0.38"


def readme():
Expand Down
50 changes: 50 additions & 0 deletions tests/test_ctrl_neutral1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Tests for xiaomi."""
from unittest import mock
from unittest.mock import call

import zigpy.application
from zigpy.device import Device

from zhaquirks.xiaomi.aqara.ctrl_neutral1 import CtrlNeutral1


# zigbee-herdsman:controller:endpoint Command 0x00158d00024be541/2 genOnOff.on({},
# {"timeout":6000,"manufacturerCode":null,"disableDefaultResponse":false})
# zigbee-herdsman:adapter:zStack:znp:SREQ --> AF - dataRequest -
# {"dstaddr":65311,"destendpoint":2,"srcendpoint":1,"clusterid":6,"transid":17,"options":0,"radius":30,"len":3,
# "data":{"type":"Buffer","data":[1,8,1]}}
# zigbee-herdsman:adapter:zStack:unpi:writer -->frame [254,13,36,1,31,255,2,1,6,0,17,0,30,3,1,8,1,201]


# zigbee-herdsman:controller:endpoint Command 0x00158d00024be541/2 genOnOff.off({},
# {"timeout":6000,"manufacturerCode":null,"disableDefaultResponse":false})
# zigbee-herdsman:adapter:zStack:znp:SREQ --> AF - dataRequest -
# {"dstaddr":65311,"destendpoint":2,"srcendpoint":1,"clusterid":6,"transid":16,"options":0,"radius":30,"len":3,
# "data":{"type":"Buffer","data":[1,7,0]}}
# zigbee-herdsman:adapter:zStack:unpi:writer --> frame [254,13,36,1,31,255,2,1,6,0,16,0,30,3,1,7,0,198]


def test_ctrl_neutral1():
"""Test ctrl neutral 1 sends correct request."""
sec = 8
ieee = 0
nwk = 1234
data = b"\x01\x08\x01"
cluster = 6
src_ep = 1
dst_ep = 2

app = zigpy.application.ControllerApplication()
app.request = mock.MagicMock()
app.get_sequence = mock.MagicMock(return_value=sec)

rep = Device(app, ieee, nwk)
rep.add_endpoint(1)
rep.add_endpoint(2)

dev = CtrlNeutral1(app, ieee, nwk, rep)
dev[2].in_clusters[cluster].command(1)

assert app.request.call_args == call(
dev, 260, cluster, src_ep, dst_ep, sec, data, expect_reply=True
)
1 change: 1 addition & 0 deletions zhaquirks/echostar/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Module for Echostar quirks implementations."""
87 changes: 87 additions & 0 deletions zhaquirks/echostar/bell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
"""Echostar Sage Doorbell Sensor Device."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
Alarms,
Basic,
Identify,
LevelControl,
OnOff,
Ota,
PowerConfiguration,
)

from ..const import (
BUTTON_1,
BUTTON_2,
CLUSTER_ID,
COMMAND,
COMMAND_ON,
COMMAND_OFF,
DEVICE_TYPE,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
)

MANUFACTURER = " Echostar"
MODEL = " Bell"


class Bell(CustomDevice):
"""Echostar Bell device."""

signature = {
# <SimpleDescriptor endpoint=18 profile=260 device_type=260
# device_version=0
# input_clusters=[0, 3, 9, 1]
# output_clusters=[3, 6, 8, 25]>
MODELS_INFO: [(MANUFACTURER, MODEL)],
ENDPOINTS: {
18: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.DIMMER_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PowerConfiguration.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
},
}

replacement = {
ENDPOINTS: {
18: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
INPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Alarms.cluster_id,
PowerConfiguration.cluster_id,
],
OUTPUT_CLUSTERS: [
Identify.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
Ota.cluster_id,
],
}
}
}
device_automation_triggers = {
(SHORT_PRESS, BUTTON_1): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 18},
(SHORT_PRESS, BUTTON_2): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 18},
}
49 changes: 49 additions & 0 deletions zhaquirks/konke/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,52 @@ def __init__(self, *args, **kwargs):
}
}
}


class KonkeMotionB(CustomDevice):
"""Custom device representing konke motion sensors."""

def __init__(self, *args, **kwargs):
"""Init."""
self.occupancy_bus = Bus()
super().__init__(*args, **kwargs)

signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 1280]
# output_clusters=[3]>
MODELS_INFO: [
(KONKE, "3AFE28010402000D"),
(KONKE, "3AFE14010402000D"),
(KONKE, "3AFE27010402000D"),
],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.IAS_ZONE,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
IasZone.cluster_id,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
}
},
}

replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfigurationCluster,
Identify.cluster_id,
OccupancyCluster,
MotionCluster,
],
OUTPUT_CLUSTERS: [Identify.cluster_id],
}
}
}
139 changes: 139 additions & 0 deletions zhaquirks/philips/rwl020.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
"""Phillips RWL020 device."""
from zigpy.profiles import zha, zll
from zigpy.quirks import CustomCluster, CustomDevice
import zigpy.types as t
from zigpy.zcl.clusters.general import (
Basic,
BinaryInput,
Groups,
Identify,
LevelControl,
OnOff,
Ota,
PowerConfiguration,
)

from ..const import (
ARGS,
CLUSTER_ID,
COMMAND,
COMMAND_OFF_WITH_EFFECT,
COMMAND_ON,
COMMAND_STEP,
DEVICE_TYPE,
DIM_DOWN,
DIM_UP,
ENDPOINT_ID,
ENDPOINTS,
INPUT_CLUSTERS,
LONG_PRESS,
OUTPUT_CLUSTERS,
PROFILE_ID,
SHORT_PRESS,
TURN_OFF,
TURN_ON,
)

DIAGNOSTICS_CLUSTER_ID = 0x0B05 # decimal = 2821


class BasicCluster(CustomCluster, Basic):
"""Centralite acceleration cluster."""

attributes = Basic.attributes.copy()
attributes.update({0x0031: ("phillips", t.bitmap16)})


class PhilipsRWL020(CustomDevice):
"""Phillips RWL020 device."""

signature = {
# <SimpleDescriptor endpoint=1 profile=49246 device_type=2080
# device_version=2
# input_clusters=[0]
# output_clusters=[0, 3, 4, 6, 8]>
ENDPOINTS: {
1: {
PROFILE_ID: zll.PROFILE_ID,
DEVICE_TYPE: zll.DeviceType.CONTROLLER,
INPUT_CLUSTERS: [Basic.cluster_id],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
},
# <SimpleDescriptor endpoint=2 profile=260 device_type=12
# device_version=0
# input_clusters=[0, 1, 3, 15, 64512]
# output_clusters=[25]>
2: {
PROFILE_ID: zha.PROFILE_ID,
DEVICE_TYPE: zha.DeviceType.SIMPLE_SENSOR,
INPUT_CLUSTERS: [
Basic.cluster_id,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
64512,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
}
}

replacement = {
ENDPOINTS: {
1: {
INPUT_CLUSTERS: [Basic.cluster_id],
OUTPUT_CLUSTERS: [
Basic.cluster_id,
Identify.cluster_id,
Groups.cluster_id,
OnOff.cluster_id,
LevelControl.cluster_id,
],
},
2: {
INPUT_CLUSTERS: [
BasicCluster,
PowerConfiguration.cluster_id,
Identify.cluster_id,
BinaryInput.cluster_id,
64512,
],
OUTPUT_CLUSTERS: [Ota.cluster_id],
},
}
}

device_automation_triggers = {
(SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON},
(SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF_WITH_EFFECT},
(SHORT_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
ARGS: [0, 30, 9],
},
(LONG_PRESS, DIM_UP): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
ARGS: [0, 56, 9],
},
(SHORT_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
ARGS: [1, 30, 9],
},
(LONG_PRESS, DIM_DOWN): {
COMMAND: COMMAND_STEP,
CLUSTER_ID: 8,
ENDPOINT_ID: 1,
ARGS: [1, 56, 9],
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
)


class SmartThingsMotionV4(CustomDevice):
"""SmartThingsMotionV4."""
class SmartThingsMotion(CustomDevice):
"""SmartThingsMotionV4 or V5."""

signature = {
# <SimpleDescriptor endpoint=1 profile=260 device_type=1026
# device_version=0
# input_clusters=[0, 1, 3, 15, 1026, 1280, 32]
# output_clusters=[25]>
MODELS_INFO: [(SMART_THINGS, "motionv4")],
MODELS_INFO: [(SMART_THINGS, "motionv4"), (SMART_THINGS, "motionv5")],
ENDPOINTS: {
1: {
PROFILE_ID: zha.PROFILE_ID,
Expand Down
Loading

0 comments on commit fe754af

Please sign in to comment.