Exemple #1
0
    def test_str_temperature(self):
        """Test resolve state with temperature sensor."""
        xknx = XKNX()
        expose_sensor = ExposeSensor(
            xknx, "TestSensor", group_address="1/2/3", value_type="temperature"
        )
        expose_sensor.sensor_value.payload = DPTArray((0x0C, 0x1A))

        self.assertEqual(expose_sensor.resolve_state(), 21.0)
        self.assertEqual(expose_sensor.unit_of_measurement(), "°C")
Exemple #2
0
    def test_str_percent(self):
        """Test resolve state with percent sensor."""
        xknx = XKNX()
        expose_sensor = ExposeSensor(
            xknx, "TestSensor", group_address="1/2/3", value_type="percent"
        )
        expose_sensor.sensor_value.payload = DPTArray((0x40,))

        self.assertEqual(expose_sensor.resolve_state(), 25)
        self.assertEqual(expose_sensor.unit_of_measurement(), "%")
Exemple #3
0
    def test_str_binary(self):
        """Test resolve state with binary sensor."""
        xknx = XKNX()
        expose_sensor = ExposeSensor(
            xknx, "TestSensor", group_address="1/2/3", value_type="binary"
        )
        expose_sensor.sensor_value.payload = DPTBinary(1)

        self.assertEqual(expose_sensor.resolve_state(), True)
        self.assertEqual(expose_sensor.unit_of_measurement(), None)
Exemple #4
0
    def test_str_temperature(self):
        """Test resolve state with temperature sensor."""
        xknx = XKNX(loop=self.loop)
        expose_sensor = ExposeSensor(
            xknx,
            'TestSensor',
            group_address='1/2/3',
            value_type="temperature")
        expose_sensor.sensor_value.payload = DPTArray((0x0c, 0x1a))

        self.assertEqual(expose_sensor.resolve_state(), 21.0)
        self.assertEqual(expose_sensor.unit_of_measurement(), "°C")
Exemple #5
0
    def test_str_percent(self):
        """Test resolve state with percent sensor."""
        xknx = XKNX(loop=self.loop)
        expose_sensor = ExposeSensor(
            xknx,
            'TestSensor',
            group_address='1/2/3',
            value_type="percent")
        expose_sensor.sensor_value.payload = DPTArray((0x40,))

        self.assertEqual(expose_sensor.resolve_state(), 25)
        self.assertEqual(expose_sensor.unit_of_measurement(), "%")
Exemple #6
0
    def test_str_binary(self):
        """Test resolve state with binary sensor."""
        xknx = XKNX(loop=self.loop)
        expose_sensor = ExposeSensor(
            xknx,
            'TestSensor',
            group_address='1/2/3',
            value_type="binary")
        expose_sensor.sensor_value.payload = DPTBinary(1)

        self.assertEqual(expose_sensor.resolve_state(), True)
        self.assertEqual(expose_sensor.unit_of_measurement(), None)
    async def test_str_binary(self):
        """Test resolve state with binary sensor."""
        xknx = XKNX()
        expose_sensor = ExposeSensor(xknx,
                                     "TestSensor",
                                     group_address="1/2/3",
                                     value_type="binary")
        await expose_sensor.process(
            Telegram(
                destination_address=GroupAddress("1/2/3"),
                payload=GroupValueWrite(value=DPTBinary(1)),
            ))

        assert expose_sensor.resolve_state() is True
        assert expose_sensor.unit_of_measurement() is None
    async def test_str_temperature(self):
        """Test resolve state with temperature sensor."""
        xknx = XKNX()
        expose_sensor = ExposeSensor(xknx,
                                     "TestSensor",
                                     group_address="1/2/3",
                                     value_type="temperature")

        await expose_sensor.process(
            Telegram(
                destination_address=GroupAddress("1/2/3"),
                payload=GroupValueWrite(DPTArray((0x0C, 0x1A))),
            ))

        assert expose_sensor.resolve_state() == 21.0
        assert expose_sensor.unit_of_measurement() == "°C"