def test_set_away_mode_pessimistic(self):
        """Test setting of the away mode."""
        config = copy.deepcopy(DEFAULT_CONFIG)
        config['climate']['away_mode_state_topic'] = 'away-state'
        assert setup_component(self.hass, climate.DOMAIN, config)

        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))

        climate.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))

        fire_mqtt_message(self.hass, 'away-state', 'ON')
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('on', state.attributes.get('away_mode'))

        fire_mqtt_message(self.hass, 'away-state', 'OFF')
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))

        fire_mqtt_message(self.hass, 'away-state', 'nonsense')
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))
Beispiel #2
0
 def test_set_away_mode_bad_attr(self):
     """Test setting the away mode without required attribute."""
     state = self.hass.states.get(ENTITY_CLIMATE)
     self.assertEqual('on', state.attributes.get('away_mode'))
     climate.set_away_mode(self.hass, None, ENTITY_CLIMATE)
     self.hass.block_till_done()
     self.assertEqual('on', state.attributes.get('away_mode'))
Beispiel #3
0
 def test_set_away_mode_bad_attr(self):
     """Test setting the away mode without required attribute."""
     state = self.hass.states.get(ENTITY_CLIMATE)
     self.assertEqual('on', state.attributes.get('away_mode'))
     climate.set_away_mode(self.hass, None, ENTITY_CLIMATE)
     self.hass.pool.block_till_done()
     self.assertEqual('on', state.attributes.get('away_mode'))
Beispiel #4
0
    def test_set_away_mode_pessimistic(self):
        """Test setting of the away mode."""
        config = copy.deepcopy(DEFAULT_CONFIG)
        config['climate']['away_mode_state_topic'] = 'away-state'
        assert setup_component(self.hass, climate.DOMAIN, config)

        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))

        climate.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))

        fire_mqtt_message(self.hass, 'away-state', 'ON')
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('on', state.attributes.get('away_mode'))

        fire_mqtt_message(self.hass, 'away-state', 'OFF')
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))

        fire_mqtt_message(self.hass, 'away-state', 'nonsense')
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))
 def test_set_away_mode(self):
     """Test the setting away mode."""
     climate.set_temperature(self.hass, 23)
     self.hass.block_till_done()
     climate.set_away_mode(self.hass, True)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY)
     self.assertEqual(16, state.attributes.get('temperature'))
 def test_set_away_mode(self):
     """Test the setting away mode."""
     climate.set_temperature(self.hass, 23)
     self.hass.block_till_done()
     climate.set_away_mode(self.hass, True)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY)
     self.assertEqual(16, state.attributes.get('temperature'))
 def test_turn_away_mode_on_cooling(self):
     """Test the setting away mode when cooling."""
     self._setup_sensor(25)
     self.hass.block_till_done()
     climate.set_temperature(self.hass, 19)
     self.hass.block_till_done()
     climate.set_away_mode(self.hass, True)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY)
     self.assertEqual(30, state.attributes.get('temperature'))
 def test_turn_away_mode_on_cooling(self):
     """Test the setting away mode when cooling."""
     self._setup_sensor(25)
     self.hass.block_till_done()
     climate.set_temperature(self.hass, 19)
     self.hass.block_till_done()
     climate.set_away_mode(self.hass, True)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY)
     self.assertEqual(30, state.attributes.get('temperature'))
    def test_set_away_mode_and_restore_prev_temp(self):
        """Test the setting and removing away mode.

        Verify original temperature is restored.
        """
        climate.set_temperature(self.hass, 23)
        self.hass.block_till_done()
        climate.set_away_mode(self.hass, True)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY)
        self.assertEqual(16, state.attributes.get('temperature'))
        climate.set_away_mode(self.hass, False)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY)
        self.assertEqual(23, state.attributes.get('temperature'))
    def test_set_away_mode_and_restore_prev_temp(self):
        """Test the setting and removing away mode.

        Verify original temperature is restored.
        """
        climate.set_temperature(self.hass, 23)
        self.hass.block_till_done()
        climate.set_away_mode(self.hass, True)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY)
        self.assertEqual(16, state.attributes.get('temperature'))
        climate.set_away_mode(self.hass, False)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY)
        self.assertEqual(23, state.attributes.get('temperature'))
    def test_set_away_mode(self):
        """Test setting of the away mode."""
        config = copy.deepcopy(DEFAULT_CONFIG)
        config['climate']['payload_on'] = 'AN'
        config['climate']['payload_off'] = 'AUS'

        assert setup_component(self.hass, climate.DOMAIN, config)

        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))
        climate.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.assertEqual(('away-mode-topic', 'AN', 0, False),
                         self.mock_publish.mock_calls[-2][1])
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('on', state.attributes.get('away_mode'))

        climate.set_away_mode(self.hass, False, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.assertEqual(('away-mode-topic', 'AUS', 0, False),
                         self.mock_publish.mock_calls[-2][1])
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))
Beispiel #12
0
    def test_set_away_mode(self):
        """Test setting of the away mode."""
        config = copy.deepcopy(DEFAULT_CONFIG)
        config['climate']['payload_on'] = 'AN'
        config['climate']['payload_off'] = 'AUS'

        assert setup_component(self.hass, climate.DOMAIN, config)

        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))
        climate.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.assertEqual(('away-mode-topic', 'AN', 0, False),
                         self.mock_publish.mock_calls[-2][1])
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('on', state.attributes.get('away_mode'))

        climate.set_away_mode(self.hass, False, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.assertEqual(('away-mode-topic', 'AUS', 0, False),
                         self.mock_publish.mock_calls[-2][1])
        state = self.hass.states.get(ENTITY_CLIMATE)
        self.assertEqual('off', state.attributes.get('away_mode'))
Beispiel #13
0
 def test_set_away_mode_off(self):
     """Test setting the away mode off/false."""
     climate.set_away_mode(self.hass, False, ENTITY_CLIMATE)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     self.assertEqual('off', state.attributes.get('away_mode'))
Beispiel #14
0
 def test_set_away_mode_off(self):
     """Test setting the away mode off/false."""
     climate.set_away_mode(self.hass, False, ENTITY_CLIMATE)
     self.hass.pool.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     self.assertEqual('off', state.attributes.get('away_mode'))
Beispiel #15
0
 def test_set_away_mode_on(self):
     """Test setting the away mode on/true."""
     climate.set_away_mode(self.hass, True, ENTITY_CLIMATE)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     self.assertEqual('on', state.attributes.get('away_mode'))
Beispiel #16
0
 def test_set_away_mode_on(self):
     """Test setting the away mode on/true."""
     climate.set_away_mode(self.hass, True, ENTITY_CLIMATE)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     self.assertEqual("on", state.attributes.get("away_mode"))