Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add floor heating device class #362

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions PyViCare/PyViCareFloorHeatingDevice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from PyViCare.PyViCareHeatingDevice import HeatingDevice
from PyViCare.PyViCareUtils import handleNotSupported


class RadiatorActuator(HeatingDevice):

@handleNotSupported
def getSerial(self):
return self.service.getProperty("device.name")["deviceId"]
Copy link
Member Author

@CFenner CFenner May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get via device.name as long as no device.serial is provided by Viessmann.


@handleNotSupported
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})
130 changes: 130 additions & 0 deletions tests/response/zigbee_fht.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"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"
},
{
"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"
}
]
}
32 changes: 32 additions & 0 deletions tests/test_zigbee_fht.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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_getSerial(self):
self.assertEqual(
self.device.getSerial(), "zigbee-1a1a1a1a1a1a1a1a")

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})
Loading