Skip to content

Commit 60b0337

Browse files
authored
feat: Expose error messages (#448)
* Update PyViCareDevice.py * Create device_error.json * Create test_device_error.py * Update PyViCareDevice.py * Update test_device_error.py * Update PyViCareDevice.py * Rename tests/response/device_error.json to tests/response/deviceerrors/F.1100.json * Update test_device_error.py
1 parent af4154c commit 60b0337

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

PyViCare/PyViCareDevice.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
from PyViCare.PyViCareService import ViCareService
24
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError, handleNotSupported
35

@@ -16,6 +18,10 @@ def __init__(self, service: ViCareService) -> None:
1618
def getSerial(self):
1719
return self.service.getProperty("device.serial")["properties"]["value"]["value"]
1820

21+
@handleNotSupported
22+
def getDeviceErrors(self) -> list[Any]:
23+
return list[Any](self.service.getProperty("device.messages.errors.raw")["properties"]["entries"]["value"])
24+
1925
def isLegacyDevice(self) -> bool:
2026
return self.service.hasRoles(["type:legacy"])
2127

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"data": [
3+
{
4+
"apiVersion": 1,
5+
"commands": {},
6+
"deviceId": "0",
7+
"feature": "device.messages.errors.raw",
8+
"gatewayId": "################",
9+
"isEnabled": true,
10+
"isReady": true,
11+
"properties": {
12+
"entries": {
13+
"type": "array",
14+
"value": [
15+
{
16+
"accessLevel": "customer",
17+
"audiences": [
18+
"IS-SUPPLIER",
19+
"IS-DEVELOPMENT",
20+
"IS-MANUFACTURING",
21+
"IS-AFTERSALES",
22+
"IS-AFTERMARKET",
23+
"IS-DEVELOPER-VEG",
24+
"IS-BIG-DATA",
25+
"IS-MANUFACTURING-VEG"
26+
],
27+
"errorCode": "F.1100",
28+
"priority": "criticalError",
29+
"timestamp": "2000-07-22T20:37:44.000Z"
30+
}
31+
]
32+
}
33+
},
34+
"timestamp": "2024-10-30T08:53:23.913Z",
35+
"uri": "https://api.viessmann.com/iot/v1/features/installations/#######/gateways/################/devices/0/features/device.messages.errors.raw"
36+
}
37+
]
38+
}

tests/test_device_error.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
3+
from PyViCare.PyViCareDevice import Device
4+
from tests.ViCareServiceMock import ViCareServiceMock
5+
6+
7+
class DeviceErrorTest(unittest.TestCase):
8+
def setUp(self):
9+
self.service = ViCareServiceMock('response/deviceerrors/F.1100.json')
10+
self.device = Device(self.service)
11+
12+
def test_deviceErrors(self):
13+
errors = self.device.getDeviceErrors()
14+
self.assertEqual(len(errors), 1)
15+
self.assertEqual(errors[0]["errorCode"], "F.1100")
16+
self.assertEqual(errors[0]["priority"], "criticalError")

0 commit comments

Comments
 (0)