(self, command)
send region specific start command
        example command:
        "cmd": {
                    "command": "start",
                    "ordered": 1,
                    "pmap_id": "wpVy73n9R5GrVYtEPZJ5iA",
                    "regions": [
                        {
                            "region_id": "6",
                            "type": "rid"
                        }
                    ],
                    "user_pmapv_id": "201227T172634"
                }
        command is json string, or dictionary.
        need 'regions' defined, or else whole map will be cleaned.
        if 'pmap_id' is not specified, the first pmap_id found in roombas list is used.
send region specific start command
        example command:
        "cmd": {
                    "command": "start",
                    "ordered": 1,
                    "pmap_id": "wpVy73n9R5GrVYtEPZJ5iA",
                    "regions": [
                        {
                            "region_id": "6",
                            "type": "rid"
                        }
                    ],
                    "user_pmapv_id": "201227T172634"
                }
        command is json string, or dictionary.
        need 'regions' defined, or else whole map will be cleaned.
        if 'pmap_id' is not specified, the first pmap_id found in roombas list is used.
send region specific start command example command : cmd : { command : start ordered : 1 pmap_id : wpVy73n9R5GrVYtEPZJ5iA regions : [ { region_id : 6 type : rid } ] user_pmapv_id : 201227T172634 } command is json string or dictionary . need regions defined or else whole map will be cleaned . if pmap_id is not specified the first pmap_id found in roombas list is used .
def send_region_command(self, command):
        '''
        send region specific start command
        example command:
        "cmd": {
                    "command": "start",
                    "ordered": 1,
                    "pmap_id": "wpVy73n9R5GrVYtEPZJ5iA",
                    "regions": [
                        {
                            "region_id": "6",
                            "type": "rid"
                        }
                    ],
                    "user_pmapv_id": "201227T172634"
                }
        command is json string, or dictionary.
        need 'regions' defined, or else whole map will be cleaned.
        if 'pmap_id' is not specified, the first pmap_id found in roombas list is used.
        '''
        pmaps = self.get_property('pmaps')
        self.log.info('pmaps: {}'.format(pmaps))
        myCommand = {}
        if not isinstance(command, dict):
            command = json.loads(command)
            
        myCommand['command'] = command.get('command', 'start')
        myCommand['ordered'] = 1
        pmap_id = command.get('pmap_id')
        user_pmap_id = command.get('user_pmapv_id')
        
        if pmaps:
            found = False
            for pmap in pmaps:
                for k, v in pmap.items():
                    if pmap_id:
                        if k == pmap_id:
                            user_pmap_id = v
                            found = True
                            break
                    else:
                        pmap_id = k
                        user_pmap_id = v
                        found = True
                        break
                if found:
                    break
                    
        myCommand['pmap_id'] = pmap_id
        for region in command.get('regions', []):
            myCommand.setdefault('regions', [])
            if not isinstance(region, dict) and str(region).isdigit():
                region = {'region_id': str(region), 'type': 'rid'}
            if isinstance(region, dict):
                myCommand['regions'].append(region)
        myCommand['user_pmapv_id'] = user_pmap_id
        
        self._send_command(myCommand)
def send_region_command ( self , command ) : pmaps = self . get_property ( 'pmaps' ) self . log . info ( 'pmaps: {}' . format ( pmaps ) ) myCommand = { } if not isinstance ( command , dict ) : command = json . loads ( command ) myCommand [ 'command' ] = command . get ( 'command' , 'start' ) myCommand [ 'ordered' ] = 1 pmap_id = command . get ( 'pmap_id' ) user_pmap_id = command . get ( 'user_pmapv_id' ) if pmaps : found = False for pmap in pmaps : for k , v in pmap . items ( ) : if pmap_id : if k == pmap_id : user_pmap_id = v found = True break else : pmap_id = k user_pmap_id = v found = True break if found : break myCommand [ 'pmap_id' ] = pmap_id for region in command . get ( 'regions' , [ ] ) : myCommand . setdefault ( 'regions' , [ ] ) if not isinstance ( region , dict ) and str ( region ) . isdigit ( ) : region = { 'region_id' : str ( region ) , 'type' : 'rid' } if isinstance ( region , dict ) : myCommand [ 'regions' ] . append ( region ) myCommand [ 'user_pmapv_id' ] = user_pmap_id self . _send_command ( myCommand )