Exemplo n.º 1
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)
        assert 'off' == state.attributes.get('away_mode')

        common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        assert '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)
        assert '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)
        assert '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)
        assert 'off' == state.attributes.get('away_mode')
Exemplo n.º 2
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)
        assert 'off' == state.attributes.get('away_mode')

        common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY_CLIMATE)
        assert '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)
        assert '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)
        assert '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)
        assert 'off' == state.attributes.get('away_mode')
Exemplo n.º 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)
     assert 'on' == state.attributes.get('away_mode')
     common.set_away_mode(self.hass, None, ENTITY_CLIMATE)
     self.hass.block_till_done()
     assert 'on' == state.attributes.get('away_mode')
Exemplo n.º 4
0
 def test_set_away_mode_bad_attr(self):
     """Test setting the away mode without required attribute."""
     state = self.hass.states.get(ENTITY_CLIMATE)
     assert 'on' == state.attributes.get('away_mode')
     common.set_away_mode(self.hass, None, ENTITY_CLIMATE)
     self.hass.block_till_done()
     assert 'on' == state.attributes.get('away_mode')
Exemplo n.º 5
0
 def test_set_away_mode(self):
     """Test the setting away mode."""
     common.set_temperature(self.hass, 23)
     self.hass.block_till_done()
     common.set_away_mode(self.hass, True)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY)
     self.assertEqual(16, state.attributes.get('temperature'))
Exemplo n.º 6
0
 def test_turn_away_mode_on_cooling(self):
     """Test the setting away mode when cooling."""
     self._setup_sensor(25)
     self.hass.block_till_done()
     common.set_temperature(self.hass, 19)
     self.hass.block_till_done()
     common.set_away_mode(self.hass, True)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY)
     self.assertEqual(30, state.attributes.get('temperature'))
Exemplo n.º 7
0
    def test_set_away_mode_and_restore_prev_temp(self):
        """Test the setting and removing away mode.

        Verify original temperature is restored.
        """
        common.set_temperature(self.hass, 23)
        self.hass.block_till_done()
        common.set_away_mode(self.hass, True)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY)
        self.assertEqual(16, state.attributes.get('temperature'))
        common.set_away_mode(self.hass, False)
        self.hass.block_till_done()
        state = self.hass.states.get(ENTITY)
        self.assertEqual(23, state.attributes.get('temperature'))
Exemplo n.º 8
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)
        assert 'off' == state.attributes.get('away_mode')
        common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.mock_publish.async_publish.assert_called_once_with(
            'away-mode-topic', 'AN', 0, False)
        self.mock_publish.async_publish.reset_mock()
        state = self.hass.states.get(ENTITY_CLIMATE)
        assert 'on' == state.attributes.get('away_mode')

        common.set_away_mode(self.hass, False, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.mock_publish.async_publish.assert_called_once_with(
            'away-mode-topic', 'AUS', 0, False)
        state = self.hass.states.get(ENTITY_CLIMATE)
        assert 'off' == state.attributes.get('away_mode')
Exemplo n.º 9
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)
        assert 'off' == state.attributes.get('away_mode')
        common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.mock_publish.async_publish.assert_called_once_with(
            'away-mode-topic', 'AN', 0, False)
        self.mock_publish.async_publish.reset_mock()
        state = self.hass.states.get(ENTITY_CLIMATE)
        assert 'on' == state.attributes.get('away_mode')

        common.set_away_mode(self.hass, False, ENTITY_CLIMATE)
        self.hass.block_till_done()
        self.mock_publish.async_publish.assert_called_once_with(
            'away-mode-topic', 'AUS', 0, False)
        state = self.hass.states.get(ENTITY_CLIMATE)
        assert 'off' == state.attributes.get('away_mode')
Exemplo n.º 10
0
 def test_set_away_mode_off(self):
     """Test setting the away mode off/false."""
     common.set_away_mode(self.hass, False, ENTITY_CLIMATE)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     assert 'off' == state.attributes.get('away_mode')
Exemplo n.º 11
0
 def test_set_away_mode_on(self):
     """Test setting the away mode on/true."""
     common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     assert 'on' == state.attributes.get('away_mode')
Exemplo n.º 12
0
 def test_set_away_mode_off(self):
     """Test setting the away mode off/false."""
     common.set_away_mode(self.hass, False, ENTITY_CLIMATE)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     assert 'off' == state.attributes.get('away_mode')
Exemplo n.º 13
0
 def test_set_away_mode_on(self):
     """Test setting the away mode on/true."""
     common.set_away_mode(self.hass, True, ENTITY_CLIMATE)
     self.hass.block_till_done()
     state = self.hass.states.get(ENTITY_CLIMATE)
     assert 'on' == state.attributes.get('away_mode')