1
0
mirror of https://github.com/no2chem/wideq.git synced 2025-05-16 15:20:09 -07:00

Accepted proposed changes

This commit is contained in:
bindismal 2018-06-17 23:50:33 +10:00
parent 3c59047d10
commit add21143d2
2 changed files with 20 additions and 18 deletions

View File

@ -122,10 +122,7 @@ def ac_config(client, device_id):
print(ac.get_energy_target()) print(ac.get_energy_target())
print(ac.get_volume()) print(ac.get_volume())
print(ac.get_light()) print(ac.get_light())
zones = ac.get_zones() print(ac.get_zones())
print(zones)
ac.set_fan_speed(wideq.ACFanSpeed('@AC_MAIN_WIND_STRENGTH_LOW_W'))
ac.set_zones(zones)
EXAMPLE_COMMANDS = { EXAMPLE_COMMANDS = {
'ls': ls, 'ls': ls,

View File

@ -749,15 +749,15 @@ class ACMode(enum.Enum):
class ACFanSpeed(enum.Enum): class ACFanSpeed(enum.Enum):
"""The fan speed for an AC/HVAC device.""" """The fan speed for an AC/HVAC device."""
SLOW_W = '@AC_MAIN_WIND_STRENGTH_SLOW_W' SLOW = '@AC_MAIN_WIND_STRENGTH_SLOW_W'
SLOW_LOW_W = '@AC_MAIN_WIND_STRENGTH_SLOW_LOW_W' SLOW_LOW = '@AC_MAIN_WIND_STRENGTH_SLOW_LOW_W'
LOW_W = '@AC_MAIN_WIND_STRENGTH_LOW_W' LOW = '@AC_MAIN_WIND_STRENGTH_LOW_W'
LOW_MID_W = '@AC_MAIN_WIND_STRENGTH_LOW_MID_W' LOW_MID = '@AC_MAIN_WIND_STRENGTH_LOW_MID_W'
MID_W = '@AC_MAIN_WIND_STRENGTH_MID_W' MID = '@AC_MAIN_WIND_STRENGTH_MID_W'
MID_HIGH_W = '@AC_MAIN_WIND_STRENGTH_MID_HIGH_W' MID_HIGH = '@AC_MAIN_WIND_STRENGTH_MID_HIGH_W'
HIGH_W = '@AC_MAIN_WIND_STRENGTH_HIGH_W' HIGH = '@AC_MAIN_WIND_STRENGTH_HIGH_W'
POWER_W = '@AC_MAIN_WIND_STRENGTH_POWER_W' POWER = '@AC_MAIN_WIND_STRENGTH_POWER_W'
AUTO_W = '@AC_MAIN_WIND_STRENGTH_AUTO_W' AUTO = '@AC_MAIN_WIND_STRENGTH_AUTO_W'
class ACOp(enum.Enum): class ACOp(enum.Enum):
"""Whether a device is on or off.""" """Whether a device is on or off."""
@ -822,14 +822,17 @@ class ACDevice(Device):
"""Set the device's zones to on/off. """Set the device's zones to on/off.
zones arg is a list of the format below zones arg is a list of the format below
zone_no is a number indexed from 1 typed as string zone_no is a number indexed from 1 typed as string
enabled is a bool typed as string enabled is a 1/0 typed as string
isOpen is a bool typed as string isOpen is a 1/0 typed as string
[{'No':zone_no, 'Cfg':enabled, 'State':isOpen},] [{'No':zone_no, 'Cfg':enabled, 'State':isOpen},]
""" """
#ensure at least 1 zone is enabled. Can't turn all zones off #ensure at least 1 zone is enabled. Can't turn all zones off
on_count = sum(int(zone['State']) for zone in zones) on_count = sum(int(zone['State']) for zone in zones)
if(on_count > 0): if on_count > 0:
zone_cmd = '/'.join(zone['No']+'_'+zone['State'] for zone in zones if zone['Cfg'] == '1') zone_cmd = '/'.join(
'{}_{}'.format(zone['No'], zone['State'])
for zone in zones if zone['Cfg'] == '1'
)
self._set_control('DuctZone', zone_cmd) self._set_control('DuctZone', zone_cmd)
def get_zones(self): def get_zones(self):
@ -839,7 +842,9 @@ class ACDevice(Device):
return self._get_config('DuctZone') return self._get_config('DuctZone')
def set_fan_speed(self, speed): def set_fan_speed(self, speed):
"""Sets the fan speed according to the WindStreng operation""" """Sets the fan speed according to the WindStrength operation
Speed arg is a value of the ACFanSpeed enum
"""
speed_value = self.model.enum_value('WindStrength', speed.value) speed_value = self.model.enum_value('WindStrength', speed.value)
self._set_control('WindStrength', speed_value) self._set_control('WindStrength', speed_value)