예제 #1
0
    def test_4byte_float_special_value(self):
        """Test parsing and streaming of DPT4ByteFloat special value."""
        assert math.isnan(DPT4ByteFloat.from_knx((0x7F, 0xC0, 0x00, 0x00)))
        assert DPT4ByteFloat.to_knx(float("nan")) == (0x7F, 0xC0, 0x00, 0x00)

        assert math.isinf(DPT4ByteFloat.from_knx((0x7F, 0x80, 0x00, 0x00)))
        assert DPT4ByteFloat.to_knx(float("inf")) == (0x7F, 0x80, 0x00, 0x00)

        assert DPT4ByteFloat.from_knx((0xFF, 0x80, 0x00, 0x00)) == float("-inf")
        assert DPT4ByteFloat.to_knx(float("-inf")) == (0xFF, 0x80, 0x00, 0x00)

        assert DPT4ByteFloat.from_knx((0x80, 0x00, 0x00, 0x00)) == float("-0")
        assert DPT4ByteFloat.to_knx(float("-0")) == (0x80, 0x00, 0x00, 0x00)
예제 #2
0
 def test_4byte_float_to_knx_wrong_parameter(self):
     """Test parsing of DPT4ByteFloat with wrong value (string)."""
     with pytest.raises(ConversionError):
         DPT4ByteFloat.to_knx("fnord")
예제 #3
0
 def test_4byte_float_zero_value(self):
     """Test parsing and streaming of DPT4ByteFloat zero value."""
     assert DPT4ByteFloat.from_knx((0x00, 0x00, 0x00, 0x00)) == 0.00
     assert DPT4ByteFloat.to_knx(0.00) == (0x00, 0x00, 0x00, 0x00)
예제 #4
0
 def test_4byte_float_values_from_voltage_meter(self):
     """Test parsing DPT4ByteFloat from voltage meter."""
     assert DPT4ByteFloat.from_knx((0x43, 0x65, 0xE3, 0xD7)) == 229.89
     assert DPT4ByteFloat.to_knx(229.89) == (0x43, 0x65, 0xE3, 0xD7)
예제 #5
0
 def test_14_057(self):
     """Test DPT4ByteFloat object."""
     assert DPT4ByteFloat.from_knx((0x3F, 0x71, 0xEB, 0x86)) == 0.9450001
     assert DPT4ByteFloat.to_knx(0.945000052452) == (0x3F, 0x71, 0xEB, 0x86)
     assert DPT4ByteFloat.unit == ""
예제 #6
0
 def test_14_055(self):
     """Test DPTPhaseAngleDeg object."""
     assert DPT4ByteFloat.from_knx((0x42, 0xEF, 0x00, 0x00)) == 119.5
     assert DPT4ByteFloat.to_knx(119.5) == (0x42, 0xEF, 0x00, 0x00)
     assert DPTPhaseAngleDeg.unit == "°"
예제 #7
0
 def test_4byte_float_values_from_power_meter(self):
     """Test parsing DPT4ByteFloat value from power meter."""
     assert DPT4ByteFloat.from_knx((0x43, 0xC6, 0x80, 00)) == 397
     assert DPT4ByteFloat.to_knx(397) == (0x43, 0xC6, 0x80, 00)
     assert DPT4ByteFloat.from_knx((0x42, 0x38, 0x00, 00)) == 46
     assert DPT4ByteFloat.to_knx(46) == (0x42, 0x38, 0x00, 00)