コード例 #1
0
 def test_dyson_v2_sensor_state_init(self):
     dyson_sensor_state = DysonEnvironmentalSensorV2State(
         open("tests/data/sensor_pure_cool_init.json", "r").read())
     self.assertEqual(dyson_sensor_state.temperature, 0)
     self.assertEqual(dyson_sensor_state.humidity, 0)
     self.assertEqual(dyson_sensor_state.particulate_matter_25, 0)
     self.assertEqual(dyson_sensor_state.particulate_matter_10, 0)
     self.assertEqual(dyson_sensor_state.volatile_organic_compounds, 0)
     self.assertEqual(dyson_sensor_state.volatile_organic_compounds, 0)
     self.assertEqual(dyson_sensor_state.p25r, 0)
     self.assertEqual(dyson_sensor_state.p10r, 0)
     self.assertEqual(
         dyson_sensor_state.__repr__(), "DysonEnvironmentalSensorV2State("
         "temperature=0,humidity=0,particulate_matter_25=0,"
         "particulate_matter_10=0,"
         "volatile_organic_compounds=0,nitrogen_dioxide=0,"
         "p25r=0,p10r=0,sleep_timer=0)")
コード例 #2
0
 def test_dyson_v2_sensor_state(self):
     dyson_sensor_state = DysonEnvironmentalSensorV2State(
         open("tests/data/sensor_pure_cool.json", "r").read())
     self.assertEqual(dyson_sensor_state.temperature, 297.7)
     self.assertEqual(dyson_sensor_state.humidity, 58)
     self.assertEqual(dyson_sensor_state.particulate_matter_25, 9)
     self.assertEqual(dyson_sensor_state.particulate_matter_10, 5)
     self.assertEqual(dyson_sensor_state.volatile_organic_compounds, 4)
     self.assertEqual(dyson_sensor_state.volatile_organic_compounds, 4)
     self.assertEqual(dyson_sensor_state.p25r, 10)
     self.assertEqual(dyson_sensor_state.p10r, 9)
     self.assertEqual(
         dyson_sensor_state.__repr__(), "DysonEnvironmentalSensorV2State("
         "temperature=297.7,humidity=58,"
         "particulate_matter_25=9,particulate_matter_10=5,"
         "volatile_organic_compounds=4,nitrogen_dioxide=11,"
         "p25r=10,p10r=9,sleep_timer=0)")
コード例 #3
0
async def test_purecool_aiq_update_state(devices, login, hass):
    """Test state update."""
    device = devices.return_value[0]
    await async_setup_component(hass, dyson_parent.DOMAIN, _get_config())
    await hass.async_block_till_done()
    event = {
        "msg": "ENVIRONMENTAL-CURRENT-SENSOR-DATA",
        "time": "2019-03-29T10:00:01.000Z",
        "data": {
            "pm10": "0080",
            "p10r": "0151",
            "hact": "0040",
            "va10": "0055",
            "p25r": "0161",
            "noxl": "0069",
            "pm25": "0035",
            "sltm": "OFF",
            "tact": "2960",
        },
    }
    device.environmental_state = DysonEnvironmentalSensorV2State(
        json.dumps(event))

    for call in device.add_message_listener.call_args_list:
        callback = call[0][0]
        if type(callback.__self__) == dyson.DysonAirSensor:
            callback(device.environmental_state)

    await hass.async_block_till_done()
    fan_state = hass.states.get("air_quality.living_room")
    attributes = fan_state.attributes

    assert fan_state.state == "35"
    assert attributes[ATTR_PM_2_5] == 35
    assert attributes[ATTR_PM_10] == 80
    assert attributes[ATTR_NO2] == 69
    assert attributes[dyson.ATTR_VOC] == 55