Skip to content

Commit 049535c

Browse files
authored
Merge pull request #32 from plugwise/single_master_thermostat
Single/Multi-thermostats and other changes
2 parents 3c6771d + 2fdf6ac commit 049535c

File tree

7 files changed

+49
-26
lines changed

7 files changed

+49
-26
lines changed

custom_components/plugwise-beta/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919

2020
_LOGGER = logging.getLogger(__name__)
2121

22-
PLATFORMS = ["binary_sensor", "climate", "sensor", "switch", "water_heater"]
23-
22+
SENSOR = ["sensor"]
23+
SINGLE = ["binary_sensor", "climate", "sensor", "switch"]
24+
MULTI = ["binary_sensor", "climate", "sensor", "switch", "water_heater"]
2425

2526
async def async_setup(hass: HomeAssistant, config: dict):
2627
"""Set up the Plugwise platform."""
@@ -65,6 +66,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
6566
)
6667
_LOGGER.debug("Plugwise device registry %s", result)
6768

69+
single_master_thermostat = api.single_master_thermostat()
70+
_LOGGER.debug("Single master thermostat = %s", single_master_thermostat)
71+
if single_master_thermostat is not None:
72+
if single_master_thermostat == True:
73+
PLATFORMS = SINGLE
74+
else:
75+
PLATFORMS = MULTI
76+
else:
77+
PLATFORMS = SENSOR
78+
6879
for component in PLATFORMS:
6980
hass.async_create_task(
7081
hass.config_entries.async_forward_entry_setup(entry, component)

custom_components/plugwise-beta/binary_sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, api, updater, name, binary_sensor, dev_id):
7272
self._name = name
7373
self._binary_sensor = binary_sensor
7474
self._is_on = False
75-
self._unique_id = f"{dev_id}-{name}"
75+
self._unique_id = f"bs-{dev_id}-{name}"
7676

7777
@property
7878
def unique_id(self):

custom_components/plugwise-beta/climate.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from homeassistant.components.climate import ClimateDevice
77
from homeassistant.components.climate.const import (
8+
CURRENT_HVAC_COOL,
89
CURRENT_HVAC_HEAT,
910
CURRENT_HVAC_IDLE,
1011
HVAC_MODE_AUTO,
@@ -100,7 +101,8 @@ def __init__(self, api, updater, name, dev_id, loc_id, min_temp, max_temp):
100101
self._water_pressure = None
101102
self._schedule_temp = None
102103
self._hvac_mode = None
103-
self._unique_id = f"{dev_id}-climate"
104+
self._single_thermostat = self._api.single_master_thermostat()
105+
self._unique_id = f"cl-{dev_id}-{name}"
104106

105107
@property
106108
def unique_id(self):
@@ -124,12 +126,20 @@ def _update_callback(self):
124126
@property
125127
def hvac_action(self):
126128
"""Return the current action."""
127-
if (
128-
self._central_heating_state is not None or self._boiler_state is not None
129-
) and self._cooling_state is None:
130-
if self._thermostat > self._temperature:
129+
if self._single_thermostat:
130+
if self._central_heating_state or self._boiler_state:
131131
return CURRENT_HVAC_HEAT
132-
return CURRENT_HVAC_IDLE
132+
if self._cooling_state:
133+
return CURRENT_HVAC_COOL
134+
return CURRENT_HVAC_IDLE
135+
else:
136+
if (
137+
self._central_heating_state is not None
138+
or self._boiler_state is not None
139+
):
140+
if self._thermostat > self._temperature:
141+
return CURRENT_HVAC_HEAT
142+
return CURRENT_HVAC_IDLE
133143

134144
@property
135145
def name(self):
@@ -183,7 +193,10 @@ def preset_modes(self):
183193
@property
184194
def hvac_modes(self):
185195
"""Return the available hvac modes list."""
186-
if self._central_heating_state is not None or self._boiler_state is not None:
196+
if (
197+
self._central_heating_state is not None
198+
or self._boiler_state is not None
199+
):
187200
if self._cooling_state is not None:
188201
return HVAC_MODES_2
189202
return HVAC_MODES_1
@@ -306,15 +319,14 @@ def update(self):
306319
if heater_central_data["cooling_state"] is not None:
307320
self._cooling_state = heater_central_data["cooling_state"]
308321

309-
if self._schema_status:
310-
self._hvac_mode = HVAC_MODE_AUTO
311-
elif (
312-
self._central_heating_state is not None
313-
or self._boiler_state is not None
314-
or self._domestic_hot_water_state is not None
315-
):
316-
if self._cooling_state is not None:
317-
self._hvac_mode = HVAC_MODE_HEAT_COOL
318-
self._hvac_mode = HVAC_MODE_HEAT
319-
else:
320-
self._hvac_mode = HVAC_MODE_OFF
322+
if self._schema_status:
323+
self._hvac_mode = HVAC_MODE_AUTO
324+
elif self._central_heating_state is not None or self._boiler_state is not None:
325+
if self._cooling_state is not None:
326+
self._hvac_mode = HVAC_MODE_HEAT_COOL
327+
self._hvac_mode = HVAC_MODE_HEAT
328+
elif self._cooling_state is not None:
329+
if self._central_heating_state is not None or self._boiler_state is not None:
330+
self._hvac_mode = HVAC_MODE_HEAT_COOL
331+
332+

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.18"],
5+
"requirements": ["Plugwise_Smile==0.1.21"],
66
"dependencies": [],
77
"codeowners": ["@CoMPaTech","@bouwew"],
88
"config_flow": true

custom_components/plugwise-beta/sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def __init__(self, api, updater, name, dev_id, sensor, sensor_type):
204204
self._icon = sensor_type[3]
205205
self._class = sensor_type[2]
206206
self._state = None
207-
self._unique_id = f"{dev_id}-{name}-{sensor_type[2]}"
207+
self._unique_id = f"sr-{dev_id}-{name}"
208208
_LOGGER.debug("Registering Plugwise %s", self._unique_id)
209209

210210
@property

custom_components/plugwise-beta/switch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(self, api, updater, name, dev_id):
4444
self._name = name
4545
self._dev_id = dev_id
4646
self._device_is_on = False
47-
self._unique_id = f"{dev_id}-{name}"
47+
self._unique_id = f"sw-{dev_id}-{name}"
4848

4949
@property
5050
def unique_id(self):

custom_components/plugwise-beta/water_heater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(self, api, updater, name, dev_id):
6767
self._cooling_state = False
6868
self._domestic_hot_water_state = False
6969
self._central_heater_water_pressure = None
70-
self._unique_id = f"{dev_id}-water_heater"
70+
self._unique_id = f"wh-{dev_id}-{name}"
7171

7272
@property
7373
def unique_id(self):

0 commit comments

Comments
 (0)