diff --git a/tests/data/test_data_processing.py b/tests/data/test_data_processing.py index c0e2ed27..d1f7b4ae 100644 --- a/tests/data/test_data_processing.py +++ b/tests/data/test_data_processing.py @@ -35,6 +35,7 @@ from ecowitt2mqtt.helpers.calculator import CalculatedDataPoint, DataPointType from ecowitt2mqtt.helpers.calculator.battery import BooleanBatteryState from ecowitt2mqtt.helpers.calculator.leak import LeakState +from ecowitt2mqtt.helpers.calculator.rainstate import RainState from ecowitt2mqtt.helpers.calculator.temperature import ( FrostRisk, HumidexPerception, @@ -2972,6 +2973,370 @@ def test_precision(device_data: dict[str, Any], ecowitt: Ecowitt) -> None: ), }, ), + ( + "payload_gw2000a_3.json", + { + "ws90_ver": CalculatedDataPoint( + data_point_key="ws90_ver", + value=147.0, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "runtime": CalculatedDataPoint( + "runtime", + 1574073.0, + unit=UnitOfTime.SECONDS, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "tempin": CalculatedDataPoint( + "temp", + 71.78, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "humidityin": CalculatedDataPoint( + "humidity", + 59.0, + unit=PERCENTAGE, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "baromrel": CalculatedDataPoint( + "barom", + 30.035, + unit=UnitOfPressure.INHG, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "baromabs": CalculatedDataPoint( + "barom", + 29.394, + unit=UnitOfPressure.INHG, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "temp": CalculatedDataPoint( + "temp", + 51.44, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "humidity": CalculatedDataPoint( + "humidity", + 76.0, + unit=PERCENTAGE, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "winddir": CalculatedDataPoint( + "winddir", + 181.0, + unit=DEGREE, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "windspeed": CalculatedDataPoint( + "wind", + 1.79, + unit=UnitOfSpeed.MILES_PER_HOUR, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "windgust": CalculatedDataPoint( + "gust", + 4.25, + unit=UnitOfSpeed.MILES_PER_HOUR, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "maxdailygust": CalculatedDataPoint( + "gust", + 12.75, + unit=UnitOfSpeed.MILES_PER_HOUR, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "solarradiation": CalculatedDataPoint( + "solarradiation", + 0.00, + unit=UnitOfIlluminance.WATTS_PER_SQUARE_METER, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "solarradiation_perceived": CalculatedDataPoint( + "solarradiation_perceived", + 0.0, + unit=PERCENTAGE, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "uv": CalculatedDataPoint( + "uv", + 0.0, + unit=UV_INDEX, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "safe_exposure_time_skin_type_1": CalculatedDataPoint( + "safe_exposure_time_skin_type_1", + None, + unit=UnitOfTime.MINUTES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "safe_exposure_time_skin_type_2": CalculatedDataPoint( + "safe_exposure_time_skin_type_2", + None, + unit=UnitOfTime.MINUTES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "safe_exposure_time_skin_type_3": CalculatedDataPoint( + "safe_exposure_time_skin_type_3", + None, + unit=UnitOfTime.MINUTES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "safe_exposure_time_skin_type_4": CalculatedDataPoint( + "safe_exposure_time_skin_type_4", + None, + unit=UnitOfTime.MINUTES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "safe_exposure_time_skin_type_5": CalculatedDataPoint( + "safe_exposure_time_skin_type_5", + None, + unit=UnitOfTime.MINUTES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "safe_exposure_time_skin_type_6": CalculatedDataPoint( + "safe_exposure_time_skin_type_6", + None, + unit=UnitOfTime.MINUTES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "rrain_piezo": CalculatedDataPoint( + "rrain_piezo", + 0.000, + unit=UnitOfPrecipitationRate.INCHES_PER_HOUR, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "erain_piezo": CalculatedDataPoint( + "rain_piezo", + 0.000, + unit=UnitOfAccumulatedPrecipitation.INCHES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "hrain_piezo": CalculatedDataPoint( + "rain_piezo", + 0.000, + unit=UnitOfAccumulatedPrecipitation.INCHES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "drain_piezo": CalculatedDataPoint( + "rain_piezo", + 0.000, + unit=UnitOfAccumulatedPrecipitation.INCHES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "wrain_piezo": CalculatedDataPoint( + "rain_piezo", + 0.181, + unit=UnitOfAccumulatedPrecipitation.INCHES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "mrain_piezo": CalculatedDataPoint( + "rain_piezo", + 0.094, + unit=UnitOfAccumulatedPrecipitation.INCHES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "yrain_piezo": CalculatedDataPoint( + "rain_piezo", + 23.264, + unit=UnitOfAccumulatedPrecipitation.INCHES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "srain_piezo": CalculatedDataPoint( + "rain_piezo", + RainState.OFF, + unit=None, + attributes={}, + data_type=DataPointType.BOOLEAN, + ), + "ws90cap_volt": CalculatedDataPoint( + "volt", + 5.0, + unit=UnitOfElectricPotential.VOLT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "wh90batt": CalculatedDataPoint( + "batt", + 3.04, + unit=UnitOfElectricPotential.VOLT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "dewpoint": CalculatedDataPoint( + "dewpoint", + 44.138051751285005, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "feelslike": CalculatedDataPoint( + "feelslike", + 51.44, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "heatindex": CalculatedDataPoint( + "heatindex", + 49.856, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "windchill": CalculatedDataPoint( + "windchill", + None, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "humidityabs": CalculatedDataPoint( + data_point_key="humidityabs", + value=0.00046879579655827896, + unit=UnitOfVolume.POUNDS_PER_CUBIC_FOOT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "humidityabsin": CalculatedDataPoint( + data_point_key="humidityabsin", + value=0.0007189508337053066, + unit=UnitOfVolume.POUNDS_PER_CUBIC_FOOT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "thermalperception": CalculatedDataPoint( + data_point_key="thermalperception", + value=ThermalPerception.DRY, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "frostpoint": CalculatedDataPoint( + data_point_key="frostpoint", + value=41.677551623349345, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "frostrisk": CalculatedDataPoint( + data_point_key="frostrisk", + value=FrostRisk.NO_RISK, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "simmerindex": CalculatedDataPoint( + data_point_key="simmerindex", + value=None, + unit=UnitOfTemperature.FAHRENHEIT, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "simmerzone": CalculatedDataPoint( + data_point_key="simmerzone", + value=None, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "beaufortscale": CalculatedDataPoint( + data_point_key="beaufortscale", + value=1, + unit=None, + attributes={ + "description": "Light air", + "sea_conditions": ( + "Ripples with appearance of scales are formed, without " + "foam crests" + ), + "land_conditions": ( + "Direction shown by smoke drift but not by wind vanes" + ), + }, + data_type=DataPointType.NON_BOOLEAN, + ), + "humidex": CalculatedDataPoint( + data_point_key="humidex", + value=11, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "humidex_perception": CalculatedDataPoint( + data_point_key="humidex_perception", + value=HumidexPerception.COMFORTABLE, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "relative_strain_index": CalculatedDataPoint( + data_point_key="relative_strain_index", + value=None, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "relative_strain_index_perception": CalculatedDataPoint( + data_point_key="relative_strain_index_perception", + value=None, + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "heap": CalculatedDataPoint( + data_point_key="heap", + value=156456.0, + unit=UnitOfMemory.BYTES, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "winddir_name": CalculatedDataPoint( + data_point_key="winddir_name", + value="S", + unit=None, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + "interval": CalculatedDataPoint( + data_point_key="interval", + value=16.0, + unit=UnitOfTime.SECONDS, + attributes={}, + data_type=DataPointType.NON_BOOLEAN, + ), + }, + ), ( "payload_gw2000a_2.json", { diff --git a/tests/fixtures/payload_gw2000a_3.json b/tests/fixtures/payload_gw2000a_3.json new file mode 100644 index 00000000..7c7fcf4c --- /dev/null +++ b/tests/fixtures/payload_gw2000a_3.json @@ -0,0 +1,33 @@ +{ + "PASSKEY": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "stationtype": "GW2000A_V3.1.5", + "runtime": "1574073", + "heap": "156456", + "dateutc": "2024-10-03 19:42:19", + "tempinf": "71.78", + "humidityin": "59", + "baromrelin": "30.035", + "baromabsin": "29.394", + "tempf": "51.44", + "humidity": "76", + "winddir": "181", + "windspeedmph": "1.79", + "windgustmph": "4.25", + "maxdailygust": "12.75", + "solarradiation": "0.00", + "uv": "0", + "rrain_piezo": "0.000", + "erain_piezo": "0.000", + "hrain_piezo": "0.000", + "drain_piezo": "0.000", + "wrain_piezo": "0.181", + "mrain_piezo": "0.094", + "yrain_piezo": "23.264", + "ws90cap_volt": "5.0", + "ws90_ver": "147", + "srain_piezo": "0", + "wh90batt": "3.04", + "freq": "868M", + "model": "GW2000A", + "interval": "16" +}