PyViCare 2.65.0__tar.gz → 2.67.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PKG-INFO +29 -6
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareAbstractOAuthManager.py +1 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareDevice.py +44 -0
- pyvicare-2.67.0/PyViCare/PyViCareEvent.py +105 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareFuelCell.py +32 -4
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareGazBoiler.py +25 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareHeatPump.py +10 -3
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareHeatingDevice.py +239 -18
- pyvicare-2.67.0/PyViCare/PyViCareService.py +192 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/README.md +28 -5
- {pyvicare-2.65.0 → pyvicare-2.67.0}/pyproject.toml +3 -3
- pyvicare-2.65.0/PyViCare/PyViCareService.py +0 -75
- {pyvicare-2.65.0 → pyvicare-2.67.0}/.gitignore +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/LICENSE +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/Feature.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCare.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareBrowserOAuthManager.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareCachedService.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareCachedServiceBase.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareCachedServiceViaGateway.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareDeviceConfig.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareElectricalEnergySystem.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareFloorHeating.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareGateway.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareHeatCurveCalculation.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareHybrid.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareOAuthManager.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareOilBoiler.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCarePelletsBoiler.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareRadiatorActuator.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareRepeater.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareRoomControl.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareRoomSensor.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareServiceViaGateway.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareUtils.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareVentilationDevice.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/PyViCareWaterTreatment.py +0 -0
- {pyvicare-2.65.0 → pyvicare-2.67.0}/PyViCare/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: PyViCare
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.67.0
|
|
4
4
|
Summary: Library to communicate with the Viessmann ViCare API.
|
|
5
5
|
Project-URL: Homepage, https://github.com/openviess/PyViCare
|
|
6
6
|
Project-URL: Repository, https://github.com/openviess/PyViCare
|
|
@@ -81,6 +81,30 @@ Depending on the device, some features are not available/supported. This results
|
|
|
81
81
|
|
|
82
82
|
Tip: You can use Pythons [contextlib.suppress](https://docs.python.org/3/library/contextlib.html#contextlib.suppress) to handle it gracefully.
|
|
83
83
|
|
|
84
|
+
### Error events
|
|
85
|
+
|
|
86
|
+
`getDeviceErrors()` reads a feature that some gateways do not offer. The event
|
|
87
|
+
history keeps those errors, including the ones that already cleared:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
for event in device.getErrorEvents(limit=10):
|
|
91
|
+
state = "active" if event.active else "cleared"
|
|
92
|
+
print(event.event_timestamp, state, event.error_code, event.error_description)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`active=True` is the raise, `active=False` the clear, so the event of an error
|
|
96
|
+
code with the latest `event_timestamp` is its current state. `getErrorEvents()`
|
|
97
|
+
asks the API for its gateway serial and filters the page by device id, so
|
|
98
|
+
`limit` counts that gateway's events. Paging and other event types are on
|
|
99
|
+
`device.service.fetch_events()`.
|
|
100
|
+
|
|
101
|
+
`getDeviceStatusMessages()`, `getDeviceServiceMessages()` and
|
|
102
|
+
`getDeviceInfoMessages()` return the current status, service and info messages
|
|
103
|
+
the same way `getDeviceErrors()` returns the errors, each entry with
|
|
104
|
+
`errorCode`, `priority` and `timestamp`. An empty list means there is no such
|
|
105
|
+
message right now; a device without the feature raises
|
|
106
|
+
`PyViCareNotSupportedFeatureError`.
|
|
107
|
+
|
|
84
108
|
## Types of heatings
|
|
85
109
|
|
|
86
110
|
- Use `asGazBoiler` for gas heatings
|
|
@@ -124,13 +148,12 @@ print(circuit.getHeatingCurveSlope())
|
|
|
124
148
|
print(circuit.getActiveProgram())
|
|
125
149
|
print(circuit.getPrograms())
|
|
126
150
|
|
|
127
|
-
print(circuit.
|
|
128
|
-
print(circuit.
|
|
151
|
+
print(circuit.getActiveProgramTemperature())
|
|
152
|
+
print(circuit.getComfortTemperature())
|
|
129
153
|
print(circuit.getActiveMode())
|
|
130
154
|
|
|
131
|
-
print(circuit.
|
|
132
|
-
print(circuit.
|
|
133
|
-
print(circuit.activateProgram("comfort"))
|
|
155
|
+
print(circuit.setComfortTemperature(21))
|
|
156
|
+
print(circuit.activateComfort())
|
|
134
157
|
print(circuit.deactivateComfort())
|
|
135
158
|
|
|
136
159
|
burner = t.burners[0] #select burner
|
|
@@ -136,6 +136,7 @@ class AbstractViCareOAuthManager:
|
|
|
136
136
|
f"{API_BASE_URL}{url}", data, headers=headers)
|
|
137
137
|
self.__raise_on_non_json_error(raw_response)
|
|
138
138
|
response = raw_response.json()
|
|
139
|
+
logger.debug("Response to post request: %s", response)
|
|
139
140
|
self.__handle_expired_token(response)
|
|
140
141
|
self.__handle_rate_limit(response)
|
|
141
142
|
self.__handle_command_error(response)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
from datetime import date, datetime
|
|
1
2
|
from typing import Any
|
|
2
3
|
|
|
4
|
+
from PyViCare.PyViCareEvent import EVENT_TYPE_DEVICE_ERROR, ViCareEvent
|
|
3
5
|
from PyViCare.PyViCareService import ViCareDeviceAccessor, ViCareService, hasRoles
|
|
4
6
|
from PyViCare.PyViCareUtils import (
|
|
5
7
|
PyViCareNotSupportedFeatureError,
|
|
@@ -34,6 +36,26 @@ class Device:
|
|
|
34
36
|
def getDeviceErrors(self) -> list[Any]:
|
|
35
37
|
return list[Any](self.getProperty("device.messages.errors.raw")["properties"]["entries"]["value"])
|
|
36
38
|
|
|
39
|
+
@handleNotSupported
|
|
40
|
+
def getDeviceStatusMessages(self) -> list[Any]:
|
|
41
|
+
return list[Any](self.getProperty("device.messages.status.raw")["properties"]["entries"]["value"])
|
|
42
|
+
|
|
43
|
+
@handleNotSupported
|
|
44
|
+
def getDeviceServiceMessages(self) -> list[Any]:
|
|
45
|
+
return list[Any](self.getProperty("device.messages.service.raw")["properties"]["entries"]["value"])
|
|
46
|
+
|
|
47
|
+
@handleNotSupported
|
|
48
|
+
def getDeviceInfoMessages(self) -> list[Any]:
|
|
49
|
+
return list[Any](self.getProperty("device.messages.info.raw")["properties"]["entries"]["value"])
|
|
50
|
+
|
|
51
|
+
@handleNotSupported
|
|
52
|
+
def getMalfunctionLockActive(self) -> bool:
|
|
53
|
+
return bool(self.getProperty("device.lock.malfunction")["properties"]["active"]["value"])
|
|
54
|
+
|
|
55
|
+
@handleNotSupported
|
|
56
|
+
def getExternalLockActive(self) -> bool:
|
|
57
|
+
return bool(self.getProperty("device.lock.external")["properties"]["active"]["value"])
|
|
58
|
+
|
|
37
59
|
# Power consumption limitation (§14a EnWG):
|
|
38
60
|
@handleNotSupported
|
|
39
61
|
def getPowerConsumptionLimit(self) -> int:
|
|
@@ -64,6 +86,28 @@ class Device:
|
|
|
64
86
|
def getPowerProductionLimitStatus(self) -> str:
|
|
65
87
|
return str(self.getProperty("device.power.statusReport.production")["properties"]["status"]["value"])
|
|
66
88
|
|
|
89
|
+
def getErrorEvents(self,
|
|
90
|
+
*,
|
|
91
|
+
last_days: int | None = None,
|
|
92
|
+
since: datetime | None = None,
|
|
93
|
+
on_date: date | None = None,
|
|
94
|
+
limit: int | None = 10) -> list[ViCareEvent]:
|
|
95
|
+
"""Device errors of this device, in the order the API returns them.
|
|
96
|
+
|
|
97
|
+
The API is asked for this gateway (`gatewaySerials`) and the page is
|
|
98
|
+
then filtered by device id, so `limit` counts this gateway's events.
|
|
99
|
+
|
|
100
|
+
An error comes as two events: `active` is True when it was raised and
|
|
101
|
+
False when it was cleared. For paging and other event types use
|
|
102
|
+
`service.fetch_events()`.
|
|
103
|
+
"""
|
|
104
|
+
page = self.service.fetch_events(
|
|
105
|
+
self.accessor, EVENT_TYPE_DEVICE_ERROR,
|
|
106
|
+
last_days=last_days, since=since, on_date=on_date,
|
|
107
|
+
gateway_serials=self.accessor.serial, limit=limit)
|
|
108
|
+
return [event for event in page.events
|
|
109
|
+
if event.device_id == self.accessor.device_id]
|
|
110
|
+
|
|
67
111
|
def isLegacyDevice(self) -> bool:
|
|
68
112
|
return hasRoles(["type:legacy"], self.roles)
|
|
69
113
|
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""Events from the Viessmann event history.
|
|
2
|
+
|
|
3
|
+
The event history keeps past device errors. The ``device.messages.errors.raw``
|
|
4
|
+
feature is missing on some gateways, and ``heating.burners.0.errorStatus`` only
|
|
5
|
+
holds the current value.
|
|
6
|
+
|
|
7
|
+
A device error appears as two events: one with ``active`` set to True when the
|
|
8
|
+
fault was raised, one with ``active`` set to False when it was cleared. The
|
|
9
|
+
newest event of an error code tells you whether that error still stands.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
EVENT_TYPE_DEVICE_ERROR = "device-error"
|
|
16
|
+
|
|
17
|
+
# Event types of the EventHistory-v2 service (from its OpenAPI document):
|
|
18
|
+
#
|
|
19
|
+
# gateway scoped, selected with the gatewaySerials parameter:
|
|
20
|
+
# device-error, device-message-info, device-message-service,
|
|
21
|
+
# device-message-status, device-message-warning, feature-changed,
|
|
22
|
+
# firmware-update-status, gateway-online, gateway-reset-command,
|
|
23
|
+
# device-bmu-serial-changed, device-boiler-serial-changed,
|
|
24
|
+
# src-status-changed, remote-diagnose-session-opened,
|
|
25
|
+
# remote-diagnose-session-closed
|
|
26
|
+
# installation scoped:
|
|
27
|
+
# installation-address-changed, invitation-accepted,
|
|
28
|
+
# invitation-terminated, geofencing-activation-changed,
|
|
29
|
+
# diy-heating-rod-run-too-long, diy-heating-curve-not-optimal,
|
|
30
|
+
# diy-dhw-schedule-not-optimal, dynamic-smart-tip,
|
|
31
|
+
# snapshot-restore-status-changed
|
|
32
|
+
#
|
|
33
|
+
# The API does not validate the value: an unknown type returns an empty list
|
|
34
|
+
# instead of an error, and names are matched exactly. Several values can be
|
|
35
|
+
# combined with commas, the API ORs them.
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _as_dict(value: Any) -> dict[str, Any]:
|
|
39
|
+
return value if isinstance(value, dict) else {}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _as_str(value: Any) -> str | None:
|
|
43
|
+
return value if isinstance(value, str) else None
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _as_bool(value: Any) -> bool:
|
|
47
|
+
return value is True
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _as_datetime(value: Any) -> datetime | None:
|
|
51
|
+
if not isinstance(value, str):
|
|
52
|
+
return None
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
return datetime.fromisoformat(value)
|
|
56
|
+
except ValueError:
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class ViCareEvent:
|
|
61
|
+
"""One entry of the event history."""
|
|
62
|
+
|
|
63
|
+
# pylint: disable=too-many-instance-attributes
|
|
64
|
+
def __init__(self, raw: dict[str, Any]) -> None:
|
|
65
|
+
body = _as_dict(raw.get("body"))
|
|
66
|
+
|
|
67
|
+
self.raw = raw
|
|
68
|
+
self.event_type = _as_str(raw.get("eventType")) or ""
|
|
69
|
+
self.gateway_serial = _as_str(raw.get("gatewaySerial"))
|
|
70
|
+
self.device_id = _as_str(body.get("deviceId"))
|
|
71
|
+
self.error_code = _as_str(body.get("errorCode"))
|
|
72
|
+
self.error_description = _as_str(body.get("errorDescription"))
|
|
73
|
+
self.error_event_type = _as_str(body.get("errorEventType"))
|
|
74
|
+
self.equipment_type = _as_str(body.get("equipmentType"))
|
|
75
|
+
self.model_id = _as_str(body.get("modelId"))
|
|
76
|
+
self.active = _as_bool(body.get("active"))
|
|
77
|
+
self.event_timestamp = _as_datetime(raw.get("eventTimestamp"))
|
|
78
|
+
self.created_at = _as_datetime(raw.get("createdAt"))
|
|
79
|
+
self.origin = _as_str(raw.get("origin"))
|
|
80
|
+
|
|
81
|
+
def __repr__(self) -> str:
|
|
82
|
+
return (
|
|
83
|
+
f"ViCareEvent({self.event_type}, error={self.error_code}, "
|
|
84
|
+
f"active={self.active}, at={self.event_timestamp})"
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class ViCareEventPage:
|
|
89
|
+
"""One page of the event history, with the cursor for the next page."""
|
|
90
|
+
|
|
91
|
+
def __init__(self, events: list[ViCareEvent], next_cursor: str | None, raw: dict[str, Any]) -> None:
|
|
92
|
+
self.events = events
|
|
93
|
+
self.next_cursor = next_cursor
|
|
94
|
+
self.raw = raw
|
|
95
|
+
|
|
96
|
+
@classmethod
|
|
97
|
+
def from_payload(cls, payload: dict[str, Any]) -> "ViCareEventPage":
|
|
98
|
+
data = payload.get("data")
|
|
99
|
+
entries = data if isinstance(data, list) else []
|
|
100
|
+
events = [ViCareEvent(entry) for entry in entries if isinstance(entry, dict)]
|
|
101
|
+
cursor = _as_str(_as_dict(payload.get("cursor")).get("next")) or None
|
|
102
|
+
return cls(events, cursor, payload)
|
|
103
|
+
|
|
104
|
+
def __repr__(self) -> str:
|
|
105
|
+
return f"ViCareEventPage({len(self.events)} events, next={self.next_cursor!r})"
|
|
@@ -165,10 +165,6 @@ class FuelCell(HeatingDevice):
|
|
|
165
165
|
def getDomesticHotWaterMinTemperatureLevel(self):
|
|
166
166
|
return self.getProperty("heating.dhw.temperature.levels")["properties"]["min"]["value"]
|
|
167
167
|
|
|
168
|
-
@handleNotSupported
|
|
169
|
-
def getHydraulicSeparatorTemperature(self):
|
|
170
|
-
return self.getProperty("heating.sensors.temperature.hydraulicSeparator")["properties"]["value"]["value"]
|
|
171
|
-
|
|
172
168
|
# ---- Actual FuelCell-relevant methods (they require paid "Advanced" API plan):
|
|
173
169
|
|
|
174
170
|
@handleNotSupported
|
|
@@ -298,6 +294,38 @@ class FuelCell(HeatingDevice):
|
|
|
298
294
|
# Returns flow supply temperature at the fuel cell as float
|
|
299
295
|
return float(self.getProperty("fuelCell.sensors.temperature.supply")["properties"]["value"]["value"])
|
|
300
296
|
|
|
297
|
+
@handleNotSupported
|
|
298
|
+
def getFuelCellPredictedPowerConsumptionUnit(self) -> str:
|
|
299
|
+
return str(self.getProperty("fuelCell.managers.energy.prediction.power.consumption")["properties"]["value"]["unit"])
|
|
300
|
+
|
|
301
|
+
@handleNotSupported
|
|
302
|
+
def getFuelCellPredictedPowerConsumption(self) -> float:
|
|
303
|
+
return float(self.getProperty("fuelCell.managers.energy.prediction.power.consumption")["properties"]["value"]["value"])
|
|
304
|
+
|
|
305
|
+
@handleNotSupported
|
|
306
|
+
def getFuelCellPredictedRuntimeUnit(self) -> str:
|
|
307
|
+
return str(self.getProperty("fuelCell.managers.energy.prediction.runtime")["properties"]["value"]["unit"])
|
|
308
|
+
|
|
309
|
+
@handleNotSupported
|
|
310
|
+
def getFuelCellPredictedRuntime(self) -> float:
|
|
311
|
+
return float(self.getProperty("fuelCell.managers.energy.prediction.runtime")["properties"]["value"]["value"])
|
|
312
|
+
|
|
313
|
+
@handleNotSupported
|
|
314
|
+
def getFuelCellTimeTillNextStartUnit(self) -> str:
|
|
315
|
+
return str(self.getProperty("fuelCell.managers.energy.timeTillNextStart")["properties"]["value"]["unit"])
|
|
316
|
+
|
|
317
|
+
@handleNotSupported
|
|
318
|
+
def getFuelCellTimeTillNextStart(self) -> float:
|
|
319
|
+
return float(self.getProperty("fuelCell.managers.energy.timeTillNextStart")["properties"]["value"]["value"])
|
|
320
|
+
|
|
321
|
+
@handleNotSupported
|
|
322
|
+
def getFuelCellPredictedHeatingDeficitUnit(self) -> str:
|
|
323
|
+
return str(self.getProperty("fuelCell.prediction.heating.deficit")["properties"]["value"]["unit"])
|
|
324
|
+
|
|
325
|
+
@handleNotSupported
|
|
326
|
+
def getFuelCellPredictedHeatingDeficit(self) -> float:
|
|
327
|
+
return float(self.getProperty("fuelCell.prediction.heating.deficit")["properties"]["value"]["value"])
|
|
328
|
+
|
|
301
329
|
@handleNotSupported
|
|
302
330
|
def getFuelCellOperationHours(self) -> int:
|
|
303
331
|
# Returns the operation hours of the fuel cell
|
|
@@ -8,6 +8,12 @@ from PyViCare.PyViCareHeatingDevice import (
|
|
|
8
8
|
from PyViCare.PyViCareUtils import handleNotSupported
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
def _burner_stop_reasons(feature: Any) -> list[str]:
|
|
12
|
+
# Every reason comes as "<reason>AllStops"; "timeAllStops" is no reason.
|
|
13
|
+
return sorted(name.removesuffix("AllStops") for name in feature["properties"]
|
|
14
|
+
if name.endswith("AllStops") and name != "timeAllStops")
|
|
15
|
+
|
|
16
|
+
|
|
11
17
|
class GazBoiler(HeatingDevice):
|
|
12
18
|
|
|
13
19
|
@property
|
|
@@ -313,6 +319,25 @@ class GazBoiler(HeatingDevice):
|
|
|
313
319
|
# Returns heating supply pressure
|
|
314
320
|
return float(self.getProperty("heating.sensors.pressure.supply")["properties"]["value"]["value"])
|
|
315
321
|
|
|
322
|
+
# Burner stops per reason (device.timeseries.burner.stops):
|
|
323
|
+
@handleNotSupported
|
|
324
|
+
def getBurnerStopReasons(self) -> list[str]:
|
|
325
|
+
return _burner_stop_reasons(self.getProperty("device.timeseries.burner.stops"))
|
|
326
|
+
|
|
327
|
+
@handleNotSupported
|
|
328
|
+
def getBurnerStopsAll(self, reason: str) -> int:
|
|
329
|
+
return int(self.getProperty("device.timeseries.burner.stops")["properties"][f"{reason}AllStops"]["value"])
|
|
330
|
+
|
|
331
|
+
# Burner stops per reason during domestic hot water heating (device.timeseries.dhw.burner.stops):
|
|
332
|
+
@handleNotSupported
|
|
333
|
+
def getDomesticHotWaterBurnerStopReasons(self) -> list[str]:
|
|
334
|
+
return _burner_stop_reasons(self.getProperty("device.timeseries.dhw.burner.stops"))
|
|
335
|
+
|
|
336
|
+
@handleNotSupported
|
|
337
|
+
def getDomesticHotWaterBurnerStopsAll(self, reason: str) -> int:
|
|
338
|
+
return int(self.getProperty("device.timeseries.dhw.burner.stops")["properties"][f"{reason}AllStops"]["value"])
|
|
339
|
+
|
|
340
|
+
|
|
316
341
|
class GazBurner(HeatingDeviceWithComponent):
|
|
317
342
|
|
|
318
343
|
@property
|
|
@@ -278,13 +278,20 @@ class HeatPump(HeatingDevice, VentilationDevice):
|
|
|
278
278
|
def getAvailableVentilationPrograms(self):
|
|
279
279
|
return self.getVentilationPrograms()
|
|
280
280
|
|
|
281
|
+
def _getDomesticHotWaterHysteresisValue(self, name: str) -> float:
|
|
282
|
+
# some devices serve a value they do not have as {"type": "any", "value": null}
|
|
283
|
+
value = self.getProperty("heating.dhw.temperature.hysteresis")["properties"][name]["value"]
|
|
284
|
+
if value is None:
|
|
285
|
+
raise PyViCareNotSupportedFeatureError(name)
|
|
286
|
+
return float(value)
|
|
287
|
+
|
|
281
288
|
@handleNotSupported
|
|
282
289
|
def getDomesticHotWaterHysteresisUnit(self) -> str:
|
|
283
290
|
return str(self.getProperty("heating.dhw.temperature.hysteresis")["properties"]["value"]["unit"])
|
|
284
291
|
|
|
285
292
|
@handleNotSupported
|
|
286
293
|
def getDomesticHotWaterHysteresis(self) -> float:
|
|
287
|
-
return
|
|
294
|
+
return self._getDomesticHotWaterHysteresisValue("value")
|
|
288
295
|
|
|
289
296
|
@handleNotSupported
|
|
290
297
|
def getDomesticHotWaterHysteresisMin(self) -> float:
|
|
@@ -315,7 +322,7 @@ class HeatPump(HeatingDevice, VentilationDevice):
|
|
|
315
322
|
|
|
316
323
|
@handleNotSupported
|
|
317
324
|
def getDomesticHotWaterHysteresisSwitchOn(self) -> float:
|
|
318
|
-
return
|
|
325
|
+
return self._getDomesticHotWaterHysteresisValue("switchOnValue")
|
|
319
326
|
|
|
320
327
|
@handleNotSupported
|
|
321
328
|
def getDomesticHotWaterHysteresisSwitchOnMin(self) -> float:
|
|
@@ -346,7 +353,7 @@ class HeatPump(HeatingDevice, VentilationDevice):
|
|
|
346
353
|
|
|
347
354
|
@handleNotSupported
|
|
348
355
|
def getDomesticHotWaterHysteresisSwitchOff(self) -> float:
|
|
349
|
-
return
|
|
356
|
+
return self._getDomesticHotWaterHysteresisValue("switchOffValue")
|
|
350
357
|
|
|
351
358
|
@handleNotSupported
|
|
352
359
|
def getDomesticHotWaterHysteresisSwitchOffMin(self) -> float:
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
# pylint: disable=too-many-lines
|
|
1
2
|
from contextlib import suppress
|
|
2
3
|
from typing import Any
|
|
3
4
|
|
|
5
|
+
from deprecated import deprecated
|
|
6
|
+
|
|
4
7
|
from PyViCare.PyViCareDevice import Device
|
|
5
8
|
from PyViCare.PyViCareHeatCurveCalculation import (
|
|
6
9
|
heat_curve_formular_variant1,
|
|
@@ -73,6 +76,10 @@ class HeatingDevice(Device):
|
|
|
73
76
|
def getOutsideTemperature(self):
|
|
74
77
|
return self.getProperty("heating.sensors.temperature.outside")["properties"]["value"]["value"]
|
|
75
78
|
|
|
79
|
+
@handleNotSupported
|
|
80
|
+
def getHydraulicSeparatorTemperature(self):
|
|
81
|
+
return self.getProperty("heating.sensors.temperature.hydraulicSeparator")["properties"]["value"]["value"]
|
|
82
|
+
|
|
76
83
|
@handleNotSupported
|
|
77
84
|
def getDomesticHotWaterConfiguredTemperature(self):
|
|
78
85
|
return self.getProperty("heating.dhw.temperature.main")["properties"]["value"]["value"]
|
|
@@ -154,6 +161,22 @@ class HeatingDevice(Device):
|
|
|
154
161
|
"properties"]["status"]["value"]
|
|
155
162
|
return status == 'on'
|
|
156
163
|
|
|
164
|
+
@handleNotSupported
|
|
165
|
+
def getBoilerInternalPumpActive(self):
|
|
166
|
+
status = self.getProperty("heating.boiler.pumps.internal")[
|
|
167
|
+
"properties"]["status"]["value"]
|
|
168
|
+
return status == 'on'
|
|
169
|
+
|
|
170
|
+
@handleNotSupported
|
|
171
|
+
def getBoilerInternalPumpCurrent(self) -> float:
|
|
172
|
+
"""Current modulation of the boiler's internal pump, in percent."""
|
|
173
|
+
return float(self.getProperty("heating.boiler.pumps.internal.current")["properties"]["value"]["value"])
|
|
174
|
+
|
|
175
|
+
@handleNotSupported
|
|
176
|
+
def getBoilerInternalPumpTarget(self) -> float:
|
|
177
|
+
"""Target modulation of the boiler's internal pump, in percent."""
|
|
178
|
+
return float(self.getProperty("heating.boiler.pumps.internal.target")["properties"]["value"]["value"])
|
|
179
|
+
|
|
157
180
|
@handleNotSupported
|
|
158
181
|
def getDomesticHotWaterActive(self):
|
|
159
182
|
status = self.getProperty("heating.dhw")["properties"]["status"]["value"]
|
|
@@ -205,6 +228,41 @@ class HeatingDevice(Device):
|
|
|
205
228
|
return self.setProperty("heating.dhw.temperature.temp2", "setTargetTemperature",
|
|
206
229
|
{"temperature": int(temperature)})
|
|
207
230
|
|
|
231
|
+
@handleNotSupported
|
|
232
|
+
def getDomesticHotWaterHygieneTemperature(self):
|
|
233
|
+
return self.getProperty("heating.dhw.temperature.hygiene")["properties"]["value"]["value"]
|
|
234
|
+
|
|
235
|
+
@handleNotSupported
|
|
236
|
+
def getDomesticHotWaterHygieneTemperatureMin(self):
|
|
237
|
+
return self.getProperty("heating.dhw.temperature.hygiene")["commands"]["setTemperature"]["params"][
|
|
238
|
+
"targetTemperature"]["constraints"]["min"]
|
|
239
|
+
|
|
240
|
+
@handleNotSupported
|
|
241
|
+
def getDomesticHotWaterHygieneTemperatureMax(self):
|
|
242
|
+
return self.getProperty("heating.dhw.temperature.hygiene")["commands"]["setTemperature"]["params"][
|
|
243
|
+
"targetTemperature"]["constraints"]["max"]
|
|
244
|
+
|
|
245
|
+
@handleNotSupported
|
|
246
|
+
def getDomesticHotWaterHygieneTemperatureStepping(self):
|
|
247
|
+
return self.getProperty("heating.dhw.temperature.hygiene")["commands"]["setTemperature"]["params"][
|
|
248
|
+
"targetTemperature"]["constraints"]["stepping"]
|
|
249
|
+
|
|
250
|
+
@handleAPICommandErrors
|
|
251
|
+
def setDomesticHotWaterHygieneTemperature(self, temperature):
|
|
252
|
+
""" Set the target temperature of the domestic hot water hygiene function
|
|
253
|
+
Parameters
|
|
254
|
+
----------
|
|
255
|
+
temperature : int
|
|
256
|
+
Target temperature
|
|
257
|
+
|
|
258
|
+
Returns
|
|
259
|
+
-------
|
|
260
|
+
result: json
|
|
261
|
+
json representation of the answer
|
|
262
|
+
"""
|
|
263
|
+
return self.setProperty("heating.dhw.temperature.hygiene", "setTemperature",
|
|
264
|
+
{"targetTemperature": int(temperature)})
|
|
265
|
+
|
|
208
266
|
@handleNotSupported
|
|
209
267
|
def getDomesticHotWaterOperatingModes(self):
|
|
210
268
|
return self.getProperty("heating.dhw.operating.modes.active")[
|
|
@@ -423,6 +481,78 @@ class HeatingDevice(Device):
|
|
|
423
481
|
return s["mode"]
|
|
424
482
|
return schedule['default_mode']
|
|
425
483
|
|
|
484
|
+
@handleNotSupported
|
|
485
|
+
def getDomesticHotWaterHygieneEnabled(self) -> bool:
|
|
486
|
+
return bool(self.getProperty("heating.dhw.hygiene")["properties"]["enabled"]["value"])
|
|
487
|
+
|
|
488
|
+
@handleNotSupported
|
|
489
|
+
def getDomesticHotWaterHygieneActive(self) -> bool:
|
|
490
|
+
"""Whether the hygiene heat-up is running right now.
|
|
491
|
+
|
|
492
|
+
Served only by devices that have the function enabled: one with it
|
|
493
|
+
switched off carries `enabled` alone, and this raises
|
|
494
|
+
PyViCareNotSupportedFeatureError there.
|
|
495
|
+
"""
|
|
496
|
+
return bool(self.getProperty("heating.dhw.hygiene")["properties"]["active"]["value"])
|
|
497
|
+
|
|
498
|
+
@handleAPICommandErrors
|
|
499
|
+
def setDomesticHotWaterHygieneEnabled(self, enabled: bool) -> Any:
|
|
500
|
+
"""Enable or disable the hygiene function.
|
|
501
|
+
|
|
502
|
+
Two generations of commands sit on the same feature: the newer
|
|
503
|
+
`setEnabled` takes the flag as a parameter, the older `enable`/`disable`
|
|
504
|
+
pair carries it in the command name. The newer one is preferred, the
|
|
505
|
+
pair is the fallback for devices that only serve it.
|
|
506
|
+
|
|
507
|
+
Which of the two a device accepts also depends on its state - while the
|
|
508
|
+
function is off only `enable` is executable, and the other way round -
|
|
509
|
+
so a refused command surfaces as PyViCareCommandError.
|
|
510
|
+
"""
|
|
511
|
+
feature = self.getProperty("heating.dhw.hygiene")
|
|
512
|
+
commands = feature.get("commands") or {}
|
|
513
|
+
if "setEnabled" in commands:
|
|
514
|
+
return self.setProperty("heating.dhw.hygiene", "setEnabled", {'enabled': enabled})
|
|
515
|
+
return self.setProperty("heating.dhw.hygiene", "enable" if enabled else "disable", {})
|
|
516
|
+
|
|
517
|
+
@handleNotSupported
|
|
518
|
+
def getDomesticHotWaterHygieneTriggerStartHour(self) -> int:
|
|
519
|
+
"""Hour at which the hygiene heat-up starts.
|
|
520
|
+
|
|
521
|
+
`heating.dhw.hygiene.trigger` carries no properties while the function
|
|
522
|
+
is disabled, so this raises PyViCareNotSupportedFeatureError there.
|
|
523
|
+
"""
|
|
524
|
+
return int(self.getProperty("heating.dhw.hygiene.trigger")["properties"]["startHour"]["value"])
|
|
525
|
+
|
|
526
|
+
@handleNotSupported
|
|
527
|
+
def getDomesticHotWaterHygieneTriggerStartMinute(self) -> int:
|
|
528
|
+
"""Minute at which the hygiene heat-up starts."""
|
|
529
|
+
return int(self.getProperty("heating.dhw.hygiene.trigger")["properties"]["startMinute"]["value"])
|
|
530
|
+
|
|
531
|
+
@handleNotSupported
|
|
532
|
+
def getDomesticHotWaterHygieneTriggerWeekdays(self) -> list[str]:
|
|
533
|
+
"""Weekdays on which the hygiene heat-up runs.
|
|
534
|
+
|
|
535
|
+
One entry for a weekly heat-up, all seven for a daily one - the API
|
|
536
|
+
knows no separate daily flag. Abbreviated as the API reports them,
|
|
537
|
+
`Mon` to `Sun`.
|
|
538
|
+
"""
|
|
539
|
+
return list(self.getProperty("heating.dhw.hygiene.trigger")["properties"]["weekdays"]["value"])
|
|
540
|
+
|
|
541
|
+
@handleAPICommandErrors
|
|
542
|
+
def setDomesticHotWaterHygieneTriggerDaily(self, startHour: int, startMinute: int) -> Any:
|
|
543
|
+
"""Run the hygiene heat-up every day at the given time."""
|
|
544
|
+
return self.setProperty("heating.dhw.hygiene.trigger", "triggerDaily",
|
|
545
|
+
{'startHour': startHour, 'startMinute': startMinute})
|
|
546
|
+
|
|
547
|
+
@handleAPICommandErrors
|
|
548
|
+
def setDomesticHotWaterHygieneTriggerOncePerWeek(self, weekday: str, startHour: int, startMinute: int) -> Any:
|
|
549
|
+
"""Run the hygiene heat-up once a week, on `weekday` at the given time.
|
|
550
|
+
|
|
551
|
+
`weekday` is the abbreviation the API uses, `Mon` to `Sun`.
|
|
552
|
+
"""
|
|
553
|
+
return self.setProperty("heating.dhw.hygiene.trigger", "triggerOncePerWeek",
|
|
554
|
+
{'weekday': weekday, 'startHour': startHour, 'startMinute': startMinute})
|
|
555
|
+
|
|
426
556
|
@handleNotSupported
|
|
427
557
|
def getAvailableCircuits(self):
|
|
428
558
|
return self.getProperty("heating.circuits")["properties"]["enabled"]["value"]
|
|
@@ -431,6 +561,17 @@ class HeatingDevice(Device):
|
|
|
431
561
|
def getControllerSerial(self):
|
|
432
562
|
return self.getProperty("heating.controller.serial")["properties"]["value"]["value"]
|
|
433
563
|
|
|
564
|
+
@handleNotSupported
|
|
565
|
+
def getBufferCylinderSize(self) -> float:
|
|
566
|
+
"""Configured size of the heating water buffer cylinder, in litres.
|
|
567
|
+
|
|
568
|
+
`heating.configuration.bufferCylinderSize` is a commissioning
|
|
569
|
+
parameter, not a measurement. Devices report 0 here while still
|
|
570
|
+
serving buffer cylinder temperatures, so a 0 does not imply that no
|
|
571
|
+
buffer cylinder is present.
|
|
572
|
+
"""
|
|
573
|
+
return float(self.getProperty("heating.configuration.bufferCylinderSize")["properties"]["value"]["value"])
|
|
574
|
+
|
|
434
575
|
@handleNotSupported
|
|
435
576
|
def getBoilerSerial(self):
|
|
436
577
|
return self.getProperty("heating.boiler.serial")["properties"]["value"]["value"]
|
|
@@ -534,6 +675,35 @@ class HeatingDevice(Device):
|
|
|
534
675
|
def getHeatProductionSummaryDomesticHotWaterLastYear(self) -> float:
|
|
535
676
|
return float(self.getProperty("heating.heat.production.summary.dhw")["properties"]["lastYear"]["value"])
|
|
536
677
|
|
|
678
|
+
# Heat production summary for cooling:
|
|
679
|
+
@handleNotSupported
|
|
680
|
+
def getHeatProductionSummaryCoolingUnit(self) -> str:
|
|
681
|
+
return str(self.getProperty("heating.heat.production.summary.cooling")["properties"]["currentDay"]["unit"])
|
|
682
|
+
|
|
683
|
+
@handleNotSupported
|
|
684
|
+
def getHeatProductionSummaryCoolingCurrentDay(self) -> float:
|
|
685
|
+
return float(self.getProperty("heating.heat.production.summary.cooling")["properties"]["currentDay"]["value"])
|
|
686
|
+
|
|
687
|
+
@handleNotSupported
|
|
688
|
+
def getHeatProductionSummaryCoolingCurrentMonth(self) -> float:
|
|
689
|
+
return float(self.getProperty("heating.heat.production.summary.cooling")["properties"]["currentMonth"]["value"])
|
|
690
|
+
|
|
691
|
+
@handleNotSupported
|
|
692
|
+
def getHeatProductionSummaryCoolingCurrentYear(self) -> float:
|
|
693
|
+
return float(self.getProperty("heating.heat.production.summary.cooling")["properties"]["currentYear"]["value"])
|
|
694
|
+
|
|
695
|
+
@handleNotSupported
|
|
696
|
+
def getHeatProductionSummaryCoolingLastMonth(self) -> float:
|
|
697
|
+
return float(self.getProperty("heating.heat.production.summary.cooling")["properties"]["lastMonth"]["value"])
|
|
698
|
+
|
|
699
|
+
@handleNotSupported
|
|
700
|
+
def getHeatProductionSummaryCoolingLastSevenDays(self) -> float:
|
|
701
|
+
return float(self.getProperty("heating.heat.production.summary.cooling")["properties"]["lastSevenDays"]["value"])
|
|
702
|
+
|
|
703
|
+
@handleNotSupported
|
|
704
|
+
def getHeatProductionSummaryCoolingLastYear(self) -> float:
|
|
705
|
+
return float(self.getProperty("heating.heat.production.summary.cooling")["properties"]["lastYear"]["value"])
|
|
706
|
+
|
|
537
707
|
|
|
538
708
|
class HeatingDeviceWithComponent:
|
|
539
709
|
"""This is the base class for all heating components"""
|
|
@@ -552,6 +722,10 @@ class HeatingDeviceWithComponent:
|
|
|
552
722
|
|
|
553
723
|
|
|
554
724
|
class HeatingCircuit(HeatingDeviceWithComponent):
|
|
725
|
+
def __init__(self, device: HeatingDevice, component: str) -> None:
|
|
726
|
+
super().__init__(device, component)
|
|
727
|
+
self._programAliases: dict[str, str] = {}
|
|
728
|
+
|
|
555
729
|
@property
|
|
556
730
|
def circuit(self) -> str:
|
|
557
731
|
return self.component
|
|
@@ -572,6 +746,26 @@ class HeatingCircuit(HeatingDeviceWithComponent):
|
|
|
572
746
|
f"heating.circuits.{self.circuit}.operating.modes.active", "setMode", {'mode': mode})
|
|
573
747
|
return r
|
|
574
748
|
|
|
749
|
+
@handleNotSupported
|
|
750
|
+
def getProgramTemperature(self, program: str):
|
|
751
|
+
feature = self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}")
|
|
752
|
+
return feature["properties"]["temperature"]["value"]
|
|
753
|
+
|
|
754
|
+
@handleNotSupported
|
|
755
|
+
def getReducedTemperature(self):
|
|
756
|
+
program = self.resolveProgramName("reduced")
|
|
757
|
+
return self.getProgramTemperature(program)
|
|
758
|
+
|
|
759
|
+
@handleNotSupported
|
|
760
|
+
def getComfortTemperature(self):
|
|
761
|
+
program = self.resolveProgramName("comfort")
|
|
762
|
+
return self.getProgramTemperature(program)
|
|
763
|
+
|
|
764
|
+
@handleNotSupported
|
|
765
|
+
def getNormalTemperature(self):
|
|
766
|
+
program = self.resolveProgramName("normal")
|
|
767
|
+
return self.getProgramTemperature(program)
|
|
768
|
+
|
|
575
769
|
def setProgramTemperature(self, program: str, temperature: float):
|
|
576
770
|
# Works for normal, reduced, comfort
|
|
577
771
|
# active has no action
|
|
@@ -595,13 +789,16 @@ class HeatingCircuit(HeatingDeviceWithComponent):
|
|
|
595
789
|
"setTemperature", {'targetTemperature': float(temperature)})
|
|
596
790
|
|
|
597
791
|
def setReducedTemperature(self, temperature):
|
|
598
|
-
|
|
792
|
+
program = self.resolveProgramName("reduced")
|
|
793
|
+
return self.setProgramTemperature(program, temperature)
|
|
599
794
|
|
|
600
795
|
def setComfortTemperature(self, temperature):
|
|
601
|
-
|
|
796
|
+
program = self.resolveProgramName("comfort")
|
|
797
|
+
return self.setProgramTemperature(program, temperature)
|
|
602
798
|
|
|
603
799
|
def setNormalTemperature(self, temperature):
|
|
604
|
-
|
|
800
|
+
program = self.resolveProgramName("normal")
|
|
801
|
+
return self.setProgramTemperature(program, temperature)
|
|
605
802
|
|
|
606
803
|
@handleNotSupported
|
|
607
804
|
def getActive(self):
|
|
@@ -615,6 +812,20 @@ class HeatingCircuit(HeatingDeviceWithComponent):
|
|
|
615
812
|
def getType(self):
|
|
616
813
|
return self.getProperty(f"heating.circuits.{self.circuit}")["properties"]["type"]["value"]
|
|
617
814
|
|
|
815
|
+
@handleNotSupported
|
|
816
|
+
def getActiveProgramTemperature(self):
|
|
817
|
+
active_program = self.getActiveProgram()
|
|
818
|
+
try:
|
|
819
|
+
feature = self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{active_program}")
|
|
820
|
+
return feature["properties"]["temperature"]["value"]
|
|
821
|
+
except (PyViCareNotSupportedFeatureError, KeyError):
|
|
822
|
+
match active_program:
|
|
823
|
+
case "standby":
|
|
824
|
+
return None
|
|
825
|
+
case "holiday":
|
|
826
|
+
return self.getReducedTemperature()
|
|
827
|
+
raise
|
|
828
|
+
|
|
618
829
|
@handleNotSupported
|
|
619
830
|
def getActiveProgramMinTemperature(self):
|
|
620
831
|
active_program = self.getActiveProgram()
|
|
@@ -674,7 +885,8 @@ class HeatingCircuit(HeatingDeviceWithComponent):
|
|
|
674
885
|
{})
|
|
675
886
|
|
|
676
887
|
def activateComfort(self):
|
|
677
|
-
|
|
888
|
+
program = self.resolveProgramName("comfort")
|
|
889
|
+
return self.activateProgram(program)
|
|
678
890
|
|
|
679
891
|
def deactivateProgram(self, program):
|
|
680
892
|
""" Deactivate a program
|
|
@@ -692,7 +904,8 @@ class HeatingCircuit(HeatingDeviceWithComponent):
|
|
|
692
904
|
"deactivate", {})
|
|
693
905
|
|
|
694
906
|
def deactivateComfort(self):
|
|
695
|
-
|
|
907
|
+
program = self.resolveProgramName("comfort")
|
|
908
|
+
return self.deactivateProgram(program)
|
|
696
909
|
|
|
697
910
|
@handleNotSupported
|
|
698
911
|
def getSupplyTemperature(self):
|
|
@@ -789,25 +1002,33 @@ class HeatingCircuit(HeatingDeviceWithComponent):
|
|
|
789
1002
|
'normalCoolingEnergySaving', 'normalEnergySaving', 'normalHeating', 'reduced', 'reducedCooling',
|
|
790
1003
|
'reducedCoolingEnergySaving', 'reducedEnergySaving', 'reducedHeating', 'standby']:
|
|
791
1004
|
with suppress(PyViCareNotSupportedFeatureError):
|
|
792
|
-
|
|
793
|
-
|
|
1005
|
+
feature = self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}")
|
|
1006
|
+
if feature is not None and "properties" in feature:
|
|
794
1007
|
available_programs.append(program)
|
|
795
1008
|
|
|
796
1009
|
return available_programs
|
|
797
1010
|
|
|
798
|
-
|
|
1011
|
+
def resolveProgramName(self, program: str) -> str:
|
|
1012
|
+
if program not in ["reduced", "comfort", "normal"]:
|
|
1013
|
+
return program
|
|
1014
|
+
|
|
1015
|
+
if program not in self._programAliases:
|
|
1016
|
+
program_alias = program
|
|
1017
|
+
with suppress(PyViCareNotSupportedFeatureError):
|
|
1018
|
+
feature = self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}Heating")
|
|
1019
|
+
if feature is not None and "properties" in feature:
|
|
1020
|
+
program_alias = f"{program}Heating"
|
|
1021
|
+
self._programAliases[program] = program_alias
|
|
1022
|
+
|
|
1023
|
+
return self._programAliases[program]
|
|
1024
|
+
|
|
1025
|
+
@deprecated(reason="renamed, use getProgramTemperature", version="2.66.0")
|
|
799
1026
|
def getDesiredTemperatureForProgram(self, program):
|
|
800
|
-
return
|
|
801
|
-
self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}")["properties"][
|
|
802
|
-
"temperature"]["value"]
|
|
1027
|
+
return self.getProgramTemperature(program)
|
|
803
1028
|
|
|
804
|
-
@
|
|
1029
|
+
@deprecated(reason="renamed, use getActiveProgramTemperature", version="2.66.0")
|
|
805
1030
|
def getCurrentDesiredTemperature(self):
|
|
806
|
-
|
|
807
|
-
if active_program in ['standby']:
|
|
808
|
-
return None
|
|
809
|
-
return self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{active_program}")[
|
|
810
|
-
"properties"]["temperature"]["value"]
|
|
1031
|
+
return self.getActiveProgramTemperature()
|
|
811
1032
|
|
|
812
1033
|
@handleNotSupported
|
|
813
1034
|
def getFrostProtectionActive(self):
|
|
@@ -864,7 +1085,7 @@ class HeatingCircuit(HeatingDeviceWithComponent):
|
|
|
864
1085
|
shift = None
|
|
865
1086
|
slope = None
|
|
866
1087
|
with suppress(PyViCareNotSupportedFeatureError):
|
|
867
|
-
inside = self.
|
|
1088
|
+
inside = self.getActiveProgramTemperature()
|
|
868
1089
|
outside = self.device.getOutsideTemperature()
|
|
869
1090
|
shift = self.getHeatingCurveShift()
|
|
870
1091
|
slope = self.getHeatingCurveSlope()
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import logging
|
|
3
|
+
from datetime import UTC, date, datetime
|
|
4
|
+
from typing import Any
|
|
5
|
+
from urllib.parse import urlencode
|
|
6
|
+
|
|
7
|
+
from PyViCare.PyViCareAbstractOAuthManager import AbstractViCareOAuthManager
|
|
8
|
+
from PyViCare.PyViCareEvent import ViCareEventPage
|
|
9
|
+
from PyViCare.PyViCareUtils import (
|
|
10
|
+
PyViCareInvalidDataError,
|
|
11
|
+
PyViCareNotSupportedFeatureError,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
logger.addHandler(logging.NullHandler())
|
|
16
|
+
|
|
17
|
+
def readFeature(entities, property_name):
|
|
18
|
+
feature = next(
|
|
19
|
+
(f for f in entities if f["feature"] == property_name), None)
|
|
20
|
+
|
|
21
|
+
if feature is None:
|
|
22
|
+
raise PyViCareNotSupportedFeatureError(property_name)
|
|
23
|
+
|
|
24
|
+
return feature
|
|
25
|
+
|
|
26
|
+
def hasRoles(requested_roles: list[str], existing_roles: list[str]) -> bool:
|
|
27
|
+
return len(requested_roles) > 0 and set(requested_roles).issubset(set(existing_roles))
|
|
28
|
+
|
|
29
|
+
_MAX_EVENT_LIMIT = 1000
|
|
30
|
+
|
|
31
|
+
GATEWAY_ROLES = [
|
|
32
|
+
"type:gateway;VitoconnectOpto1",
|
|
33
|
+
"type:gateway;VitoconnectOpto2/OT2",
|
|
34
|
+
"type:gateway;TCU100",
|
|
35
|
+
"type:gateway;TCU200",
|
|
36
|
+
"type:gateway;TCU300",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
def is_gateway_role(roles: list[str]) -> bool:
|
|
40
|
+
return any(hasRoles([role], roles) for role in GATEWAY_ROLES)
|
|
41
|
+
|
|
42
|
+
def buildSetPropertyUrl(accessor, property_name, action):
|
|
43
|
+
return f'/features/installations/{accessor.id}/gateways/{accessor.serial}/devices/{accessor.device_id}/features/{property_name}/commands/{action}'
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _format_query_datetime(value: datetime | None) -> str | None:
|
|
47
|
+
"""Format a datetime as the ISO 8601 UTC string the API expects.
|
|
48
|
+
|
|
49
|
+
Naive datetimes are read as UTC.
|
|
50
|
+
"""
|
|
51
|
+
if value is None:
|
|
52
|
+
return None
|
|
53
|
+
|
|
54
|
+
if value.tzinfo is None:
|
|
55
|
+
value = value.replace(tzinfo=UTC)
|
|
56
|
+
return value.astimezone(UTC).strftime('%Y-%m-%dT%H:%M:%SZ')
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _format_query_date(value: date | None) -> str | None:
|
|
60
|
+
"""Format a date as the ISO 8601 date the API expects."""
|
|
61
|
+
if value is None:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
if isinstance(value, datetime):
|
|
65
|
+
raise TypeError("on_date takes a datetime.date, not datetime.datetime")
|
|
66
|
+
return value.isoformat()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _event_query_limit(limit: int | None) -> int | None:
|
|
70
|
+
"""Clamp the page size to what the API accepts (1000)."""
|
|
71
|
+
if limit is None:
|
|
72
|
+
return None
|
|
73
|
+
|
|
74
|
+
if limit < 1:
|
|
75
|
+
raise ValueError("limit must be 1 or more")
|
|
76
|
+
return min(limit, _MAX_EVENT_LIMIT)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class ViCareDeviceAccessor:
|
|
80
|
+
def __init__(self, _id: int, serial: str, device_id: str) -> None:
|
|
81
|
+
self.id = _id
|
|
82
|
+
self.serial = serial
|
|
83
|
+
self.device_id = device_id
|
|
84
|
+
|
|
85
|
+
class ViCareService:
|
|
86
|
+
def __init__(self, oauth_manager: AbstractViCareOAuthManager, roles: list[str]) -> None:
|
|
87
|
+
self.oauth_manager = oauth_manager
|
|
88
|
+
self.roles = roles
|
|
89
|
+
|
|
90
|
+
def getProperty(self, accessor: ViCareDeviceAccessor, property_name: str) -> Any:
|
|
91
|
+
url = self.buildGetPropertyUrl(accessor, property_name)
|
|
92
|
+
response = self.oauth_manager.get(url)
|
|
93
|
+
# A missing feature comes back as a 404 body, not as an exception.
|
|
94
|
+
if "data" not in response:
|
|
95
|
+
raise PyViCareNotSupportedFeatureError(property_name)
|
|
96
|
+
return response["data"]
|
|
97
|
+
|
|
98
|
+
def buildGetPropertyUrl(self, accessor: ViCareDeviceAccessor, property_name):
|
|
99
|
+
if is_gateway_role(self.roles):
|
|
100
|
+
return f'/features/installations/{accessor.id}/gateways/{accessor.serial}/features/{property_name}'
|
|
101
|
+
return f'/features/installations/{accessor.id}/gateways/{accessor.serial}/devices/{accessor.device_id}/features/{property_name}'
|
|
102
|
+
|
|
103
|
+
def hasRoles(self, requested_roles) -> bool:
|
|
104
|
+
return hasRoles(requested_roles, self.roles)
|
|
105
|
+
|
|
106
|
+
def setProperty(self, accessor: ViCareDeviceAccessor, property_name: str, action: str, data: Any) -> Any:
|
|
107
|
+
url = buildSetPropertyUrl(accessor, property_name, action)
|
|
108
|
+
|
|
109
|
+
post_data = data if isinstance(data, str) else json.dumps(data)
|
|
110
|
+
return self.oauth_manager.post(url, post_data)
|
|
111
|
+
|
|
112
|
+
def fetch_all_features(self, accessor: ViCareDeviceAccessor) -> Any:
|
|
113
|
+
url = f'/features/installations/{accessor.id}/gateways/{accessor.serial}/devices/{accessor.device_id}/features/'
|
|
114
|
+
if is_gateway_role(self.roles):
|
|
115
|
+
url = f'/features/installations/{accessor.id}/gateways/{accessor.serial}/features/'
|
|
116
|
+
return self.oauth_manager.get(url)
|
|
117
|
+
|
|
118
|
+
def reboot_gateway(self, accessor: ViCareDeviceAccessor) -> Any:
|
|
119
|
+
url = f'/equipment/installations/{accessor.id}/gateways/{accessor.serial}/reboot'
|
|
120
|
+
data = "{}"
|
|
121
|
+
return self.oauth_manager.post(url, data)
|
|
122
|
+
|
|
123
|
+
# pylint: disable=too-many-arguments
|
|
124
|
+
def _build_events_url(self,
|
|
125
|
+
accessor: ViCareDeviceAccessor,
|
|
126
|
+
event_type: str | None = None,
|
|
127
|
+
*,
|
|
128
|
+
last_days: int | None = None,
|
|
129
|
+
since: datetime | None = None,
|
|
130
|
+
on_date: date | None = None,
|
|
131
|
+
gateway_serials: str | None = None,
|
|
132
|
+
limit: int | None = None,
|
|
133
|
+
cursor: str | None = None) -> str:
|
|
134
|
+
if sum(window is not None for window in (last_days, since, on_date)) > 1:
|
|
135
|
+
raise ValueError("last_days, since and on_date cannot be combined")
|
|
136
|
+
if last_days is not None and last_days < 1:
|
|
137
|
+
raise ValueError("last_days must be 1 or more")
|
|
138
|
+
|
|
139
|
+
params = {
|
|
140
|
+
'eventType': event_type,
|
|
141
|
+
'lastNDays': last_days,
|
|
142
|
+
'timestamp': _format_query_datetime(since),
|
|
143
|
+
'date': _format_query_date(on_date),
|
|
144
|
+
'gatewaySerials': gateway_serials,
|
|
145
|
+
'limit': _event_query_limit(limit),
|
|
146
|
+
'cursor': cursor,
|
|
147
|
+
}
|
|
148
|
+
# the cursor is base64 and the timestamps contain colons, so encode them
|
|
149
|
+
query = urlencode({key: value for key, value in params.items() if value is not None})
|
|
150
|
+
url = f'/events-history/installations/{accessor.id}/events'
|
|
151
|
+
return f'{url}?{query}' if query else url
|
|
152
|
+
|
|
153
|
+
# pylint: disable=too-many-arguments
|
|
154
|
+
def fetch_events(self,
|
|
155
|
+
accessor: ViCareDeviceAccessor,
|
|
156
|
+
event_type: str | None = None,
|
|
157
|
+
*,
|
|
158
|
+
last_days: int | None = None,
|
|
159
|
+
since: datetime | None = None,
|
|
160
|
+
on_date: date | None = None,
|
|
161
|
+
gateway_serials: str | None = None,
|
|
162
|
+
limit: int | None = None,
|
|
163
|
+
cursor: str | None = None) -> ViCareEventPage:
|
|
164
|
+
"""Events of the installation this accessor belongs to.
|
|
165
|
+
|
|
166
|
+
The API returns them newest ingestion first, so a late arriving event
|
|
167
|
+
can precede an older one. Compare `event_timestamp` when the chronology
|
|
168
|
+
matters.
|
|
169
|
+
|
|
170
|
+
The API filters by `event_type`, `gateway_serials` (comma separated),
|
|
171
|
+
one time window and the page size; the device id is not a parameter and
|
|
172
|
+
is filtered by the caller. Pass the `next_cursor` of a page as `cursor`
|
|
173
|
+
to fetch the following one.
|
|
174
|
+
|
|
175
|
+
The time window is `last_days`, `since` (from that instant until now)
|
|
176
|
+
or `on_date` (events of one day). Only one of them may be given, the
|
|
177
|
+
API rejects combinations. `limit` defaults to 50 on the server, values
|
|
178
|
+
above 1000 are clamped, values below 1 raise ValueError.
|
|
179
|
+
|
|
180
|
+
`event_type` is matched exactly and is not validated; several values
|
|
181
|
+
such as "device-error,device-message-warning" are OR-ed by the API.
|
|
182
|
+
"""
|
|
183
|
+
url = self._build_events_url(
|
|
184
|
+
accessor, event_type, last_days=last_days, since=since, on_date=on_date,
|
|
185
|
+
gateway_serials=gateway_serials, limit=limit, cursor=cursor)
|
|
186
|
+
response = self.oauth_manager.get(url)
|
|
187
|
+
|
|
188
|
+
if not isinstance(response, dict) or 'data' not in response:
|
|
189
|
+
logger.error("Missing 'data' property when fetching events.")
|
|
190
|
+
raise PyViCareInvalidDataError(response)
|
|
191
|
+
|
|
192
|
+
return ViCareEventPage.from_payload(response)
|
|
@@ -49,6 +49,30 @@ Depending on the device, some features are not available/supported. This results
|
|
|
49
49
|
|
|
50
50
|
Tip: You can use Pythons [contextlib.suppress](https://docs.python.org/3/library/contextlib.html#contextlib.suppress) to handle it gracefully.
|
|
51
51
|
|
|
52
|
+
### Error events
|
|
53
|
+
|
|
54
|
+
`getDeviceErrors()` reads a feature that some gateways do not offer. The event
|
|
55
|
+
history keeps those errors, including the ones that already cleared:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
for event in device.getErrorEvents(limit=10):
|
|
59
|
+
state = "active" if event.active else "cleared"
|
|
60
|
+
print(event.event_timestamp, state, event.error_code, event.error_description)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`active=True` is the raise, `active=False` the clear, so the event of an error
|
|
64
|
+
code with the latest `event_timestamp` is its current state. `getErrorEvents()`
|
|
65
|
+
asks the API for its gateway serial and filters the page by device id, so
|
|
66
|
+
`limit` counts that gateway's events. Paging and other event types are on
|
|
67
|
+
`device.service.fetch_events()`.
|
|
68
|
+
|
|
69
|
+
`getDeviceStatusMessages()`, `getDeviceServiceMessages()` and
|
|
70
|
+
`getDeviceInfoMessages()` return the current status, service and info messages
|
|
71
|
+
the same way `getDeviceErrors()` returns the errors, each entry with
|
|
72
|
+
`errorCode`, `priority` and `timestamp`. An empty list means there is no such
|
|
73
|
+
message right now; a device without the feature raises
|
|
74
|
+
`PyViCareNotSupportedFeatureError`.
|
|
75
|
+
|
|
52
76
|
## Types of heatings
|
|
53
77
|
|
|
54
78
|
- Use `asGazBoiler` for gas heatings
|
|
@@ -92,13 +116,12 @@ print(circuit.getHeatingCurveSlope())
|
|
|
92
116
|
print(circuit.getActiveProgram())
|
|
93
117
|
print(circuit.getPrograms())
|
|
94
118
|
|
|
95
|
-
print(circuit.
|
|
96
|
-
print(circuit.
|
|
119
|
+
print(circuit.getActiveProgramTemperature())
|
|
120
|
+
print(circuit.getComfortTemperature())
|
|
97
121
|
print(circuit.getActiveMode())
|
|
98
122
|
|
|
99
|
-
print(circuit.
|
|
100
|
-
print(circuit.
|
|
101
|
-
print(circuit.activateProgram("comfort"))
|
|
123
|
+
print(circuit.setComfortTemperature(21))
|
|
124
|
+
print(circuit.activateComfort())
|
|
102
125
|
print(circuit.deactivateComfort())
|
|
103
126
|
|
|
104
127
|
burner = t.burners[0] #select burner
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "PyViCare"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.67.0"
|
|
4
4
|
description = "Library to communicate with the Viessmann ViCare API."
|
|
5
5
|
authors = [{ name = "Simon Gillet", email = "mail+pyvicare@gillet.ninja" }]
|
|
6
6
|
requires-python = ">=3.11"
|
|
@@ -46,10 +46,10 @@ Changelog = "https://github.com/openviess/PyViCare/releases"
|
|
|
46
46
|
dev = [
|
|
47
47
|
"codespell==2.4.3",
|
|
48
48
|
"mypy==2.4.1",
|
|
49
|
-
"pylint==4.1.
|
|
49
|
+
"pylint==4.1.4",
|
|
50
50
|
"pytest==9.2.0",
|
|
51
51
|
"pytest-cov==7.1.0",
|
|
52
|
-
"ruff==0.17.
|
|
52
|
+
"ruff==0.17.6",
|
|
53
53
|
"types-deprecated>=1.2.15.20241117,<2",
|
|
54
54
|
"types-requests>=2.31",
|
|
55
55
|
]
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import logging
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from PyViCare.PyViCareAbstractOAuthManager import AbstractViCareOAuthManager
|
|
6
|
-
from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError
|
|
7
|
-
|
|
8
|
-
logger = logging.getLogger(__name__)
|
|
9
|
-
logger.addHandler(logging.NullHandler())
|
|
10
|
-
|
|
11
|
-
def readFeature(entities, property_name):
|
|
12
|
-
feature = next(
|
|
13
|
-
(f for f in entities if f["feature"] == property_name), None)
|
|
14
|
-
|
|
15
|
-
if feature is None:
|
|
16
|
-
raise PyViCareNotSupportedFeatureError(property_name)
|
|
17
|
-
|
|
18
|
-
return feature
|
|
19
|
-
|
|
20
|
-
def hasRoles(requested_roles: list[str], existing_roles: list[str]) -> bool:
|
|
21
|
-
return len(requested_roles) > 0 and set(requested_roles).issubset(set(existing_roles))
|
|
22
|
-
|
|
23
|
-
GATEWAY_ROLES = [
|
|
24
|
-
"type:gateway;VitoconnectOpto1",
|
|
25
|
-
"type:gateway;VitoconnectOpto2/OT2",
|
|
26
|
-
"type:gateway;TCU100",
|
|
27
|
-
"type:gateway;TCU200",
|
|
28
|
-
"type:gateway;TCU300",
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
def is_gateway_role(roles: list[str]) -> bool:
|
|
32
|
-
return any(hasRoles([role], roles) for role in GATEWAY_ROLES)
|
|
33
|
-
|
|
34
|
-
def buildSetPropertyUrl(accessor, property_name, action):
|
|
35
|
-
return f'/features/installations/{accessor.id}/gateways/{accessor.serial}/devices/{accessor.device_id}/features/{property_name}/commands/{action}'
|
|
36
|
-
|
|
37
|
-
class ViCareDeviceAccessor:
|
|
38
|
-
def __init__(self, _id: int, serial: str, device_id: str) -> None:
|
|
39
|
-
self.id = _id
|
|
40
|
-
self.serial = serial
|
|
41
|
-
self.device_id = device_id
|
|
42
|
-
|
|
43
|
-
class ViCareService:
|
|
44
|
-
def __init__(self, oauth_manager: AbstractViCareOAuthManager, roles: list[str]) -> None:
|
|
45
|
-
self.oauth_manager = oauth_manager
|
|
46
|
-
self.roles = roles
|
|
47
|
-
|
|
48
|
-
def getProperty(self, accessor: ViCareDeviceAccessor, property_name: str) -> Any:
|
|
49
|
-
url = self.buildGetPropertyUrl(accessor, property_name)
|
|
50
|
-
return self.oauth_manager.get(url)
|
|
51
|
-
|
|
52
|
-
def buildGetPropertyUrl(self, accessor: ViCareDeviceAccessor, property_name):
|
|
53
|
-
if is_gateway_role(self.roles):
|
|
54
|
-
return f'/features/installations/{accessor.id}/gateways/{accessor.serial}/features/{property_name}'
|
|
55
|
-
return f'/features/installations/{accessor.id}/gateways/{accessor.serial}/devices/{accessor.device_id}/features/{property_name}'
|
|
56
|
-
|
|
57
|
-
def hasRoles(self, requested_roles) -> bool:
|
|
58
|
-
return hasRoles(requested_roles, self.roles)
|
|
59
|
-
|
|
60
|
-
def setProperty(self, accessor: ViCareDeviceAccessor, property_name: str, action: str, data: Any) -> Any:
|
|
61
|
-
url = buildSetPropertyUrl(accessor, property_name, action)
|
|
62
|
-
|
|
63
|
-
post_data = data if isinstance(data, str) else json.dumps(data)
|
|
64
|
-
return self.oauth_manager.post(url, post_data)
|
|
65
|
-
|
|
66
|
-
def fetch_all_features(self, accessor: ViCareDeviceAccessor) -> Any:
|
|
67
|
-
url = f'/features/installations/{accessor.id}/gateways/{accessor.serial}/devices/{accessor.device_id}/features/'
|
|
68
|
-
if is_gateway_role(self.roles):
|
|
69
|
-
url = f'/features/installations/{accessor.id}/gateways/{accessor.serial}/features/'
|
|
70
|
-
return self.oauth_manager.get(url)
|
|
71
|
-
|
|
72
|
-
def reboot_gateway(self, accessor: ViCareDeviceAccessor) -> Any:
|
|
73
|
-
url = f'/equipment/installations/{accessor.id}/gateways/{accessor.serial}/reboot'
|
|
74
|
-
data = "{}"
|
|
75
|
-
return self.oauth_manager.post(url, data)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|