File: test_wave_mini.py

package info (click to toggle)
airthings-ble 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: python: 1,577; makefile: 3
file content (36 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download
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
import logging

from airthings_ble.command_decode import WaveRadonAndPlusCommandDecode
from airthings_ble.const import BATTERY
from airthings_ble.sensor_decoders import _decode_wave_plus

_LOGGER = logging.getLogger(__name__)


def test_wave_plus_command_decode() -> None:
    """Test wave plus command decode."""
    decode = WaveRadonAndPlusCommandDecode()
    assert decode.decode_data(
        logger=_LOGGER,
        raw_data=bytearray.fromhex(
            "6d00600c04000100008211ff00000000c04c20001f3560007006B80B0900"
        ),
    ) == {BATTERY: 3.0}


def test_wave_plus_sensor_data() -> None:
    """Test wave plus sensor data."""
    raw_data = bytearray.fromhex("01380d800b002200bd094cc31d036c0000007d05")

    decoded_data = _decode_wave_plus(name="Plus", format_type="<4B8H", scale=1.0)(
        raw_data
    )

    assert decoded_data["humidity"] == 28.0
    assert decoded_data["radon_1day_avg"] == 11
    assert decoded_data["radon_longterm_avg"] == 34
    assert decoded_data["temperature"] == 24.93
    assert decoded_data["voc"] == 108
    assert decoded_data["co2"] == 797
    assert decoded_data["illuminance"] == 5
    assert decoded_data["pressure"] == 999.92