| 1 |
"""Test pydeCONZ moisture.""" |
| 2 |
|
| 3 |
DATA = { |
| 4 |
"config": { |
| 5 |
"battery": 100, |
| 6 |
"offset": 0, |
| 7 |
"on": True, |
| 8 |
"reachable": True, |
| 9 |
}, |
| 10 |
"etag": "c35662de2333cf107ca22818d8d0a57b", |
| 11 |
"lastannounced": "2023-05-13T10:25:54Z", |
| 12 |
"lastseen": "2023-05-13T11:43Z", |
| 13 |
"manufacturername": "_TZE200_myd45weu", |
| 14 |
"modelid": "TS0601", |
| 15 |
"name": "Soil Sensor", |
| 16 |
"state": { |
| 17 |
"lastupdated": "2023-05-13T11:43:05.976", |
| 18 |
"lowbattery": False, |
| 19 |
"moisture": 9000, |
| 20 |
}, |
| 21 |
"swversion": "1.0.8", |
| 22 |
"type": "ZHAMoisture", |
| 23 |
"uniqueid": "xx:xx:xx:xx:xx:xx:xx:xx-01-0408", |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
async def test_handler_moisture(mock_aioresponse, deconz_session, deconz_called_with): |
| 28 |
"""Verify that moisture sensor works.""" |
| 29 |
moisture = deconz_session.sensors.moisture |
| 30 |
|
| 31 |
mock_aioresponse.put("http://host:80/api/apikey/sensors/0/config") |
| 32 |
await moisture.set_config("0", offset=1) |
| 33 |
assert deconz_called_with("put", path="/sensors/0/config", json={"offset": 1}) |
| 34 |
|
| 35 |
|
| 36 |
async def test_sensor_moisture(deconz_sensor): |
| 37 |
"""Verify that moisture sensor works.""" |
| 38 |
sensor = await deconz_sensor(DATA) |
| 39 |
|
| 40 |
assert sensor.moisture == 9000 |
| 41 |
assert sensor.offset == 0 |
| 42 |
assert sensor.scaled_moisture == 90 |
| 43 |
|
| 44 |
|
| 45 |
assert sensor.battery == 100 |
| 46 |
assert sensor.low_battery is False |
| 47 |
assert sensor.on is True |
| 48 |
assert sensor.reachable is True |
| 49 |
assert sensor.tampered is None |
| 50 |
assert sensor.internal_temperature is None |
| 51 |
|
| 52 |
|
| 53 |
assert sensor.deconz_id == "/sensors/0" |
| 54 |
assert sensor.etag == "c35662de2333cf107ca22818d8d0a57b" |
| 55 |
assert sensor.manufacturer == "_TZE200_myd45weu" |
| 56 |
assert sensor.model_id == "TS0601" |
| 57 |
assert sensor.name == "Soil Sensor" |
| 58 |
assert sensor.software_version == "1.0.8" |
| 59 |
assert sensor.type == "ZHAMoisture" |
| 60 |
assert sensor.unique_id == "xx:xx:xx:xx:xx:xx:xx:xx-01-0408" |