コード例 #1
0
async def main():
    connection_config = ConnectionConfig(
        connection_type=ConnectionType.TUNNELING,
        gateway_ip="10.0.0.197",
        gateway_port=3671,
        local_ip="10.0.0.70")
    xknx = XKNX(connection_config=connection_config)
    await xknx.start()
    print(len(xknx.devices))
    for device in xknx.devices:
        print(device)
    print("Start done")

    light = Light(xknx,
                  name ='Lamp Pieter',
                  group_address_switch='0/2/18')
    print(light)
    await light.set_off()

    TempSensor = Sensor(xknx,
                        'TempSensor Bureel Pieter',
                        group_address_state='2/2/11',
                        value_type='temperature')
    await TempSensor.sync()
    print(TempSensor)
    print(TempSensor.resolve_state())
    print(TempSensor.unit_of_measurement())
    print(TempSensor.sensor_value.value)
    await xknx.stop()
コード例 #2
0
    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(), "%")
コード例 #3
0
    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")
コード例 #4
0
    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(), "%")
コード例 #5
0
ファイル: sensor_test.py プロジェクト: michelde/xknx
    def test_str_electric_potential(self):
        """Test resolve state with voltage sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(xknx,
                        'TestSensor',
                        group_address_state='1/2/3',
                        value_type="electric_potential")
        sensor.sensor_value.payload = DPTArray((0x43, 0x65, 0xE3, 0xD7))

        self.assertEqual(round(sensor.resolve_state(), 2), 229.89)
        self.assertEqual(sensor.unit_of_measurement(), "V")
コード例 #6
0
ファイル: sensor_test.py プロジェクト: Karssi/xknx
    def test_str_power(self):
        """Test resolve state with power sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(xknx,
                        'TestSensor',
                        group_address='1/2/3',
                        value_type="power")
        sensor.sensor_value.payload = DPTArray((0x43, 0xC6, 0x80, 00))

        self.assertEqual(sensor.resolve_state(), 397)
        self.assertEqual(sensor.unit_of_measurement(), "W")
コード例 #7
0
ファイル: sensor_test.py プロジェクト: rnixx/xknx
    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.sensor_value.payload = DPTArray((0x00, 0x1b,))

        self.assertEqual(sensor.resolve_state(), 0.27)
        self.assertEqual(sensor.unit_of_measurement(), "m/s")
コード例 #8
0
ファイル: sensor_test.py プロジェクト: michelde/xknx
    def test_str_scaling(self):
        """Test resolve state with percent sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(xknx,
                        'TestSensor',
                        group_address_state='1/2/3',
                        value_type="percent")
        sensor.sensor_value.payload = DPTArray((0x40, ))

        self.assertEqual(sensor.resolve_state(), 25)
        self.assertEqual(sensor.unit_of_measurement(), "%")
        self.assertEqual(sensor.ha_device_class(), None)
コード例 #9
0
ファイル: sensor_test.py プロジェクト: phbaer/xknx
    def test_str_electric_potential(self):
        """Test resolve state with voltage sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(
            xknx,
            'TestSensor',
            group_address_state='1/2/3',
            value_type="electric_potential")
        sensor.sensor_value.payload = DPTArray((0x43, 0x65, 0xE3, 0xD7))

        self.assertEqual(round(sensor.resolve_state(), 2), 229.89)
        self.assertEqual(sensor.unit_of_measurement(), "V")
コード例 #10
0
ファイル: sensor_test.py プロジェクト: phbaer/xknx
    def test_str_power(self):
        """Test resolve state with power sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(
            xknx,
            'TestSensor',
            group_address_state='1/2/3',
            value_type="power")
        sensor.sensor_value.payload = DPTArray((0x43, 0xC6, 0x80, 00))

        self.assertEqual(sensor.resolve_state(), 397)
        self.assertEqual(sensor.unit_of_measurement(), "W")
        self.assertEqual(sensor.ha_device_class(), "power")
コード例 #11
0
ファイル: sensor_test.py プロジェクト: phbaer/xknx
    def test_str_humidity(self):
        """Test resolve state with humidity sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(
            xknx,
            'TestSensor',
            group_address_state='1/2/3',
            value_type="humidity")
        sensor.sensor_value.payload = DPTArray((0x0e, 0x73))

        self.assertEqual(sensor.resolve_state(), 33.02)
        self.assertEqual(sensor.unit_of_measurement(), "%")
        self.assertEqual(sensor.ha_device_class(), "humidity")
コード例 #12
0
ファイル: sensor_test.py プロジェクト: phbaer/xknx
    def test_str_temp(self):
        """Test resolve state with temperature sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(
            xknx,
            'TestSensor',
            group_address_state='1/2/3',
            value_type="temperature")
        sensor.sensor_value.payload = DPTArray((0x0c, 0x1a))

        self.assertEqual(sensor.resolve_state(), 21.00)
        self.assertEqual(sensor.unit_of_measurement(), "°C")
        self.assertEqual(sensor.ha_device_class(), "temperature")
コード例 #13
0
ファイル: sensor_test.py プロジェクト: phbaer/xknx
    def test_str_speed_ms(self):
        """Test resolve state with speed_ms sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(
            xknx,
            'TestSensor',
            group_address_state='1/2/3',
            value_type="speed_ms")
        sensor.sensor_value.payload = DPTArray((0x00, 0x1b,))

        self.assertEqual(sensor.resolve_state(), 0.27)
        self.assertEqual(sensor.unit_of_measurement(), "m/s")
        self.assertEqual(sensor.ha_device_class(), None)
コード例 #14
0
ファイル: sensor_test.py プロジェクト: phbaer/xknx
    def test_str_scaling(self):
        """Test resolve state with percent sensor."""
        xknx = XKNX(loop=self.loop)
        sensor = Sensor(
            xknx,
            'TestSensor',
            group_address_state='1/2/3',
            value_type="percent")
        sensor.sensor_value.payload = DPTArray((0x40,))

        self.assertEqual(sensor.resolve_state(), 25)
        self.assertEqual(sensor.unit_of_measurement(), "%")
        self.assertEqual(sensor.ha_device_class(), None)