Skip to content

Commit 9d84b22

Browse files
authored
Merge pull request #16 from plugwise/move_constants
Move smile constants
2 parents 6f7acf9 + 4900eb0 commit 9d84b22

File tree

6 files changed

+284
-211
lines changed

6 files changed

+284
-211
lines changed

plugwise/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Plugwise module."""
22

3-
__version__ = "0.8.0a2"
3+
__version__ = "0.8.0a3"
44

55
from plugwise.smile import Smile
66
from plugwise.stick import stick

plugwise/constants.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
### Stick constants ###
2+
13
UTF8_DECODE = "utf-8"
24

35
# Serial connection settings for plugwise USB stick
@@ -260,3 +262,105 @@
260262
HA_SWITCH = "switch"
261263
HA_SENSOR = "sensor"
262264
HA_BINARY_SENSOR = "binary_sensor"
265+
266+
267+
### Smile constants ###
268+
269+
APPLIANCES = "/core/appliances"
270+
DOMAIN_OBJECTS = "/core/domain_objects"
271+
LOCATIONS = "/core/locations"
272+
NOTIFICATIONS = "/core/notifications"
273+
RULES = "/core/rules"
274+
SYSTEM = "/system"
275+
STATUS = "/system/status.xml"
276+
277+
DEFAULT_TIMEOUT = 30
278+
DEFAULT_USERNAME = "smile"
279+
DEFAULT_PORT = 80
280+
281+
SWITCH_GROUP_TYPES = ["switching", "report"]
282+
283+
HOME_MEASUREMENTS = {
284+
"electricity_consumed": "power",
285+
"electricity_produced": "power",
286+
"gas_consumed": "gas",
287+
"outdoor_temperature": "temperature",
288+
}
289+
290+
# Excluded:
291+
# zone_thermosstat 'temperature_offset'
292+
# radiator_valve 'uncorrected_temperature', 'temperature_offset'
293+
DEVICE_MEASUREMENTS = {
294+
# HA Core current_temperature
295+
"temperature": "temperature",
296+
# HA Core setpoint
297+
"thermostat": "setpoint",
298+
# Anna/Adam
299+
"boiler_temperature": "water_temperature",
300+
"domestic_hot_water_state": "dhw_state",
301+
"intended_boiler_temperature": "intended_boiler_temperature", # non-zero when heating, zero when dhw-heating
302+
"intended_central_heating_state": "heating_state", # use intended_c_h_state, this key shows the heating-behavior better than c-h_state
303+
"modulation_level": "modulation_level",
304+
"return_water_temperature": "return_temperature",
305+
# Used with the Elga heatpump - marcelveldt
306+
"compressor_state": "compressor_state",
307+
"cooling_state": "cooling_state",
308+
# Next 2 keys are used to show the state of the gas-heater used next to the Elga heatpump - marcelveldt
309+
"slave_boiler_state": "slave_boiler_state",
310+
"flame_state": "flame_state", # also present when there is a single gas-heater
311+
# Anna only
312+
"central_heater_water_pressure": "water_pressure",
313+
"outdoor_temperature": "outdoor_temperature", # Outdoor temp as reported on the Anna, in the App
314+
"schedule_temperature": "schedule_temperature", # Only present on legacy Anna and Anna_v3
315+
# Legacy Anna: similar to flame-state on Anna/Adam
316+
"boiler_state": "boiler_state",
317+
# Legacy Anna: shows when heating is active, don't show dhw_state, cannot be determined reliably
318+
"intended_boiler_state": "intended_boiler_state",
319+
# Lisa and Tom
320+
"battery": "battery",
321+
"temperature_difference": "temperature_difference",
322+
"valve_position": "valve_position",
323+
# Plug
324+
"electricity_consumed": "electricity_consumed",
325+
"electricity_produced": "electricity_produced",
326+
"relay": "relay",
327+
}
328+
329+
SMILES = {
330+
"smile_open_therm_v3": {
331+
"type": "thermostat",
332+
"friendly_name": "Adam",
333+
},
334+
"smile_open_therm_v2": {
335+
"type": "thermostat",
336+
"friendly_name": "Adam",
337+
},
338+
"smile_thermo_v4": {
339+
"type": "thermostat",
340+
"friendly_name": "Anna",
341+
},
342+
"smile_thermo_v3": {
343+
"type": "thermostat",
344+
"friendly_name": "Anna",
345+
},
346+
"smile_thermo_v1": {
347+
"type": "thermostat",
348+
"friendly_name": "Anna",
349+
"legacy": True,
350+
},
351+
"smile_v4": {
352+
"type": "power",
353+
"friendly_name": "P1",
354+
},
355+
"smile_v3": {
356+
"type": "power",
357+
"friendly_name": "P1",
358+
},
359+
"smile_v2": {
360+
"type": "power",
361+
"friendly_name": "P1",
362+
"legacy": True,
363+
},
364+
"stretch_v3": {"type": "stretch", "friendly_name": "Stretch", "legacy": True},
365+
"stretch_v2": {"type": "stretch", "friendly_name": "Stretch", "legacy": True},
366+
}

plugwise/exceptions.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (C) 2011 Sven Petai <[email protected]>
22
# Use of this source code is governed by the MIT license found in the LICENSE file.
33

4+
### Stick exceptions ###
45

56
class PlugwiseException(Exception):
67
"""Base error class for this Plugwise library"""
@@ -42,3 +43,66 @@ class TimeoutException(PlugwiseException):
4243
"""Timeout expired while waiting for response from node"""
4344

4445
pass
46+
47+
48+
### Smile exceptions ###
49+
50+
51+
class PlugwiseError(Exception):
52+
"""Plugwise exceptions class."""
53+
54+
pass
55+
56+
57+
class ConnectionFailedError(PlugwiseError):
58+
"""Raised when unable to connect."""
59+
60+
pass
61+
62+
63+
class InvalidAuthentication(PlugwiseError):
64+
"""Raised when unable to authenticate."""
65+
66+
pass
67+
68+
69+
class UnsupportedDeviceError(PlugwiseError):
70+
"""Raised when device is not supported."""
71+
72+
pass
73+
74+
75+
class DeviceSetupError(PlugwiseError):
76+
"""Raised when device is missing critical setup data."""
77+
78+
pass
79+
80+
81+
class DeviceTimeoutError(PlugwiseError):
82+
"""Raised when device is not supported."""
83+
84+
pass
85+
86+
87+
class ErrorSendingCommandError(PlugwiseError):
88+
"""Raised when device is not accepting the command."""
89+
90+
pass
91+
92+
93+
class ResponseError(PlugwiseError):
94+
"""Raised when empty or error in response returned."""
95+
96+
pass
97+
98+
99+
class InvalidXMLError(PlugwiseError):
100+
"""Raised when response holds incomplete or invalid XML data."""
101+
102+
pass
103+
104+
105+
class XMLDataMissingError(PlugwiseError):
106+
"""Raised when xml data is empty."""
107+
108+
pass

0 commit comments

Comments
 (0)