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])
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)
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))
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)