Skip to content

Commit 0b0a1b5

Browse files
authored
Merge pull request #44 from plugwise/release_dot_2
Release 0.2.0
2 parents bbcbf25 + 4ce39e8 commit 0b0a1b5

File tree

7 files changed

+85
-77
lines changed

7 files changed

+85
-77
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,24 @@ A fully asynchronous approach to supporting Plugwise devices. This repository is
2121

2222
## What do we support (in short)?
2323

24-
- Adam (firmware 2.3 + 3.0) - we don't have a `Koen` yet in our testers suite
24+
- Adam (firmware 2.3 + 3.0)
2525
- Smile & Anna (firmware 1.8, 3.1 and 4.0)
2626
- Smile P1 (firmware 2.5 and 3.3)
2727

2828
## What can I expect in HA from this component
2929

30-
- `climate`: A (number of) thermostat(s) visible in HA, including temperature, presets and heating-demand status, per thermostat. Also, setting of temperature, preset and switching the active schedule on and off.
31-
- `sensor` and `binary_sensor`: A number of sensoric values depending on your hardware (Outdoor temperature, Anna's illuminance, Plug power-usage, P1 values)
32-
- `switch`: Plugs are available as switches, also switching them on/off is supported.
33-
- `water_heater`: When your heating system connected to the Smile/Adam supports heating of tap-water, the status of this function is shown via the water_heater entity icon, next to the status of the normal heating function (idle/heating/hot_water) - **note** this is not available on all platforms (there is logic in place deciding if you need this as a seperate entity)
30+
- `climate`: A (number of) thermostat(s) visible in HA, including temperature, presets and heating-demand status, per thermostat. Also, setting of temperature, preset and switching the active schedule on and off. Cooling is only supported in combination with an Anna (fw 3.1 and 4.0).
31+
- `sensor` and `binary_sensor`: A number of sensoric values depending on your hardware: outdoor temperature, Anna's illuminance, Tom's valve postion, Plug's power-values, P1 power- and gas-values
32+
- `switch`: The switch-parts of Plugs are available as switches, also switching them on/off is supported.
33+
34+
The `water_heater`-device present in previous releases has been replaced by a state-sensor. This sensor will only show up when there are more (than one) thermostats present in your climate-system.
3435

3536
## How to set-up?
3637

3738
- Use [HACS](https://hacs.xyz)
38-
- Use the link to this page and add it on the `custom repo` page
39+
- Use the link to this page and add it on the `custom repo` page .
3940
- Look for `Plugwise beta custom component ` in `integrations` and install it!
41+
- If you need an pre-release for testing, click the three dots and mark the 'beta' check to see pre-releases.
4042

4143
## When installed
4244

custom_components/plugwise-beta/binary_sensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121
BINARY_SENSOR_LIST = [
22-
"domestic_hot_water_state",
22+
"dhw_state",
2323
"slave_boiler_state",
2424
"valve_position",
2525
]
@@ -143,7 +143,7 @@ def device_info(self) -> Dict[str, any]:
143143
@property
144144
def icon(self):
145145
"""Return the icon to use in the frontend."""
146-
if self._binary_sensor == "domestic_hot_water_state":
146+
if self._binary_sensor == "dhw_state":
147147
return WATER_ICON
148148
if self._binary_sensor == "slave_boiler_state":
149149
return FLAME_ICON
@@ -162,7 +162,7 @@ def update(self):
162162
_LOGGER.debug("Update binary_sensor called")
163163
data = self._api.get_device_data(self._dev_id)
164164

165-
if data is None:
165+
if not data:
166166
_LOGGER.error("Received no data for device %s.", self._binary_sensor)
167167
else:
168168
if self._binary_sensor in data:

custom_components/plugwise-beta/climate.py

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
)
1717
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
1818
from homeassistant.core import callback
19+
from Plugwise_Smile.Smile import Smile
1920

2021
from .const import (
2122
DOMAIN,
@@ -91,14 +92,14 @@ def __init__(self, api, updater, name, dev_id, loc_id, model, min_temp, max_temp
9192
self._presets = None
9293
self._presets_list = None
9394
self._boiler_state = None
94-
self._central_heating_state = None
95+
self._heating_state = None
9596
self._cooling_state = None
96-
self._domestic_hot_water_state = None
97+
self._dhw_state = None
9798
self._hvac_mode = None
9899
self._schema_names = None
99100
self._schema_status = None
100101
self._temperature = None
101-
self._thermostat = None
102+
self._setpoint = None
102103
self._water_pressure = None
103104
self._schedule_temp = None
104105
self._hvac_mode = None
@@ -128,12 +129,12 @@ def _update_callback(self):
128129
def hvac_action(self):
129130
"""Return the current action."""
130131
if self._single_thermostat:
131-
if self._central_heating_state or self._boiler_state:
132+
if self._heating_state or self._boiler_state:
132133
return CURRENT_HVAC_HEAT
133134
if self._cooling_state:
134135
return CURRENT_HVAC_COOL
135136
return CURRENT_HVAC_IDLE
136-
if self._central_heating_state is not None or self._boiler_state is not None:
137+
if self._heating_state is not None or self._boiler_state is not None:
137138
if self._thermostat > self._temperature:
138139
return CURRENT_HVAC_HEAT
139140
return CURRENT_HVAC_IDLE
@@ -192,7 +193,7 @@ def preset_modes(self):
192193
@property
193194
def hvac_modes(self):
194195
"""Return the available hvac modes list."""
195-
if self._central_heating_state is not None or self._boiler_state is not None:
196+
if self._heating_state is not None or self._boiler_state is not None:
196197
if self._cooling_state is not None:
197198
return HVAC_MODES_2
198199
return HVAC_MODES_1
@@ -205,7 +206,7 @@ def hvac_mode(self):
205206
@property
206207
def target_temperature(self):
207208
"""Return the target_temperature."""
208-
return self._thermostat
209+
return self._setpoint
209210

210211
@property
211212
def preset_mode(self):
@@ -241,9 +242,12 @@ async def async_set_temperature(self, **kwargs):
241242
self._min_temp < temperature < self._max_temp
242243
):
243244
_LOGGER.debug("Set temp to %sºC", temperature)
244-
await self._api.set_temperature(self._loc_id, temperature)
245-
self._thermostat = temperature
246-
self.async_write_ha_state()
245+
try:
246+
await self._api.set_temperature(self._loc_id, temperature)
247+
self._setpoint = temperature
248+
self.async_write_ha_state()
249+
except Smile.PlugwiseError:
250+
_LOGGER.error("Error while communicating to device")
247251
else:
248252
_LOGGER.error("Invalid temperature requested")
249253

@@ -253,34 +257,43 @@ async def async_set_hvac_mode(self, hvac_mode):
253257
state = "false"
254258
if hvac_mode == HVAC_MODE_AUTO:
255259
state = "true"
256-
await self._api.set_temperature(self._loc_id, self._schedule_temp)
257-
self._thermostat = self._schedule_temp
258-
await self._api.set_schedule_state(
259-
self._loc_id, self._last_active_schema, state
260-
)
261-
self._hvac_mode = hvac_mode
262-
self.async_write_ha_state()
260+
try:
261+
await self._api.set_temperature(self._loc_id, self._schedule_temp)
262+
self._setpoint = self._schedule_temp
263+
except Smile.PlugwiseError:
264+
_LOGGER.error("Error while communicating to device")
265+
try:
266+
await self._api.set_schedule_state(
267+
self._loc_id, self._last_active_schema, state
268+
)
269+
self._hvac_mode = hvac_mode
270+
self.async_write_ha_state()
271+
except Smile.PlugwiseError:
272+
_LOGGER.error("Error while communicating to device")
263273

264274
async def async_set_preset_mode(self, preset_mode):
265275
"""Set the preset mode."""
266276
_LOGGER.debug("Set preset mode to %s.", preset_mode)
267-
await self._api.set_preset(self._loc_id, preset_mode)
268-
self._preset_mode = preset_mode
269-
self._thermostat = self._presets.get(self._preset_mode, "none")[0]
270-
self.async_write_ha_state()
277+
try:
278+
await self._api.set_preset(self._loc_id, preset_mode)
279+
self._preset_mode = preset_mode
280+
self._setpoint = self._presets.get(self._preset_mode, "none")[0]
281+
self.async_write_ha_state()
282+
except Smile.PlugwiseError:
283+
_LOGGER.error("Error while communicating to device")
271284

272285
def update(self):
273286
"""Update the data for this climate device."""
274287
_LOGGER.info("Updating climate...")
275288
climate_data = self._api.get_device_data(self._dev_id)
276289
heater_central_data = self._api.get_device_data(self._api.heater_id)
277290

278-
if climate_data is None:
291+
if not climate_data:
279292
_LOGGER.error("Received no climate_data for device %s.", self._name)
280293
else:
281294
_LOGGER.debug("Climate_data collected from Plugwise API")
282-
if "thermostat" in climate_data:
283-
self._thermostat = climate_data["thermostat"]
295+
if "setpoint" in climate_data:
296+
self._thermostat = climate_data["setpoint"]
284297
if "temperature" in climate_data:
285298
self._temperature = climate_data["temperature"]
286299
if "schedule_temperature" in climate_data:
@@ -302,31 +315,29 @@ def update(self):
302315
if "active_preset" in climate_data:
303316
self._preset_mode = climate_data["active_preset"]
304317

305-
if heater_central_data is None:
318+
if not heater_central_data:
306319
_LOGGER.error("Received no heater_central_data for device %s.", self._name)
307320
else:
308321
_LOGGER.debug("Heater_central_data collected from Plugwise API")
309322
if "boiler_state" in heater_central_data:
310323
if heater_central_data["boiler_state"] is not None:
311324
self._boiler_state = heater_central_data["boiler_state"]
312-
if "central_heating_state" in heater_central_data:
313-
if heater_central_data["central_heating_state"] is not None:
314-
self._central_heating_state = heater_central_data[
315-
"central_heating_state"
316-
]
325+
if "heating_state" in heater_central_data:
326+
if heater_central_data["heating_state"] is not None:
327+
self._heating_state = heater_central_data["heating_state" ]
317328
if "cooling_state" in heater_central_data:
318329
if heater_central_data["cooling_state"] is not None:
319330
self._cooling_state = heater_central_data["cooling_state"]
320331

321332
if self._schema_status:
322333
self._hvac_mode = HVAC_MODE_AUTO
323-
elif self._central_heating_state is not None or self._boiler_state is not None:
334+
elif self._heating_state is not None or self._boiler_state is not None:
324335
if self._cooling_state is not None:
325336
self._hvac_mode = HVAC_MODE_HEAT_COOL
326337
self._hvac_mode = HVAC_MODE_HEAT
327338
elif self._cooling_state is not None:
328339
if (
329-
self._central_heating_state is not None
340+
self._heating_state is not None
330341
or self._boiler_state is not None
331342
):
332343
self._hvac_mode = HVAC_MODE_HEAT_COOL

custom_components/plugwise-beta/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"domain": "plugwise-beta",
33
"name": "Plugwise Beta for Home Assistant",
44
"documentation": "https://github.com/plugwise/plugwise-beta",
5-
"requirements": ["Plugwise_Smile==0.1.24"],
5+
"requirements": ["Plugwise_Smile==0.2.0"],
66
"dependencies": [],
77
"codeowners": ["@CoMPaTech","@bouwew"],
88
"config_flow": true

custom_components/plugwise-beta/manifest.json.ha-core

Lines changed: 0 additions & 9 deletions
This file was deleted.

custom_components/plugwise-beta/sensor.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
]
4141
ATTR_PRESSURE = ["Pressure", PRESSURE_BAR, DEVICE_CLASS_PRESSURE, "mdi:water"]
4242
SENSOR_MAP = {
43-
"thermostat": ATTR_TEMPERATURE,
43+
"setpoint": ATTR_TEMPERATURE,
4444
"temperature": ATTR_TEMPERATURE,
4545
"battery": ATTR_BATTERY_LEVEL,
46-
"central_heater_water_pressure": ATTR_PRESSURE,
46+
"water_pressure": ATTR_PRESSURE,
4747
"temperature_difference": ATTR_TEMPERATURE,
4848
"electricity_consumed": [
4949
"Current Consumed Power",
@@ -71,7 +71,7 @@
7171
],
7272
"outdoor_temperature": ATTR_TEMPERATURE,
7373
"illuminance": ATTR_ILLUMINANCE,
74-
"boiler_temperature": ATTR_TEMPERATURE,
74+
"water_temperature": ATTR_TEMPERATURE,
7575
"electricity_consumed_off_peak_point": [
7676
"Current Consumed Power (off peak)",
7777
"W",
@@ -152,6 +152,7 @@
152152
"flame_state",
153153
]
154154

155+
155156
async def async_setup_entry(hass, config_entry, async_add_entities):
156157
"""Set up the Smile sensors from a config entry."""
157158
_LOGGER.debug("Plugwise hass data %s", hass.data[DOMAIN])
@@ -209,20 +210,14 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
209210
_LOGGER.debug("Plugwise aux sensor Dev %s", device["name"])
210211
devices.append(
211212
PwThermostatSensor(
212-
api,
213-
updater,
214-
device["name"],
215-
dev_id,
216-
"state",
217-
None,
213+
api, updater, device["name"], dev_id, "state", None,
218214
)
219215
)
220216
_LOGGER.info(
221217
"Added sensor.%s_state", "{}".format(device["name"])
222218
)
223219
idx += 1
224220

225-
226221
async_add_entities(devices, True)
227222

228223

@@ -247,7 +242,7 @@ def __init__(self, api, updater, name, dev_id, sensor, sensor_type):
247242
self._class = self._device
248243
self._state = None
249244
self._boiler_state = False
250-
self._central_heating_state = False
245+
self._heating_state = False
251246
self._cooling_state = False
252247

253248
if self._dev_id == self._api.heater_id:
@@ -320,7 +315,7 @@ def unit_of_measurement(self):
320315
def icon(self):
321316
"""Icon for the sensor."""
322317
if self._sensor_type is None:
323-
if self._boiler_state or self._central_heating_state:
318+
if self._boiler_state or self._heating_state:
324319
return FLAME_ICON
325320
if self._cooling_state:
326321
return COOL_ICON
@@ -332,7 +327,7 @@ def update(self):
332327
_LOGGER.debug("Update sensor called")
333328
data = self._api.get_device_data(self._dev_id)
334329

335-
if data is None:
330+
if not data:
336331
_LOGGER.error("Received no data for device %s.", self._name)
337332
else:
338333
if self._sensor in data:
@@ -347,20 +342,20 @@ def update(self):
347342
if "boiler_state" in data:
348343
if data["boiler_state"] is not None:
349344
self._boiler_state = data["boiler_state"]
350-
if "central_heating_state" in data:
351-
if data["central_heating_state"] is not None:
352-
self._central_heating_state = data["central_heating_state"]
345+
if "heating_state" in data:
346+
if data["heating_state"] is not None:
347+
self._heating_state = data["heating_state"]
353348
if "cooling_state" in data:
354349
if data["cooling_state"] is not None:
355350
self._cooling_state = data["cooling_state"]
356351
if self._sensor == "state":
357-
if self._boiler_state or self._central_heating_state:
352+
if self._boiler_state or self._heating_state:
358353
self._state = "heating"
359354
elif self._cooling_state:
360355
self._state = "cooling"
361356
else:
362357
self._state = "idle"
363-
358+
364359

365360
class PwPowerSensor(Entity):
366361
"""Power sensor devices."""
@@ -453,7 +448,7 @@ def update(self):
453448
_LOGGER.debug("Update sensor called")
454449
data = self._api.get_device_data(self._dev_id)
455450

456-
if data is None:
451+
if not data:
457452
_LOGGER.error("Received no data for device %s.", self._name)
458453
else:
459454
if self._sensor in data:

0 commit comments

Comments
 (0)