def test_str_humidity(self): """Test resolve state with humidity sensor.""" xknx = XKNX(loop=self.loop) sensor = Sensor(xknx, 'TestSensor', group_address='1/2/3', value_type="humidity") sensor.state = DPTArray((0x0e, 0x73)) self.assertEqual(sensor.resolve_state(), 33.02) self.assertEqual(sensor.unit_of_measurement(), "%")
def test_str_temp(self): """Test resolve state with temperature sensor.""" xknx = XKNX(loop=self.loop) sensor = Sensor(xknx, 'TestSensor', group_address='1/2/3', value_type="temperature") sensor.state = DPTArray((0x0c, 0x1a)) self.assertEqual(sensor.resolve_state(), 21.00) self.assertEqual(sensor.unit_of_measurement(), "°C")
def test_str_scaling(self): """Test resolve state with percent sensor.""" xknx = XKNX(loop=self.loop) sensor = Sensor(xknx, 'TestSensor', group_address='1/2/3', value_type="percent") sensor.state = DPTArray((0x40, )) self.assertEqual(sensor.resolve_state(), "25") self.assertEqual(sensor.unit_of_measurement(), "%")
def test_str_speed_ms(self): """Test resolve state with speed_ms sensor.""" xknx = XKNX(loop=self.loop) sensor = Sensor(xknx, 'TestSensor', group_address='1/2/3', value_type="speed_ms") sensor.state = DPTArray(( 0x00, 0x1b, )) self.assertEqual(sensor.resolve_state(), 0.27) self.assertEqual(sensor.unit_of_measurement(), "m/s")
def test_str_binary(self): """Test resolve_state fallback method with integer object.""" xknx = XKNX(loop=self.loop) sensor = Sensor(xknx, 'TestSensor', group_address='1/2/3') sensor.state = DPTBinary(5) self.assertEqual(sensor.resolve_state(), "101")
def test_str_array(self): """Test resolve_state fallback method with DPTArray.""" xknx = XKNX(loop=self.loop) sensor = Sensor(xknx, 'TestSensor', group_address='1/2/3') sensor.state = DPTArray((0x01, 0x02, 0x03)) self.assertEqual(sensor.resolve_state(), "0x01,0x02,0x03")