forked from danielperna84/custom_homematic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_sensor.py
57 lines (41 loc) · 1.94 KB
/
test_sensor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Tests for switch entities of hahomematic."""
from __future__ import annotations
import pytest
from homeassistant.const import STATE_UNKNOWN
from tests import const, helper
TEST_DEVICES: dict[str, str] = {
"VCU7837366": "HB-UNI-Sensor1.json",
}
# pylint: disable=protected-access
@pytest.mark.asyncio
async def test_sensor_trans(factory: helper.Factory) -> None:
"""Test sensor with translation."""
entity_id = "sensor.hb_uni_sensor1_vcu7837366_dew_point"
entity_name = "HB-UNI-Sensor1_VCU7837366 dew point"
hass, control = await factory.setup_environment(TEST_DEVICES)
ha_state, hm_entity = helper.get_and_check_state(
hass=hass, control=control, entity_id=entity_id, entity_name=entity_name
)
assert ha_state.state == STATE_UNKNOWN
control.central.event(const.INTERFACE_ID, "VCU7837366:1", "Taupunkt", 1)
await hass.async_block_till_done()
assert hass.states.get(entity_id).state == "1.0"
control.central.event(const.INTERFACE_ID, "VCU7837366:1", "Taupunkt", 0)
await hass.async_block_till_done()
assert hass.states.get(entity_id).state == "0.0"
@pytest.mark.asyncio
async def test_sensor_to_trans(factory: helper.Factory) -> None:
"""Test sensor without translation."""
entity_id = "sensor.hb_uni_sensor1_vcu7837366_abs_luftfeuchte"
entity_name = "HB-UNI-Sensor1_VCU7837366 Abs Luftfeuchte"
hass, control = await factory.setup_environment(TEST_DEVICES)
ha_state, hm_entity = helper.get_and_check_state(
hass=hass, control=control, entity_id=entity_id, entity_name=entity_name
)
assert ha_state.state == STATE_UNKNOWN
control.central.event(const.INTERFACE_ID, "VCU7837366:1", "Abs_Luftfeuchte", 1)
await hass.async_block_till_done()
assert hass.states.get(entity_id).state == "1.0"
control.central.event(const.INTERFACE_ID, "VCU7837366:1", "Abs_Luftfeuchte", 0)
await hass.async_block_till_done()
assert hass.states.get(entity_id).state == "0.0"