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

feat: Add floor heating device #415

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
5 changes: 5 additions & 0 deletions PyViCare/PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import re

from PyViCare.PyViCareFloorHeating import FloorHeating
from PyViCare.PyViCareFuelCell import FuelCell
from PyViCare.PyViCareGazBoiler import GazBoiler
from PyViCare.PyViCareHeatingDevice import HeatingDevice
Expand Down Expand Up @@ -50,6 +51,9 @@ def asHybridDevice(self):
def asRadiatorActuator(self):
return RadiatorActuator(self.service)

def asFloorHeating(self):
return FloorHeating(self.service)

def asRoomSensor(self):
return RoomSensor(self.service)

Expand Down Expand Up @@ -87,6 +91,7 @@ def asAutoDetectDevice(self):
(self.asVentilation, r"E3_ViAir", ["type:ventilation;central"]),
(self.asVentilation, r"E3_VitoPure", ["type:ventilation;purifier"]),
(self.asRadiatorActuator, r"E3_RadiatorActuator", ["type:radiator"]),
(self.asFloorHeating, r"E3_FloorHeatingCircuitDistributorBox", ["type:fhtMain"]),
(self.asRoomSensor, r"E3_RoomSensor", ["type:climateSensor"]),
(self.asGateway, r"E3_TCU41_x04", ["type:gateway;TCU100"]),
(self.asGateway, r"E3_TCU19_x05", ["type:gateway;TCU200"]),
Expand Down
35 changes: 35 additions & 0 deletions PyViCare/PyViCareFloorHeating.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 FloorHeating(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"]

@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})
145 changes: 145 additions & 0 deletions tests/response/zigbee_fht.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"data": [
{
"apiVersion": 1,
"commands": {},
"deviceId": "zigbee-5cc7c1fffea25f73",
"feature": "device.messages.errors.raw",
"gatewayId": "################",
"isEnabled": true,
"isReady": true,
"properties": {
"entries": {
"type": "array",
"value": []
}
},
"timestamp": "2024-10-01T03:59:44.794Z",
"uri": "https://api.viessmann.com/iot/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/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/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/features/device.name/commands/setName"
}
},
"deviceId": "zigbee-5cc7c1fffea25f73",
"feature": "device.name",
"gatewayId": "################",
"isEnabled": true,
"isReady": true,
"properties": {
"name": {
"type": "string",
"value": ""
}
},
"timestamp": "2024-10-01T03:59:44.794Z",
"uri": "https://api.viessmann.com/iot/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/features/device.name"
},
{
"apiVersion": 1,
"commands": {},
"deviceId": "zigbee-5cc7c1fffea25f73",
"feature": "fht.operating.modes.active",
"gatewayId": "################",
"isEnabled": true,
"isReady": true,
"properties": {
"value": {
"type": "string",
"value": "standby"
}
},
"timestamp": "2024-10-01T03:59:44.794Z",
"uri": "https://api.viessmann.com/iot/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/features/fht.operating.modes.active"
},
{
"apiVersion": 1,
"commands": {},
"deviceId": "zigbee-5cc7c1fffea25f73",
"feature": "fht.operating.modes.cooling",
"gatewayId": "################",
"isEnabled": true,
"isReady": true,
"properties": {
"active": {
"type": "boolean",
"value": false
}
},
"timestamp": "2024-10-01T03:59:44.794Z",
"uri": "https://api.viessmann.com/iot/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/features/fht.operating.modes.cooling"
},
{
"apiVersion": 1,
"commands": {},
"deviceId": "zigbee-5cc7c1fffea25f73",
"feature": "fht.operating.modes.heating",
"gatewayId": "################",
"isEnabled": true,
"isReady": true,
"properties": {
"active": {
"type": "boolean",
"value": false
}
},
"timestamp": "2024-10-01T03:59:44.794Z",
"uri": "https://api.viessmann.com/iot/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/features/fht.operating.modes.heating"
},
{
"apiVersion": 1,
"commands": {},
"deviceId": "zigbee-5cc7c1fffea25f73",
"feature": "fht.operating.modes.standby",
"gatewayId": "################",
"isEnabled": true,
"isReady": true,
"properties": {
"active": {
"type": "boolean",
"value": true
}
},
"timestamp": "2024-10-01T03:59:44.794Z",
"uri": "https://api.viessmann.com/iot/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/features/fht.operating.modes.standby"
},
{
"apiVersion": 1,
"commands": {},
"deviceId": "zigbee-5cc7c1fffea25f73",
"feature": "fht.sensors.temperature.supply",
"gatewayId": "################",
"isEnabled": true,
"isReady": true,
"properties": {
"status": {
"type": "string",
"value": "connected"
},
"value": {
"type": "number",
"unit": "celsius",
"value": 21.9
}
},
"timestamp": "2024-10-01T11:06:25.941Z",
"uri": "https://api.viessmann.com/iot/v2/features/installations/#######/gateways/################/devices/zigbee-5cc7c1fffea25f73/features/fht.sensors.temperature.supply"
}
]
}
18 changes: 18 additions & 0 deletions tests/test_zigbee_fht.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import unittest

from PyViCare.PyViCareFloorHeating import FloorHeating
from tests.ViCareServiceMock import ViCareServiceMock


class ZK03840(unittest.TestCase):
def setUp(self):
self.service = ViCareServiceMock('response/zigbee_fht.json')
self.device = FloorHeating(self.service)

def test_getSerial(self):
self.assertEqual(
self.device.getSerial(), "zigbee-5cc7c1fffea25f73")

def test_getActiveMode(self):
self.assertEqual(
self.device.getActiveMode(), "standby")
Loading