From feb1fea9857b3b1cc38f26d0c7262d96387d1fd5 Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Sat, 2 Mar 2024 13:29:25 +0100 Subject: [PATCH 1/7] Create zigbee_fht.json --- tests/response/zigbee_fht.json | 128 +++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 tests/response/zigbee_fht.json diff --git a/tests/response/zigbee_fht.json b/tests/response/zigbee_fht.json new file mode 100644 index 00000000..941a01be --- /dev/null +++ b/tests/response/zigbee_fht.json @@ -0,0 +1,128 @@ +[ + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "device.messages.errors.raw", + "gatewayId": "################", + "isEnabled": false, + "isReady": true, + "properties": {}, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.messages.errors.raw" + }, + { + "apiVersion": 1, + "commands": { + "setName": { + "isExecutable": true, + "name": "setName", + "params": { + "name": { + "constraints": { + "maxLength": 40, + "minLength": 1, + "regEx": "^[\\p{L}0-9]+( [\\p{L}0-9]+)*$" + }, + "required": true, + "type": "string" + } + }, + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.name/commands/setName" + } + }, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "device.name", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "name": { + "type": "string", + "value": "" + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.name" + }, + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.active", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "value": { + "type": "string", + "value": "standby" + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.active" + }, + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.cooling", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "active": { + "type": "boolean", + "value": false + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.cooling" + }, + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.heating", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "active": { + "type": "boolean", + "value": false + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.heating" + }, + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.standby", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "active": { + "type": "boolean", + "value": true + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.standby" + }, + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.sensors.temperature.supply", + "gatewayId": "################", + "isEnabled": false, + "isReady": true, + "properties": {}, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.sensors.temperature.supply" + } +] From 3375c992344af7cf367554874348740ca43f9b94 Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 3 Apr 2024 10:31:44 +0200 Subject: [PATCH 2/7] add floorheating --- PyViCare/PyViCareFloorHeatingDevice.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 PyViCare/PyViCareFloorHeatingDevice.py diff --git a/PyViCare/PyViCareFloorHeatingDevice.py b/PyViCare/PyViCareFloorHeatingDevice.py new file mode 100644 index 00000000..f45ebf41 --- /dev/null +++ b/PyViCare/PyViCareFloorHeatingDevice.py @@ -0,0 +1,13 @@ +from PyViCare.PyViCareHeatingDevice import HeatingDevice +from PyViCare.PyViCareUtils import handleNotSupported + + +class RadiatorActuator(HeatingDevice): + + @handleNotSupported + def getSupplyTemperature(self): + return self.service.getProperty("fht.sensors.temperature.supply")["properties"]["value"]["value"] + + @handleNotSupported + def getActiveMode(self): + return self.service.getProperty("fht.operating.modes.active")["properties"]["value"]["value"] From 6c02930a07a24d988aa985093ee7a2c75d4e62ed Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Wed, 3 Apr 2024 10:31:53 +0200 Subject: [PATCH 3/7] add tests --- tests/test_zigbee_fht.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_zigbee_fht.py diff --git a/tests/test_zigbee_fht.py b/tests/test_zigbee_fht.py new file mode 100644 index 00000000..b593c78d --- /dev/null +++ b/tests/test_zigbee_fht.py @@ -0,0 +1,28 @@ +import unittest + +from PyViCare.PyViCareRadiatorActuator import RadiatorActuator +from tests.ViCareServiceMock import ViCareServiceMock + + +class ZK03840(unittest.TestCase): + def setUp(self): + self.service = ViCareServiceMock('response/zigbee_fht.json') + self.device = RadiatorActuator(self.service) + + def test_getTemperature(self): + self.assertEqual( + self.device.getTemperature(), 18.5) + + def test_getTargetTemperature(self): + self.assertEqual( + self.device.getTargetTemperature(), 18) + + def test_setTargetTemperature(self): + self.device.setTargetTemperature(22) + self.assertEqual(len(self.service.setPropertyData), 1) + self.assertEqual( + self.service.setPropertyData[0]['property_name'], 'trv.temperature') + self.assertEqual( + self.service.setPropertyData[0]['action'], 'setTargetTemperature') + self.assertEqual(self.service.setPropertyData[0]['data'], { + 'temperature': 22}) From f66068f465c1b24a67379f32e16f4f4cbccdf0d4 Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Fri, 24 May 2024 10:23:24 +0200 Subject: [PATCH 4/7] Update PyViCareFloorHeatingDevice.py --- PyViCare/PyViCareFloorHeatingDevice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PyViCare/PyViCareFloorHeatingDevice.py b/PyViCare/PyViCareFloorHeatingDevice.py index f45ebf41..21bde0e4 100644 --- a/PyViCare/PyViCareFloorHeatingDevice.py +++ b/PyViCare/PyViCareFloorHeatingDevice.py @@ -4,6 +4,10 @@ class RadiatorActuator(HeatingDevice): + @handleNotSupported + def getSerial(self): + return self.service.getProperty("device.name")["deviceId"] + @handleNotSupported def getSupplyTemperature(self): return self.service.getProperty("fht.sensors.temperature.supply")["properties"]["value"]["value"] From fad98d86c2b6ca9481f32b8ea19c335f1f133b14 Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Fri, 24 May 2024 10:24:29 +0200 Subject: [PATCH 5/7] Update test_zigbee_fht.py --- tests/test_zigbee_fht.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_zigbee_fht.py b/tests/test_zigbee_fht.py index b593c78d..e5693021 100644 --- a/tests/test_zigbee_fht.py +++ b/tests/test_zigbee_fht.py @@ -9,6 +9,10 @@ def setUp(self): self.service = ViCareServiceMock('response/zigbee_fht.json') self.device = RadiatorActuator(self.service) + def test_getSerial(self): + self.assertEqual( + self.device.getSerial(), "zigbee-1a1a1a1a1a1a1a1a") + def test_getTemperature(self): self.assertEqual( self.device.getTemperature(), 18.5) From f5d362a47a623e0e4832dd0a5475e9054b3f86c3 Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Fri, 24 May 2024 14:26:04 +0200 Subject: [PATCH 6/7] Update PyViCareFloorHeatingDevice.py --- PyViCare/PyViCareFloorHeatingDevice.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/PyViCare/PyViCareFloorHeatingDevice.py b/PyViCare/PyViCareFloorHeatingDevice.py index 21bde0e4..f1db1d5b 100644 --- a/PyViCare/PyViCareFloorHeatingDevice.py +++ b/PyViCare/PyViCareFloorHeatingDevice.py @@ -12,6 +12,24 @@ def getSerial(self): def getSupplyTemperature(self): return self.service.getProperty("fht.sensors.temperature.supply")["properties"]["value"]["value"] + @handleNotSupported + def getModes(self): + return self.service.getProperty("fht.operating.modes.active")["commands"]["setMode"]["params"]["mode"]["constraints"]["enum"] + @handleNotSupported def getActiveMode(self): return self.service.getProperty("fht.operating.modes.active")["properties"]["value"]["value"] + + def setMode(self, mode): + """ Set the active mode + Parameters + ---------- + mode : str + Valid mode can be obtained using getModes() + + Returns + ------- + result: json + json representation of the answer + """ + return self.service.setProperty("fht.operating.modes.active", "setMode", {'mode': mode}) From f21a1455097e90eb4e7e3d886d60ad00b114f327 Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:11:38 +0200 Subject: [PATCH 7/7] Update zigbee_fht.json --- tests/response/zigbee_fht.json | 246 +++++++++++++++++---------------- 1 file changed, 124 insertions(+), 122 deletions(-) diff --git a/tests/response/zigbee_fht.json b/tests/response/zigbee_fht.json index 941a01be..bb8eeff5 100644 --- a/tests/response/zigbee_fht.json +++ b/tests/response/zigbee_fht.json @@ -1,128 +1,130 @@ -[ - { - "apiVersion": 1, - "commands": {}, - "deviceId": "zigbee-1a1a1a1a1a1a1a1a", - "feature": "device.messages.errors.raw", - "gatewayId": "################", - "isEnabled": false, - "isReady": true, - "properties": {}, - "timestamp": "2024-03-01T04:40:59.911Z", - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.messages.errors.raw" - }, - { - "apiVersion": 1, - "commands": { - "setName": { - "isExecutable": true, - "name": "setName", - "params": { - "name": { - "constraints": { - "maxLength": 40, - "minLength": 1, - "regEx": "^[\\p{L}0-9]+( [\\p{L}0-9]+)*$" - }, - "required": true, - "type": "string" - } - }, - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.name/commands/setName" - } +{ + "data": [ + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "device.messages.errors.raw", + "gatewayId": "################", + "isEnabled": false, + "isReady": true, + "properties": {}, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.messages.errors.raw" }, - "deviceId": "zigbee-1a1a1a1a1a1a1a1a", - "feature": "device.name", - "gatewayId": "################", - "isEnabled": true, - "isReady": true, - "properties": { - "name": { - "type": "string", - "value": "" - } + { + "apiVersion": 1, + "commands": { + "setName": { + "isExecutable": true, + "name": "setName", + "params": { + "name": { + "constraints": { + "maxLength": 40, + "minLength": 1, + "regEx": "^[\\p{L}0-9]+( [\\p{L}0-9]+)*$" + }, + "required": true, + "type": "string" + } + }, + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.name/commands/setName" + } + }, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "device.name", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "name": { + "type": "string", + "value": "" + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.name" }, - "timestamp": "2024-03-01T04:40:59.911Z", - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/device.name" - }, - { - "apiVersion": 1, - "commands": {}, - "deviceId": "zigbee-1a1a1a1a1a1a1a1a", - "feature": "fht.operating.modes.active", - "gatewayId": "################", - "isEnabled": true, - "isReady": true, - "properties": { - "value": { - "type": "string", - "value": "standby" - } + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.active", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "value": { + "type": "string", + "value": "standby" + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.active" }, - "timestamp": "2024-03-01T04:40:59.911Z", - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.active" - }, - { - "apiVersion": 1, - "commands": {}, - "deviceId": "zigbee-1a1a1a1a1a1a1a1a", - "feature": "fht.operating.modes.cooling", - "gatewayId": "################", - "isEnabled": true, - "isReady": true, - "properties": { - "active": { - "type": "boolean", - "value": false - } + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.cooling", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "active": { + "type": "boolean", + "value": false + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.cooling" }, - "timestamp": "2024-03-01T04:40:59.911Z", - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.cooling" - }, - { - "apiVersion": 1, - "commands": {}, - "deviceId": "zigbee-1a1a1a1a1a1a1a1a", - "feature": "fht.operating.modes.heating", - "gatewayId": "################", - "isEnabled": true, - "isReady": true, - "properties": { - "active": { - "type": "boolean", - "value": false - } + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.heating", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "active": { + "type": "boolean", + "value": false + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.heating" }, - "timestamp": "2024-03-01T04:40:59.911Z", - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.heating" - }, - { - "apiVersion": 1, - "commands": {}, - "deviceId": "zigbee-1a1a1a1a1a1a1a1a", - "feature": "fht.operating.modes.standby", - "gatewayId": "################", - "isEnabled": true, - "isReady": true, - "properties": { - "active": { - "type": "boolean", - "value": true - } + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.operating.modes.standby", + "gatewayId": "################", + "isEnabled": true, + "isReady": true, + "properties": { + "active": { + "type": "boolean", + "value": true + } + }, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.standby" }, - "timestamp": "2024-03-01T04:40:59.911Z", - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.operating.modes.standby" - }, - { - "apiVersion": 1, - "commands": {}, - "deviceId": "zigbee-1a1a1a1a1a1a1a1a", - "feature": "fht.sensors.temperature.supply", - "gatewayId": "################", - "isEnabled": false, - "isReady": true, - "properties": {}, - "timestamp": "2024-03-01T04:40:59.911Z", - "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.sensors.temperature.supply" - } -] + { + "apiVersion": 1, + "commands": {}, + "deviceId": "zigbee-1a1a1a1a1a1a1a1a", + "feature": "fht.sensors.temperature.supply", + "gatewayId": "################", + "isEnabled": false, + "isReady": true, + "properties": {}, + "timestamp": "2024-03-01T04:40:59.911Z", + "uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/zigbee-1a1a1a1a1a1a1a1a/features/fht.sensors.temperature.supply" + } + ] +}