def test_air_quality(self): """Test if accessory is updated after state change.""" entity_id = 'sensor.air_quality' acc = AirQualitySensor(self.hass, 'Air Quality', entity_id, 2, config=None) acc.run() self.assertEqual(acc.aid, 2) self.assertEqual(acc.category, 10) # Sensor self.assertEqual(acc.char_density.value, 0) self.assertEqual(acc.char_quality.value, 0) self.hass.states.set(entity_id, STATE_UNKNOWN) self.hass.block_till_done() self.assertEqual(acc.char_density.value, 0) self.assertEqual(acc.char_quality.value, 0) self.hass.states.set(entity_id, '34') self.hass.block_till_done() self.assertEqual(acc.char_density.value, 34) self.assertEqual(acc.char_quality.value, 1) self.hass.states.set(entity_id, '200') self.hass.block_till_done() self.assertEqual(acc.char_density.value, 200) self.assertEqual(acc.char_quality.value, 5)
def test_air_quality(self): """Test if accessory is updated after state change.""" entity_id = 'sensor.air_quality' acc = AirQualitySensor(self.hass, 'Air Quality', entity_id, 2, config=None) acc.run() self.assertEqual(acc.aid, 2) self.assertEqual(acc.category, 10) # Sensor self.assertEqual(acc.char_density.value, 0) self.assertEqual(acc.char_quality.value, 0) self.hass.states.set(entity_id, STATE_UNKNOWN) self.hass.block_till_done() self.assertEqual(acc.char_density.value, 0) self.assertEqual(acc.char_quality.value, 0) self.hass.states.set(entity_id, '34') self.hass.block_till_done() self.assertEqual(acc.char_density.value, 34) self.assertEqual(acc.char_quality.value, 1) self.hass.states.set(entity_id, '200') self.hass.block_till_done() self.assertEqual(acc.char_density.value, 200) self.assertEqual(acc.char_quality.value, 5)
async def test_air_quality(hass, hk_driver): """Test if accessory is updated after state change.""" entity_id = 'sensor.air_quality' hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = AirQualitySensor(hass, hk_driver, 'Air Quality', entity_id, 2, None) await hass.async_add_job(acc.run) assert acc.aid == 2 assert acc.category == 10 # Sensor assert acc.char_density.value == 0 assert acc.char_quality.value == 0 hass.states.async_set(entity_id, STATE_UNKNOWN) await hass.async_block_till_done() assert acc.char_density.value == 0 assert acc.char_quality.value == 0 hass.states.async_set(entity_id, '34') await hass.async_block_till_done() assert acc.char_density.value == 34 assert acc.char_quality.value == 1 hass.states.async_set(entity_id, '200') await hass.async_block_till_done() assert acc.char_density.value == 200 assert acc.char_quality.value == 5
async def test_air_quality(hass, hk_driver): """Test if accessory is updated after state change.""" entity_id = "sensor.air_quality" hass.states.async_set(entity_id, None) await hass.async_block_till_done() acc = AirQualitySensor(hass, hk_driver, "Air Quality", entity_id, 2, None) await acc.run_handler() await hass.async_block_till_done() assert acc.aid == 2 assert acc.category == 10 # Sensor assert acc.char_density.value == 0 assert acc.char_quality.value == 0 hass.states.async_set(entity_id, STATE_UNKNOWN) await hass.async_block_till_done() assert acc.char_density.value == 0 assert acc.char_quality.value == 0 hass.states.async_set(entity_id, "34") await hass.async_block_till_done() assert acc.char_density.value == 34 assert acc.char_quality.value == 1 hass.states.async_set(entity_id, "200") await hass.async_block_till_done() assert acc.char_density.value == 200 assert acc.char_quality.value == 5