Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pynmea2/types/talker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,4 +1130,13 @@ class MMB(TalkerSentence):
("UnitINHG", "unit_ingh"),
("PressureBars", "pressure_bars", float),
("UnitBars", "unit_bars")
)
)

class MHU(TalkerSentence):
"""Relative humidity."""
fields = (
('Relative Humidity', 'relative_humidity', Decimal),
('Absolute Humidity', 'absolute_humidity', Decimal),
('Dew Point Temperature', 'dew_point_temperature', Decimal),
('Temperature Unit', 'temperature_unit', str),
)
35 changes: 34 additions & 1 deletion test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,37 @@ def test_MMB():
assert msg.talker == 'WI'
assert msg.sentence_type == 'MMB'
assert msg.pressure_bars == 1004.6
assert msg.unit_bars == "B"
assert msg.unit_bars == "B"

def test_MHU():
data = "$WIMHU,83.8,,,*53"
msg = pynmea2.parse(data)
assert msg.render() == data
assert msg.talker == 'WI'
assert msg.sentence_type == 'MHU'
assert msg.relative_humidity == Decimal('83.8')
assert msg.absolute_humidity is None
assert msg.dew_point_temperature is None
assert msg.temperature_unit is None

def test_MHU_all_fields():
data = "$WIMHU,83.8,12.5,25.5,C*14"
msg = pynmea2.parse(data)
assert msg.render() == data
assert msg.talker == 'WI'
assert msg.sentence_type == 'MHU'
assert msg.relative_humidity == Decimal('83.8')
assert msg.absolute_humidity == Decimal('12.5')
assert msg.dew_point_temperature == Decimal('25.5')
assert msg.temperature_unit == 'C'

def test_MHU_other_talker():
data = "$HCMHU,55.2,10.1,14.3,C*02"
msg = pynmea2.parse(data)
assert msg.render() == data
assert msg.talker == 'HC'
assert msg.sentence_type == 'MHU'
assert msg.relative_humidity == Decimal('55.2')
assert msg.absolute_humidity == Decimal('10.1')
assert msg.dew_point_temperature == Decimal('14.3')
assert msg.temperature_unit == 'C'
Loading