async def test_spa_with_blower(hass: HomeAssistant): """Test supported features flags.""" with patch("homeassistant.components.balboa.BalboaSpaWifi.have_blower", return_value=True): config_entry = await _setup_climate_test(hass) # force a refresh async_dispatcher_send(hass, SIGNAL_UPDATE.format(config_entry.entry_id)) await hass.async_block_till_done() state = hass.states.get(ENTITY_CLIMATE) assert ( state.attributes["supported_features"] == SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE | SUPPORT_FAN_MODE) for fan_state in range(4): # set blower state = await _patch_blower(hass, config_entry, fan_state) assert state.attributes[ATTR_FAN_MODE] == FAN_SETTINGS[fan_state] # test the nonsense checks for fan_state in (None, 70): state = await _patch_blower(hass, config_entry, fan_state) assert state.attributes[ATTR_FAN_MODE] == FAN_OFF
async def test_spa_preset_modes(hass: HomeAssistant): """Test the various preset modes.""" config_entry = await _setup_climate_test(hass) state = hass.states.get(ENTITY_CLIMATE) modes = state.attributes.get(ATTR_PRESET_MODES) assert ["Ready", "Rest", "Ready in Rest"] == modes # Put it in Ready and Rest modelist = ["Ready", "Rest"] for mode in modelist: with patch( "homeassistant.components.balboa.BalboaSpaWifi.get_heatmode", return_value=modelist.index(mode), ): await common.async_set_preset_mode(hass, mode, ENTITY_CLIMATE) async_dispatcher_send(hass, SIGNAL_UPDATE.format(config_entry.entry_id)) await hass.async_block_till_done() state = hass.states.get(ENTITY_CLIMATE) assert state.attributes[ATTR_PRESET_MODE] == modelist.index(mode) # put it in RNR and test assertion with patch( "homeassistant.components.balboa.BalboaSpaWifi.get_heatmode", return_value=2, ), pytest.raises(HomeAssistantError): await common.async_set_preset_mode(hass, 2, ENTITY_CLIMATE)
async def _patch_filter(hass, config_entry, filter_mode, num): """Patch the filter state.""" with patch( "homeassistant.components.balboa.BalboaSpaWifi.get_filtermode", return_value=filter_mode, ): async_dispatcher_send(hass, SIGNAL_UPDATE.format(config_entry.entry_id)) await hass.async_block_till_done() return hass.states.get(f"{ENTITY_BINARY_SENSOR}filter{num}")
async def _patch_circ_pump(hass, config_entry, pump_state): """Patch the circ pump state.""" with patch( "homeassistant.components.balboa.BalboaSpaWifi.get_circ_pump", return_value=pump_state, ): async_dispatcher_send(hass, SIGNAL_UPDATE.format(config_entry.entry_id)) await hass.async_block_till_done() return hass.states.get(f"{ENTITY_BINARY_SENSOR}circ_pump")
async def _patch_spa_heatstate(hass, config_entry, heat_state): """Patch the heatmode.""" with patch( "homeassistant.components.balboa.BalboaSpaWifi.get_heatstate", return_value=heat_state, ): await common.async_set_hvac_mode(hass, HVAC_SETTINGS[heat_state], ENTITY_CLIMATE) async_dispatcher_send(hass, SIGNAL_UPDATE.format(config_entry.entry_id)) await hass.async_block_till_done() return hass.states.get(ENTITY_CLIMATE)
async def _patch_blower(hass, config_entry, fan_state): """Patch the blower state.""" with patch( "homeassistant.components.balboa.BalboaSpaWifi.get_blower", return_value=fan_state, ): if fan_state is not None and fan_state <= len(FAN_SETTINGS): await common.async_set_fan_mode(hass, FAN_SETTINGS[fan_state]) async_dispatcher_send(hass, SIGNAL_UPDATE.format(config_entry.entry_id)) await hass.async_block_till_done() return hass.states.get(ENTITY_CLIMATE)
async def _patch_spa_settemp(hass, config_entry, tscale, settemp): """Patch the settemp.""" with patch( "homeassistant.components.balboa.BalboaSpaWifi.get_tempscale", return_value=tscale, ), patch( "homeassistant.components.balboa.BalboaSpaWifi.get_settemp", return_value=settemp, ): await common.async_set_temperature(hass, temperature=settemp, entity_id=ENTITY_CLIMATE) async_dispatcher_send(hass, SIGNAL_UPDATE.format(config_entry.entry_id)) await hass.async_block_till_done() return hass.states.get(ENTITY_CLIMATE)