Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set hvac modes, based on thermostat available modes #85

Merged
merged 5 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions custom_components/heatmiserneo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@

SUPPORT_FLAGS = 0

# Heatmiser doesn't really have an off mode - standby is a preset - implement later
hvac_modes = [HVAC_MODE_OFF, HVAC_MODE_HEAT, HVAC_MODE_HEAT_COOL, HVAC_MODE_FAN_ONLY]

# This should be in the neohubapi.neohub enums code
import enum
class AvailableMode(str, enum.Enum):
HEAT = "heat"
COOL = "cool"
VENT = "vent"
AUTO = "auto"

hvac_mode_mapping = {
AvailableMode.AUTO: HVAC_MODE_HEAT_COOL,
AvailableMode.COOL: HVAC_MODE_COOL,
AvailableMode.VENT: HVAC_MODE_FAN_ONLY,
AvailableMode.HEAT: HVAC_MODE_HEAT
}

async def async_setup_entry(hass, entry, async_add_entities):

Expand All @@ -64,7 +75,12 @@ def __init__(self, hub: NeoHub, neostat: NeoStat, unit_of_measurement):
# self._type = type Neostat vs Neostat-e
self._hvac_action = None
self._hvac_mode = None
self._hvac_modes = hvac_modes
self._hvac_modes = []
if hasattr(neostat, 'standby'):
self._hvac_modes.append(HVAC_MODE_OFF)
for mode in neostat.available_modes:
self._hvac_modes.append(hvac_mode_mapping[mode])

self._target_temperature_high = None
self._target_temperature_low = None
self._support_flags = SUPPORT_FLAGS
Expand Down Expand Up @@ -224,7 +240,7 @@ async def async_set_hvac_mode(self, hvac_mode):

async def async_update(self):
""" Get Updated Info. """
_LOGGER.debug("Entered update(self)")
_LOGGER.debug("Entered climate.update(self)")
_, devices = await self._hub.get_live_data()
for thermostat in devices['thermostats']:
if self._neostat.name == thermostat.name:
Expand All @@ -237,11 +253,11 @@ async def async_update(self):
else:
# We are in heating mode by default as some devices only support this mode.
hc_mode = HCMode(thermostat.hc_mode)
if hc_mode == HCMode.AUTO:
if hc_mode == HCMode.AUTO and AvailableMode.AUTO in thermostat.available_modes:
self.update_hvac_mode(HVAC_MODE_HEAT_COOL)
elif hc_mode == HCMode.VENT:
elif hc_mode == HCMode.VENT and AvailableMode.VENT in thermostat.available_modes:
self.update_hvac_mode(HVAC_MODE_FAN_ONLY)
elif hc_mode == HCMode.COOLING:
elif hc_mode == HCMode.COOLING and AvailableMode.COOL in thermostat.available_modes:
self.update_hvac_mode(HVAC_MODE_COOL)
else:
self.update_hvac_mode(HVAC_MODE_HEAT)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/heatmiserneo/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def async_turn_off(self, **kwargs):

async def async_update(self):
""" Update the switch's status. """
_LOGGER.debug("Entered update(self)")
_LOGGER.debug("Entered switch.update(self)")
_, devices = await self._hub.get_live_data()
for device in devices['timeclocks']:
if self._switch.name == device.name:
Expand Down