Esempio n. 1
0
 def test_reset(self):
     """Test resetting the alert."""
     assert setup_component(self.hass, alert.DOMAIN, TEST_CONFIG)
     self.hass.states.set("sensor.test", STATE_ON)
     self.hass.block_till_done()
     alert.turn_off(self.hass, ENTITY_ID)
     self.hass.block_till_done()
     self.assertEqual(STATE_OFF, self.hass.states.get(ENTITY_ID).state)
     alert.turn_on(self.hass, ENTITY_ID)
     self.hass.block_till_done()
     self.assertEqual(STATE_ON, self.hass.states.get(ENTITY_ID).state)
Esempio n. 2
0
 def test_reset(self):
     """Test resetting the alert."""
     assert setup_component(self.hass, alert.DOMAIN, TEST_CONFIG)
     self.hass.states.set("sensor.test", STATE_ON)
     self.hass.block_till_done()
     alert.turn_off(self.hass, ENTITY_ID)
     self.hass.block_till_done()
     self.assertEqual(STATE_OFF, self.hass.states.get(ENTITY_ID).state)
     alert.turn_on(self.hass, ENTITY_ID)
     self.hass.block_till_done()
     self.assertEqual(STATE_ON, self.hass.states.get(ENTITY_ID).state)
Esempio n. 3
0
    def test_hidden(self):
        """Test entity hidding."""
        assert setup_component(self.hass, alert.DOMAIN, TEST_CONFIG)
        hidden = self.hass.states.get(ENTITY_ID).attributes.get('hidden')
        self.assertTrue(hidden)

        self.hass.states.set("sensor.test", STATE_ON)
        self.hass.block_till_done()
        hidden = self.hass.states.get(ENTITY_ID).attributes.get('hidden')
        self.assertFalse(hidden)

        alert.turn_off(self.hass, ENTITY_ID)
        hidden = self.hass.states.get(ENTITY_ID).attributes.get('hidden')
        self.assertFalse(hidden)
Esempio n. 4
0
    def test_hidden(self):
        """Test entity hidding."""
        assert setup_component(self.hass, alert.DOMAIN, TEST_CONFIG)
        hidden = self.hass.states.get(ENTITY_ID).attributes.get('hidden')
        self.assertTrue(hidden)

        self.hass.states.set("sensor.test", STATE_ON)
        self.hass.block_till_done()
        hidden = self.hass.states.get(ENTITY_ID).attributes.get('hidden')
        self.assertFalse(hidden)

        alert.turn_off(self.hass, ENTITY_ID)
        hidden = self.hass.states.get(ENTITY_ID).attributes.get('hidden')
        self.assertFalse(hidden)
Esempio n. 5
0
    def test_silence(self):
        """Test silencing the alert."""
        assert setup_component(self.hass, alert.DOMAIN, TEST_CONFIG)
        self.hass.states.set("sensor.test", STATE_ON)
        self.hass.block_till_done()
        alert.turn_off(self.hass, ENTITY_ID)
        self.hass.block_till_done()
        self.assertEqual(STATE_OFF, self.hass.states.get(ENTITY_ID).state)

        # alert should not be silenced on next fire
        self.hass.states.set("sensor.test", STATE_OFF)
        self.hass.block_till_done()
        self.assertEqual(STATE_IDLE, self.hass.states.get(ENTITY_ID).state)
        self.hass.states.set("sensor.test", STATE_ON)
        self.hass.block_till_done()
        self.assertEqual(STATE_ON, self.hass.states.get(ENTITY_ID).state)
Esempio n. 6
0
    def test_silence(self):
        """Test silencing the alert."""
        assert setup_component(self.hass, alert.DOMAIN, TEST_CONFIG)
        self.hass.states.set("sensor.test", STATE_ON)
        self.hass.block_till_done()
        alert.turn_off(self.hass, ENTITY_ID)
        self.hass.block_till_done()
        self.assertEqual(STATE_OFF, self.hass.states.get(ENTITY_ID).state)

        # alert should not be silenced on next fire
        self.hass.states.set("sensor.test", STATE_OFF)
        self.hass.block_till_done()
        self.assertEqual(STATE_IDLE, self.hass.states.get(ENTITY_ID).state)
        self.hass.states.set("sensor.test", STATE_ON)
        self.hass.block_till_done()
        self.assertEqual(STATE_ON, self.hass.states.get(ENTITY_ID).state)