parameters: (self)
docstring: Reload the commands
docstring_summary: Reload the commands
docstring_tokens: Reload the commands
function: def _reload_commands(self):
          """ Reload the commands
          """
          with self._cmd_lock:
              self.log.info("Event : one device changed. Reloading data for commands")
              self.all_commands = {}
              with self._db.session_scope():
                  for cmd in self._db.get_all_command():
                      #print(cmd)
                      #<Command: return_confirmation='True', name='Swith', reference='switch_lighting2', id='6', device_id='21'>
                      #print(cmd.params)
                      #[<CommandParam: data_type='DT_Trigger', conversion='', cmd_id='16', key='state'>]
  
                      self.all_commands[str(cmd.id)] = {
                                                    'return_confirmation' : cmd.return_confirmation,
                                                    'name' : cmd.name,
                                                    'reference' : cmd.reference,
                                                    'id' : cmd.id,
                                                    'device_id' : cmd.device_id,
                                                    'xpl_command' : None,
                                                    'params' : []
                                                  }
  
                      for param in cmd.params:
                          self.all_commands[str(cmd.id)]['params'].append({
                                                                         'data_type' : param.data_type,
                                                                         'conversion' : param.conversion,
                                                                         'cmd_id' : param.cmd_id,
                                                                         'key' : param.key
                                                                     })
  
                      #print(cmd.xpl_command)
                      #<XplCommand: name='Switch', stat_id='82', cmd_id='6', json_id='switch_lighting2', device_id='21', id='6', schema='ac.basic'>
                      if cmd.xpl_command != None:
                          xpl_command = {
                                          'name' : cmd.xpl_command.name,
                                          'stat_id' : cmd.xpl_command.stat_id,
                                          'cmd_id' : cmd.xpl_command.cmd_id,
                                          'json_id' : cmd.xpl_command.json_id,
                                          'device_id' : cmd.xpl_command.device_id,
                                          'id' : cmd.xpl_command.id,
                                          'schema' : cmd.xpl_command.schema,
                                          'params' : []
                                        }
  
                          for param in cmd.xpl_command.params:
                              #print(param)
                              #<XplCommandParam: value='0x0038abfc', key='address', xplcmd_id='6'>
                              xpl_command['params'].append({'value' : param.value,
                                                            'key' : param.key,
                                                            'xplcmd_id' : param.xplcmd_id})
  
                          self.all_commands[str(cmd.id)]['xpl_command'] = xpl_command
  
              #print(self.all_commands)
              self.log.info("Event : one device changed. Reloading data for commands -- finished")
function_tokens: def _reload_commands ( self ) : with self . _cmd_lock : self . log . info ( "Event : one device changed. Reloading data for commands" ) self . all_commands = { } with self . _db . session_scope ( ) : for cmd in self . _db . get_all_command ( ) : #print(cmd) #<Command: return_confirmation='True', name='Swith', reference='switch_lighting2', id='6', device_id='21'> #print(cmd.params) #[<CommandParam: data_type='DT_Trigger', conversion='', cmd_id='16', key='state'>] self . all_commands [ str ( cmd . id ) ] = { 'return_confirmation' : cmd . return_confirmation , 'name' : cmd . name , 'reference' : cmd . reference , 'id' : cmd . id , 'device_id' : cmd . device_id , 'xpl_command' : None , 'params' : [ ] } for param in cmd . params : self . all_commands [ str ( cmd . id ) ] [ 'params' ] . append ( { 'data_type' : param . data_type , 'conversion' : param . conversion , 'cmd_id' : param . cmd_id , 'key' : param . key } ) #print(cmd.xpl_command) #<XplCommand: name='Switch', stat_id='82', cmd_id='6', json_id='switch_lighting2', device_id='21', id='6', schema='ac.basic'> if cmd . xpl_command != None : xpl_command = { 'name' : cmd . xpl_command . name , 'stat_id' : cmd . xpl_command . stat_id , 'cmd_id' : cmd . xpl_command . cmd_id , 'json_id' : cmd . xpl_command . json_id , 'device_id' : cmd . xpl_command . device_id , 'id' : cmd . xpl_command . id , 'schema' : cmd . xpl_command . schema , 'params' : [ ] } for param in cmd . xpl_command . params : #print(param) #<XplCommandParam: value='0x0038abfc', key='address', xplcmd_id='6'> xpl_command [ 'params' ] . append ( { 'value' : param . value , 'key' : param . key , 'xplcmd_id' : param . xplcmd_id } ) self . all_commands [ str ( cmd . id ) ] [ 'xpl_command' ] = xpl_command #print(self.all_commands) self . log . info ( "Event : one device changed. Reloading data for commands -- finished" )