コード例 #1
0
ファイル: test_conversion.py プロジェクト: daBONDi/pknx
    def test_float_to_knx(self):
        """Does the float to KNX conversion works correctly?"""

        # See
        # http://www.knx.org/fileadmin/template/documents/\
        # downloads_support_menu/KNX_tutor_seminar_page/\
        # Advanced_documentation/05_Interworking_E1209.pdf
        self.assertEquals(float_to_knx2(-30),
                          [0x8a, 0x24])  # example pg. 21/36

        self.assertEquals(float_to_knx2(0), [0x00, 0x00])
        self.assertEquals(float_to_knx2(0.01), [0x00, 0x01])
        self.assertEquals(float_to_knx2(1), [0x00, 0x64])
コード例 #2
0
    def test_float_to_knx(self):
        """Does the float to KNX conversion works correctly?"""

        # See
        # http://www.knx.org/fileadmin/template/documents/\
        # downloads_support_menu/KNX_tutor_seminar_page/\
        # Advanced_documentation/05_Interworking_E1209.pdf
        self.assertEquals(float_to_knx2(-30),
                          [0x8a, 0x24])  # example pg. 21/36

        self.assertEquals(float_to_knx2(0), [0x00, 0x00])
        self.assertEquals(float_to_knx2(0.01), [0x00, 0x01])
        self.assertEquals(float_to_knx2(1), [0x00, 0x64])
コード例 #3
0
    def set_temperature(self, **kwargs):
        """Set new target temperature."""
        temperature = kwargs.get(ATTR_TEMPERATURE)
        if temperature is None:
            return
        from knxip.conversion import float_to_knx2

        self.set_value('setpoint', float_to_knx2(temperature))
        _LOGGER.debug("Set target temperature to %s", temperature)
コード例 #4
0
ファイル: knx.py プロジェクト: Khabi/home-assistant
    def set_temperature(self, **kwargs):
        """Set new target temperature."""
        temperature = kwargs.get(ATTR_TEMPERATURE)
        if temperature is None:
            return
        from knxip.conversion import float_to_knx2

        self.set_value('setpoint', float_to_knx2(temperature))
        _LOGGER.debug("Set target temperature to %s", temperature)
コード例 #5
0
ファイル: knx.py プロジェクト: AZAZ78/weewx-knx
    def _handle_new_archive_record(self, event):
        record = event.record
        tunnel = self._knx_tunnel

        try:
            res = tunnel.connect()
            if not res:
                logerr(
                    'Could not connect to KNX/IP interface {0}, retry later'.
                    format(self._gateway_ip))
                return
        except KNXException as ex:
            logerr(
                'Exception during connect to KNX/IP interface {0}: {1}, retry later'
                .format(self._gateway_ip, ex))
            return

        try:
            for key, value in self._knx_map.items():
                data = record.get(key)
                if data is not None:
                    logdbg('Send {0} with data {1} to address {2}'.format(
                        key, data, value))
                    encoded_data = float_to_knx2(float(data))
                    tunnel.group_write(parse_group_address(value),
                                       encoded_data)
                else:
                    logerr(
                        'No value available for {0} and address {1}, nothing send'
                        .format(key, value))

        except KNXException as ex:
            logerr('KNXException raised : {0}'.format(ex))

        try:
            tunnel.disconnect()
        except KNXException as ex:
            logerr('KNXException raised : {0}'.format(ex))
コード例 #6
0
ファイル: knx.py プロジェクト: wgfreewill/home-assistant
    def set_temperature(self, temperature):
        """Set new target temperature."""
        from knxip.conversion import float_to_knx2

        self.set_value("setpoint", float_to_knx2(temperature))
        _LOGGER.debug("Set target temperature to %s", temperature)
コード例 #7
0
ファイル: knx.py プロジェクト: 12-hak/hak-assistant
    def set_temperature(self, temperature):
        """Set new target temperature."""
        from knxip.conversion import float_to_knx2

        self.set_value("setpoint", float_to_knx2(temperature))
        _LOGGER.debug("Set target temperature to %s", temperature)