1
0
mirror of https://github.com/no2chem/wideq.git synced 2025-05-21 01:20:11 -07:00

Added support for zone control for ducted HVAC that support zone control

Added support for reading / setting fan speed
This commit is contained in:
bindismal 2018-06-16 21:34:33 +10:00
parent c6d597f446
commit 3c59047d10
2 changed files with 47 additions and 2 deletions

View File

@ -87,7 +87,8 @@ def ac_mon(client, device_id):
'{1}; '
'{0.mode.name}; '
'cur {0.temp_cur_f}°F; '
'cfg {0.temp_cfg_f}°F'
'cfg {0.temp_cfg_f}°F; '
'fan speed {0.fan_speed.name}'
.format(
state,
'on' if state.is_on else 'off'
@ -121,7 +122,10 @@ def ac_config(client, device_id):
print(ac.get_energy_target())
print(ac.get_volume())
print(ac.get_light())
zones = ac.get_zones()
print(zones)
ac.set_fan_speed(wideq.ACFanSpeed('@AC_MAIN_WIND_STRENGTH_LOW_W'))
ac.set_zones(zones)
EXAMPLE_COMMANDS = {
'ls': ls,

View File

@ -746,6 +746,18 @@ class ACMode(enum.Enum):
AROMA = "@AC_MAIN_OPERATION_MODE_AROMA_W"
ENERGY_SAVING = "@AC_MAIN_OPERATION_MODE_ENERGY_SAVING_W"
class ACFanSpeed(enum.Enum):
"""The fan speed for an AC/HVAC device."""
SLOW_W = '@AC_MAIN_WIND_STRENGTH_SLOW_W'
SLOW_LOW_W = '@AC_MAIN_WIND_STRENGTH_SLOW_LOW_W'
LOW_W = '@AC_MAIN_WIND_STRENGTH_LOW_W'
LOW_MID_W = '@AC_MAIN_WIND_STRENGTH_LOW_MID_W'
MID_W = '@AC_MAIN_WIND_STRENGTH_MID_W'
MID_HIGH_W = '@AC_MAIN_WIND_STRENGTH_MID_HIGH_W'
HIGH_W = '@AC_MAIN_WIND_STRENGTH_HIGH_W'
POWER_W = '@AC_MAIN_WIND_STRENGTH_POWER_W'
AUTO_W = '@AC_MAIN_WIND_STRENGTH_AUTO_W'
class ACOp(enum.Enum):
"""Whether a device is on or off."""
@ -806,6 +818,31 @@ class ACDevice(Device):
self.set_celsius(self.f2c[f])
def set_zones(self, zones):
"""Set the device's zones to on/off.
zones arg is a list of the format below
zone_no is a number indexed from 1 typed as string
enabled is a bool typed as string
isOpen is a bool typed as string
[{'No':zone_no, 'Cfg':enabled, 'State':isOpen},]
"""
#ensure at least 1 zone is enabled. Can't turn all zones off
on_count = sum(int(zone['State']) for zone in zones)
if(on_count > 0):
zone_cmd = '/'.join(zone['No']+'_'+zone['State'] for zone in zones if zone['Cfg'] == '1')
self._set_control('DuctZone', zone_cmd)
def get_zones(self):
"""Gets the status of the zones, including whether a zone is configured.
Result is a list of dicts with the same format as set_zones()
"""
return self._get_config('DuctZone')
def set_fan_speed(self, speed):
"""Sets the fan speed according to the WindStreng operation"""
speed_value = self.model.enum_value('WindStrength', speed.value)
self._set_control('WindStrength', speed_value)
def set_mode(self, mode):
"""Set the device's operating mode to an `OpMode` value.
"""
@ -921,6 +958,10 @@ class ACStatus(object):
def mode(self):
return ACMode(self.lookup_enum('OpMode'))
@property
def fan_speed(self):
return ACFanSpeed(self.lookup_enum('WindStrength'))
@property
def is_on(self):
op = ACOp(self.lookup_enum('Operation'))