Skip to content

Commit 9c85fc1

Browse files
pkolbusjeeftor
authored andcommitted
Tolerate more missing fields
The pressure_trend and precip_accum_local_yesterday_final have also been omitted from the summary in Tempest observations from new devices. Treat these as optional and update the test.
1 parent 7272156 commit 9c85fc1

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

tests/fixtures/ws/websocket_messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
{"device_id":211522,"type":"obs_st","obs":[[1709130791,0.0,0.0,0.0,0.0,3.0,793.3,-9.4,92.0,7875.0,0.28,66.0,0.0,0.0,0.0,0.0,2.62,1.0,0.0,0.0,0.0,0.0]],"summary":{"pressure_trend":"rising","strike_count_1h":0,"strike_count_3h":0,"precip_total_1h":0.0,"strike_last_dist":26,"strike_last_epoch":1707346875,"precip_accum_local_yesterday":0.478541,"precip_accum_local_yesterday_final":1.126487,"precip_analysis_type_yesterday":1,"feels_like":-9.4,"heat_index":-9.4,"wind_chill":-9.4,"dew_point":-10.5,"wet_bulb_temperature":-9.7,"wet_bulb_globe_temperature":-9.2,"air_density":1.04779,"delta_t":0.3,"precip_minutes_local_day":0,"precip_minutes_local_yesterday":22},"source":"mqtt","serial_number":"ST-00084623","hub_sn":"HB-00068684","firmware_revision":172},
66
{"device_id":211522,"type":"obs_st","obs":[[1709130911,0.0,0.32,1.31,254.0,3.0,793.3,-9.4,92.0,9792.0,0.34,81.0,0.0,0.0,0.0,0.0,2.62,1.0,0.0,0.0,0.0,0.0]],"summary":{"pressure_trend":"rising","strike_count_1h":0,"strike_count_3h":0,"precip_total_1h":0.0,"strike_last_dist":26,"strike_last_epoch":1707346875,"precip_accum_local_yesterday":0.478541,"precip_accum_local_yesterday_final":1.126487,"precip_analysis_type_yesterday":1,"feels_like":-9.4,"heat_index":-9.4,"wind_chill":-9.4,"dew_point":-10.5,"wet_bulb_temperature":-9.7,"wet_bulb_globe_temperature":-9.1,"air_density":1.04779,"delta_t":0.3,"precip_minutes_local_day":0,"precip_minutes_local_yesterday":22},"source":"mqtt","serial_number":"ST-00084623","hub_sn":"HB-00068684","firmware_revision":172},
77
{"device_id":211522,"type":"obs_st","obs":[[1709132533,0.0,0.3,0.95,333.0,3.0,793.5,-8.8,89.0,37408.0,1.31,312.0,0.0,0.0,0.0,0.0,2.71,1.0,0.0,0.0,0.0,0.0]],"summary":{"pressure_trend":"rising","strike_count_1h":0,"strike_count_3h":0,"precip_total_1h":0.0,"strike_last_dist":26,"strike_last_epoch":1707346875,"precip_accum_local_yesterday":0.478541,"precip_accum_local_yesterday_final":1.126487,"precip_analysis_type_yesterday":1,"feels_like":-8.8,"heat_index":-8.8,"wind_chill":-8.8,"dew_point":-10.3,"wet_bulb_temperature":-9.3,"wet_bulb_globe_temperature":-7.2,"air_density":1.04568,"delta_t":0.5,"precip_minutes_local_day":0,"precip_minutes_local_yesterday":22},"source":"mqtt","serial_number":"ST-00084623","hub_sn":"HB-00068684","firmware_revision":172},
8-
{"device_id":211522,"type":"obs_st","obs":[[1709132533,0.0,0.3,0.95,333.0,3.0,793.5,-8.8,89.0,37408.0,1.31,312.0,0.0,0.0,0.0,0.0,2.71,1.0,0.0,0.0,0.0,0.0]],"summary":{"pressure_trend":"rising","strike_count_1h":0,"strike_count_3h":0,"precip_total_1h":0.0,"precip_accum_local_yesterday":0.478541,"precip_accum_local_yesterday_final":1.126487,"precip_analysis_type_yesterday":1,"feels_like":-8.8,"heat_index":-8.8,"wind_chill":-8.8,"dew_point":-10.3,"wet_bulb_temperature":-9.3,"wet_bulb_globe_temperature":-7.2,"air_density":1.04568,"delta_t":0.5,"precip_minutes_local_day":0,"precip_minutes_local_yesterday":22},"source":"mqtt","serial_number":"ST-00084623","hub_sn":"HB-00068684","firmware_revision":172},
8+
{"device_id":211522,"type":"obs_st","obs":[[1709132533,0.0,0.3,0.95,333.0,3.0,793.5,-8.8,89.0,37408.0,1.31,312.0,0.0,0.0,0.0,0.0,2.71,1.0,0.0,0.0,0.0,0.0]],"summary":{"strike_count_1h":0,"strike_count_3h":0,"precip_total_1h":0.0,"precip_accum_local_yesterday":0.478541,"precip_analysis_type_yesterday":1,"feels_like":-8.8,"heat_index":-8.8,"wind_chill":-8.8,"dew_point":-10.3,"wet_bulb_temperature":-9.3,"wet_bulb_globe_temperature":-7.2,"air_density":1.04568,"delta_t":0.5,"precip_minutes_local_day":0,"precip_minutes_local_yesterday":22},"source":"mqtt","serial_number":"ST-00084623","hub_sn":"HB-00068684","firmware_revision":172},
99
{"serial_number": "ST-00081234", "type": "evt_strike", "hub_sn": "HB-00061234", "evt": [1710383159, 13, -182, 1], "source": "enhanced", "device_id": 392412}
1010
]

tests/test_ws.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def test_websocket_messages(websocket_messages):
5555

5656
assert msg6.summary.strike_last_dist == None
5757
assert msg6.summary.strike_last_epoch == None
58+
assert msg6.summary.pressure_trend == None
59+
assert msg6.summary.precip_accum_local_yesterday_final == None
5860

5961
def test_winds(websocket_winds):
6062
for msg in websocket_winds:

weatherflow4py/models/rest/device.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
@dataclass_json
2121
@dataclass
2222
class Summary:
23-
pressure_trend: str
2423
strike_count_1h: int
2524
strike_count_3h: int
2625
precip_total_1h: float
2726
precip_accum_local_yesterday: float
28-
precip_accum_local_yesterday_final: float
2927
precip_analysis_type_yesterday: PrecipitationAnalysisType
3028
feels_like: float
3129
heat_index: float
3230
wind_chill: float
31+
pressure_trend: Optional[str] = None
32+
precip_accum_local_yesterday_final: Optional[float] = None
3333
strike_last_dist: Optional[int] = None
3434
strike_last_epoch: Optional[int] = None
3535

0 commit comments

Comments
 (0)