| 1 |
"""Test pydeCONZ humidity.""" |
| 2 |
|
| 3 |
DATA = { |
| 4 |
"config": { |
| 5 |
"battery": 100, |
| 6 |
"offset": 0, |
| 7 |
"on": True, |
| 8 |
"reachable": True, |
| 9 |
}, |
| 10 |
"ep": 1, |
| 11 |
"etag": "1220e5d026493b6e86207993703a8a71", |
| 12 |
"manufacturername": "LUMI", |
| 13 |
"modelid": "lumi.weather", |
| 14 |
"name": "Mi temperature 1", |
| 15 |
"state": { |
| 16 |
"humidity": 3555, |
| 17 |
"lastupdated": "2019-05-05T14:39:00", |
| 18 |
}, |
| 19 |
"swversion": "20161129", |
| 20 |
"type": "ZHAHumidity", |
| 21 |
"uniqueid": "xx:xx:xx:xx:xx:xx:xx:xx-01-0405", |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
async def test_handler_humidity(mock_aioresponse, deconz_session, deconz_called_with): |
| 26 |
"""Verify that humidity sensor works.""" |
| 27 |
humidity = deconz_session.sensors.humidity |
| 28 |
|
| 29 |
mock_aioresponse.put("http://host:80/api/apikey/sensors/0/config") |
| 30 |
await humidity.set_config("0", offset=1) |
| 31 |
assert deconz_called_with("put", path="/sensors/0/config", json={"offset": 1}) |
| 32 |
|
| 33 |
|
| 34 |
async def test_sensor_humidity(deconz_sensor): |
| 35 |
"""Verify that humidity sensor works.""" |
| 36 |
sensor = await deconz_sensor(DATA) |
| 37 |
|
| 38 |
assert sensor.humidity == 3555 |
| 39 |
assert sensor.offset == 0 |
| 40 |
assert sensor.scaled_humidity == 35.55 |
| 41 |
|
| 42 |
|
| 43 |
assert sensor.battery == 100 |
| 44 |
assert sensor.ep == 1 |
| 45 |
assert sensor.low_battery is None |
| 46 |
assert sensor.on is True |
| 47 |
assert sensor.reachable is True |
| 48 |
assert sensor.tampered is None |
| 49 |
assert sensor.internal_temperature is None |
| 50 |
|
| 51 |
|
| 52 |
assert sensor.deconz_id == "/sensors/0" |
| 53 |
assert sensor.etag == "1220e5d026493b6e86207993703a8a71" |
| 54 |
assert sensor.manufacturer == "LUMI" |
| 55 |
assert sensor.model_id == "lumi.weather" |
| 56 |
assert sensor.name == "Mi temperature 1" |
| 57 |
assert sensor.software_version == "20161129" |
| 58 |
assert sensor.type == "ZHAHumidity" |
| 59 |
assert sensor.unique_id == "xx:xx:xx:xx:xx:xx:xx:xx-01-0405" |