| 1 | """Test pydeCONZ sensors. |
| 2 | |
| 3 | pytest --cov-report term-missing --cov=pydeconz.sensor tests/test_sensors.py |
| 4 | """ |
| 5 | |
| 6 | from pydeconz.models import ResourceType |
| 7 | |
| 8 | from tests import sensors as sensor_test_data |
| 9 | |
| 10 | |
| 11 | async def test_create_all_sensors(deconz_refresh_state): |
| 12 | """Verify that creating all sensors work.""" |
| 13 | deconz_session = await deconz_refresh_state( |
| 14 | sensors={ |
| 15 | "0": sensor_test_data.test_air_purifier.DATA, |
| 16 | "1": sensor_test_data.test_air_quality.DATA, |
| 17 | "2": sensor_test_data.test_alarm.DATA, |
| 18 | "3": sensor_test_data.test_ancillary_control.DATA, |
| 19 | "4": sensor_test_data.test_battery.DATA, |
| 20 | "5": sensor_test_data.test_carbon_dioxide.DATA, |
| 21 | "6": sensor_test_data.test_carbon_monoxide.DATA, |
| 22 | "7": sensor_test_data.test_consumption.DATA, |
| 23 | "8": sensor_test_data.test_daylight.DATA, |
| 24 | "9": sensor_test_data.test_door_lock.DATA, |
| 25 | "10": sensor_test_data.test_fire.DATA, |
| 26 | "11": sensor_test_data.test_formaldehyde.DATA, |
| 27 | "12": sensor_test_data.test_generic_flag.DATA, |
| 28 | "13": sensor_test_data.test_generic_status.DATA, |
| 29 | "14": sensor_test_data.test_humidity.DATA, |
| 30 | "15": sensor_test_data.test_light_level.DATA, |
| 31 | "16": sensor_test_data.test_moisture.DATA, |
| 32 | "17": sensor_test_data.test_open_close.DATA, |
| 33 | "18": sensor_test_data.test_particulate_matter.DATA, |
| 34 | "19": sensor_test_data.test_power.DATA, |
| 35 | "20": sensor_test_data.test_presence.DATA, |
| 36 | "21": sensor_test_data.test_pressure.DATA, |
| 37 | "22": sensor_test_data.test_relative_rotary.DATA, |
| 38 | "23": sensor_test_data.test_switch.DATA, |
| 39 | "24": sensor_test_data.test_temperature.DATA, |
| 40 | "25": sensor_test_data.test_thermostat.DATA, |
| 41 | "26": sensor_test_data.test_time.DATA, |
| 42 | "27": sensor_test_data.test_vibration.DATA, |
| 43 | "28": sensor_test_data.test_water.DATA, |
| 44 | }, |
| 45 | ) |
| 46 | sensors = deconz_session.sensors |
| 47 | assert len(sensors._handlers) == 29 |
| 48 | assert sensors["0"].type == ResourceType.ZHA_AIR_PURIFIER |
| 49 | assert sensors["1"].type == ResourceType.ZHA_AIR_QUALITY |
| 50 | assert sensors["2"].type == ResourceType.ZHA_ALARM |
| 51 | assert sensors["3"].type == ResourceType.ZHA_ANCILLARY_CONTROL |
| 52 | assert sensors["4"].type == ResourceType.ZHA_BATTERY |
| 53 | assert sensors["5"].type == ResourceType.ZHA_CARBON_DIOXIDE |
| 54 | assert sensors["6"].type == ResourceType.ZHA_CARBON_MONOXIDE |
| 55 | assert sensors["7"].type == ResourceType.ZHA_CONSUMPTION |
| 56 | assert sensors["8"].type == ResourceType.DAYLIGHT |
| 57 | assert sensors["9"].type == ResourceType.ZHA_DOOR_LOCK |
| 58 | assert sensors["10"].type == ResourceType.ZHA_FIRE |
| 59 | assert sensors["11"].type == ResourceType.ZHA_FORMALDEHYDE |
| 60 | assert sensors["12"].type == ResourceType.CLIP_GENERIC_FLAG |
| 61 | assert sensors["13"].type == ResourceType.CLIP_GENERIC_STATUS |
| 62 | assert sensors["14"].type == ResourceType.ZHA_HUMIDITY |
| 63 | assert sensors["15"].type == ResourceType.ZHA_LIGHT_LEVEL |
| 64 | assert sensors["16"].type == ResourceType.ZHA_MOISTURE |
| 65 | assert sensors["17"].type == ResourceType.ZHA_OPEN_CLOSE |
| 66 | assert sensors["18"].type == ResourceType.ZHA_PARTICULATE_MATTER |
| 67 | assert sensors["19"].type == ResourceType.ZHA_POWER |
| 68 | assert sensors["20"].type == ResourceType.ZHA_PRESENCE |
| 69 | assert sensors["21"].type == ResourceType.ZHA_PRESSURE |
| 70 | assert sensors["22"].type == ResourceType.ZHA_RELATIVE_ROTARY |
| 71 | assert sensors["23"].type == ResourceType.ZHA_SWITCH |
| 72 | assert sensors["24"].type == ResourceType.ZHA_TEMPERATURE |
| 73 | assert sensors["25"].type == ResourceType.ZHA_THERMOSTAT |
| 74 | assert sensors["26"].type == ResourceType.ZHA_TIME |
| 75 | assert sensors["27"].type == ResourceType.ZHA_VIBRATION |
| 76 | assert sensors["28"].type == ResourceType.ZHA_WATER |