Ejemplo n.º 1
0
def main():
     global arguments
     error=None
     configfile="./etc/config/ht_proxy_cfg.xml"
     try:
          client= ht_proxy_if.cht_socket_client(configfile, devicetype=ht_proxy_if.DT_MODEM)
     except:
          print("couldn't connect to server")
          raise

     trx=ht_transceiver.ctransceiver(client)
     cfg=ht_yanetcom.cyanetcom(client)
     
     if arguments['temp'] != 10.0:
          error=cfg.set_tempniveau(arguments['temp'])
          if error != None:
               print("{0}".format(error)) 

     if arguments['bart'] != 'none':
          error=cfg.set_betriebsart(arguments['bart'])
          if error != None:
               print("{0}".format(error))

     if arguments['cfg'] != 10:
          error=trx.cfg_mode(arguments['cfg'])
          if error != None:
               print("{0}".format(error))

     if arguments['adr'] != 0:
          error=trx.cfg_deviceaddress(arguments['adr'])
          if error != None:
               print("{0}".format(error))
     
     if arguments['rst'] != 0:
          error=trx.reset()
          if error != None:
               print("{0}".format(error))
Ejemplo n.º 2
0
def main(configfile, ems_bus):
    global arguments
    error = None
    heater_circuit = 1
    temp_mode = ht_const.HT_TEMPNIVEAU_NORMAL
    
    try:
        client= ht_proxy_if.cht_socket_client(configfile, devicetype = ht_proxy_if.DT_MODEM)
    except:
        print("couldn't connect to server")
        raise

    trx = ht_transceiver.ctransceiver(client)
    cfg = ht_yanetcom.cyanetcom(client, ems_bus)
     
    if ems_bus == False:
        if arguments['hcircuit'] != 1:
            heater_circuit = arguments['hcircuit']

        if arguments['tempmod'] != ht_const.HT_TEMPNIVEAU_DUMMY:
            temp_mode = arguments['tempmod']
        else:
            temp_mode = ht_const.HT_TEMPNIVEAU_NORMAL

        if arguments['temp'] != 4.0:
            error = cfg.set_tempniveau(arguments['temp'], hcircuit_nr = heater_circuit, temperatur_mode = temp_mode)
            if error != None:
                print("{0}".format(error)) 
                
        if arguments['bart'] != 'none':
            error = cfg.set_betriebsart(arguments['bart'])
            if error != None:
                print("{0}".format(error))
    else:
        if arguments['temp'] != 4.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error)) 
            time.sleep(1)
            # second setup temperatur (temporary)
            error = cfg.set_tempniveau(arguments['temp'], temperatur_mode = ht_const.EMS_TEMP_MODE_TEMPORARY)
            if error != None:
                print("{0}".format(error)) 

        if arguments['tempc1'] != 11.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error)) 
            time.sleep(1)
            # second setup temperatur (comfort1)
            error=cfg.set_tempniveau(arguments['tempc1'], temperatur_mode = ht_const.EMS_TEMP_MODE_COMFORT1)
            if error != None:
                print("{0}".format(error)) 

        if arguments['tempc2'] != 12.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error)) 
            time.sleep(1)
            # second setup temperatur (comfort2)
            error=cfg.set_tempniveau(arguments['tempc2'], temperatur_mode = ht_const.EMS_TEMP_MODE_COMFORT2)
            if error != None:
                print("{0}".format(error)) 

        if arguments['tempc3'] != 13.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error)) 
            time.sleep(1)
            # second setup temperatur (comfort3)
            error=cfg.set_tempniveau(arguments['tempc3'], temperatur_mode = ht_const.EMS_TEMP_MODE_COMFORT3)
            if error != None:
                print("{0}".format(error)) 

        if arguments['tempeco'] != 14.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error)) 
            time.sleep(1)
            # second setup temperatur (eco)
            error=cfg.set_tempniveau(arguments['tempeco'], temperatur_mode = ht_const.EMS_TEMP_MODE_ECO)
            if error != None:
                print("{0}".format(error)) 

        if arguments['tempman'] != 15.0:
            # first setup to manual-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_MANUAL)
            if error != None:
                print("{0}".format(error)) 
            time.sleep(1)
            # second setup temperatur (manual)
            error=cfg.set_tempniveau(arguments['tempman'], temperatur_mode = ht_const.EMS_TEMP_MODE_MANUAL)
            if error != None:
                print("{0}".format(error))

        if arguments['ecomode'] != -1:
            error=cfg.set_ecomode(arguments['ecomode'])
            if error != None:
                print("{0}".format(error))

        if arguments['bart'] != 'none':
            if  str(arguments['bart']).lower() in ('manual','man','m'):
                omode = ht_const.EMS_OMODE_MANUAL
            else:
                omode = ht_const.EMS_OMODE_AUTO
            error=cfg.set_operation_mode(omode)
            if error != None:
                print("{0}".format(error))
                
    if arguments['adr'] != 0:
        error=trx.cfg_deviceaddress(arguments['adr'])
        if error != None:
            print("{0}".format(error))
     
    if arguments['rst'] != 0:
        error=trx.reset()
        if error != None:
            print("{0}".format(error))
Ejemplo n.º 3
0
def main(configfile, ems_bus):
    global arguments
    error = None
    heater_circuit = 1
    temp_mode = ht_const.HT_TEMPNIVEAU_NORMAL

    try:
        client = ht_proxy_if.cht_socket_client(configfile,
                                               devicetype=ht_proxy_if.DT_MODEM)
    except:
        print("couldn't connect to server")
        raise

    trx = ht_transceiver.ctransceiver(client)
    cfg = ht_yanetcom.cyanetcom(client, ems_bus)

    if ems_bus == False:
        if arguments['hcircuit'] != 1:
            heater_circuit = arguments['hcircuit']

        if arguments['tempmod'] != ht_const.HT_TEMPNIVEAU_DUMMY:
            temp_mode = arguments['tempmod']
        else:
            temp_mode = ht_const.HT_TEMPNIVEAU_NORMAL

        if arguments['temp'] != 4.0:
            error = cfg.set_tempniveau(arguments['temp'],
                                       hcircuit_nr=heater_circuit,
                                       temperatur_mode=temp_mode)
            if error != None:
                print("{0}".format(error))

        if arguments['bart'] != 'none':
            error = cfg.set_betriebsart(arguments['bart'])
            if error != None:
                print("{0}".format(error))
    else:
        if arguments['temp'] != 4.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error))
            time.sleep(1)
            # second setup temperatur (temporary)
            error = cfg.set_tempniveau(
                arguments['temp'],
                temperatur_mode=ht_const.EMS_TEMP_MODE_TEMPORARY)
            if error != None:
                print("{0}".format(error))

        if arguments['tempc1'] != 11.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error))
            time.sleep(1)
            # second setup temperatur (comfort1)
            error = cfg.set_tempniveau(
                arguments['tempc1'],
                temperatur_mode=ht_const.EMS_TEMP_MODE_COMFORT1)
            if error != None:
                print("{0}".format(error))

        if arguments['tempc2'] != 12.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error))
            time.sleep(1)
            # second setup temperatur (comfort2)
            error = cfg.set_tempniveau(
                arguments['tempc2'],
                temperatur_mode=ht_const.EMS_TEMP_MODE_COMFORT2)
            if error != None:
                print("{0}".format(error))

        if arguments['tempc3'] != 13.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error))
            time.sleep(1)
            # second setup temperatur (comfort3)
            error = cfg.set_tempniveau(
                arguments['tempc3'],
                temperatur_mode=ht_const.EMS_TEMP_MODE_COMFORT3)
            if error != None:
                print("{0}".format(error))

        if arguments['tempeco'] != 14.0:
            # first setup to auto-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_AUTO)
            if error != None:
                print("{0}".format(error))
            time.sleep(1)
            # second setup temperatur (eco)
            error = cfg.set_tempniveau(
                arguments['tempeco'],
                temperatur_mode=ht_const.EMS_TEMP_MODE_ECO)
            if error != None:
                print("{0}".format(error))

        if arguments['tempman'] != 15.0:
            # first setup to manual-mode
            error = cfg.set_operation_mode(ht_const.EMS_OMODE_MANUAL)
            if error != None:
                print("{0}".format(error))
            time.sleep(1)
            # second setup temperatur (manual)
            error = cfg.set_tempniveau(
                arguments['tempman'],
                temperatur_mode=ht_const.EMS_TEMP_MODE_MANUAL)
            if error != None:
                print("{0}".format(error))

        if arguments['ecomode'] != -1:
            error = cfg.set_ecomode(arguments['ecomode'])
            if error != None:
                print("{0}".format(error))

        if arguments['bart'] != 'none':
            if str(arguments['bart']).lower() in ('manual', 'man', 'm'):
                omode = ht_const.EMS_OMODE_MANUAL
            else:
                omode = ht_const.EMS_OMODE_AUTO
            error = cfg.set_operation_mode(omode)
            if error != None:
                print("{0}".format(error))

    if arguments['adr'] != 0:
        error = trx.cfg_deviceaddress(arguments['adr'])
        if error != None:
            print("{0}".format(error))

    if arguments['rst'] != 0:
        error = trx.reset()
        if error != None:
            print("{0}".format(error))
Ejemplo n.º 4
0
    def run(self):
        """ """
        import ht_yanetcom
        ems_bus = False
        self.__ht_if_tx_data = ht_yanetcom.cyanetcom(self.__port, ems_bus)

        while self.__thread_run:
            # set default values
            execute_command = True
            command_name = ""
            self.__splitted_rx_param = []
            self.__param_count = 0

            try:
                # wait for queue-message
                (access_name, value) = self.__tx_queue.get()
            except:
                errorstr = "cht_if_tx_data.run();Error; on ht_if.__tx_queue.get()"
                self.__logging.critical(errorstr)
                raise

            if (access_name, value) == (None, None):
                self.stop()
                break

            # got message, split up content
            if value != None:
                self.__splitted_rx_param = value.split(',')
            else:
                self.__splitted_rx_param = ""
            debugstr = "cht_if_tx_data; access_name:{0}; value:{1}".format(access_name, self.__splitted_rx_param)
            self.__logging.debug(debugstr)

            # extract detailed parameters from configuration-context.
            if access_name in self.__ht_if_allowed_cmds.keys():
                allowed_parameter = self.__ht_if_allowed_cmds[access_name]

                # only parameter not None and length > 0 are processed
                if allowed_parameter != None and len(self.__splitted_rx_param) > 0:
                    # extract: 1. parameter := command-name
                    command_name = self.__ht_if_allowed_cmds[access_name][0]

                    # extract: 2. parameter := parameter count (int)
                    indexed_value = self.__ht_if_allowed_cmds[access_name][1]
                    self.__param_count = indexed_value
                    if type(indexed_value) == str:
                        self.__param_count = ord(indexed_value) - ord('0')

                    if self.__param_count > 1:
                        # extract: 3. parameter := heater circuit-number
                        indexed_value = self.__ht_if_allowed_cmds[access_name][2]
                        self.__heater_circuit = int(indexed_value)
                        if self.__heater_circuit > 0 and self.__heater_circuit < 5:
                            execute_command = True
                        else:
                            self.__heater_circuit = 1
                            execute_command = False

                        # extract: 4-n. parameter := special values depending on current command
                        # extract parameter for tdesired
                        if command_name.lower() in 'tdesired':
                            if self.__param_count == 3:
                                indexed_value = self.__ht_if_allowed_cmds[access_name][3]
                                if indexed_value == 'T':
                                    if len(self.__splitted_rx_param) > 1:
                                        # get temperatur-value from rx-message
                                        self.__tempera_desired = float(self.__splitted_rx_param[0])
                                        # get niveau-value from rx-message
                                        tempera_niveau = self.__splitted_rx_param[1].lower()
                                        allowed_niveaus = self.__ht_if_allowed_cmds[access_name][4]
                                        if tempera_niveau in allowed_niveaus:
                                            self.__niveau_desired = tempera_niveau
                                            execute_command = True
                                        else:
                                            # error no valid parameter received
                                            execute_command = False
                                            errorstr = "cht_if_tx_data;error; cmd:{0}; parameter:{1} wrong".format(command_name, tempera_niveau)
                                            self.__logging.warning(errorstr)
                                    else:
                                        # error no valid parameter received
                                        execute_command = False
                                        errorstr = "cht_if_tx_data;error; cmd:{0}; parameter:{1} wrong".format(command_name, self.__splitted_rx_param)
                                        self.__logging.warning(errorstr)
                            else:
                                # error no valid parameter
                                execute_command = False
                                errorstr = "cht_if_tx_data;error; cmd:{0}; amount of parameter:{1} wrong".format(command_name, self.__param_count)
                                self.__logging.warning(errorstr)
                        ########## end of: 'tdesired'

                        # extract parameter for tniveau
                        if command_name.lower() in 'tniveau':
                            if self.__param_count == 2:
                                indexed_value = self.__ht_if_allowed_cmds[access_name][3]
                                if len(self.__splitted_rx_param) > 0:
                                    if self.__splitted_rx_param[0].lower() in indexed_value:
                                        self.__tempera_niveau = self.__splitted_rx_param[0].lower()
                                        execute_command = True
                                    else:
                                        # error no valid parameter received
                                        execute_command = False
                                        errorstr = "cht_if_tx_data;error; cmd:{0}; unknown parameter:{1}".format(command_name, self.__splitted_rx_param[0])
                                        self.__logging.warning(errorstr)
                                else:
                                    # error no valid parameter received
                                    execute_command = False
                                    errorstr = "cht_if_tx_data;error; cmd:{0}; parameter:{1} wrong".format(command_name, self.__splitted_rx_param)
                                    self.__logging.warning(errorstr)
                            else:
                                # error no valid parameter
                                execute_command = False
                                errorstr = "cht_if_tx_data;error; cmd:{0}; amount of parameter:{1} wrong".format(command_name, self.__param_count)
                                self.__logging.warning(errorstr)
                        ########## end of: 'tniveau'
                    else:
                        errorstr = "cht_if_tx_data;error; cmd:{0}; amount of parameter:{1} wrong".format(command_name, self.__param_count)
                        self.__logging.warning(errorstr)
                        # error no valid parameter
                        execute_command = False
                else:
                    errorstr = "cht_if_tx_data; error; unknown command:{0} or wrong parameter received.".format(access_name)
                    self.__logging.warning(errorstr)
                    # error no valid parameter
                    execute_command = False

                # execute command if allowed
                if execute_command == True:
                    debugstr = """cht_if_tx_data; command:{0}; param_count:{1}; P1 heater-circuit:{2}; P2-Pn:{3}""".format(command_name,
                                                                                                              self.__param_count,
                                                                                                              self.__heater_circuit,
                                                                                                              self.__splitted_rx_param)
                    self.__logging.debug(debugstr)

                    # set EMS bus if it was dynamicly detected on telegramm-rx
                    #  this setup is importent to use the correct commands / Telegramms
                    #  for the EMS-like controllers.
                    if self.__bustype_detector_fkt() == ht_const.BUS_TYPE_EMS:
                        ems_bus = True
                        self.__ht_if_tx_data.set_ems_controller()
                    else:
                        ems_bus = False
                    # send data to ht-bus
                    self.__send_data_2_ht_bus(command_name.lower(), ems_bus)
                # task done, end of processing
                self.__tx_queue.task_done()
            else:
                errorstr = "cht_if_tx_data; unknown command:{0}".format(access_name)
                self.__logging.warning(errorstr)