Creates home assistant configuration for the known devices
339639
def _home_assistant_config(self):
        
        devices = {}
        for scs_id, dev in self._devices.items():
            devices[dev['ha_id']] = {
                'name': dev['name'],
                'scs_id': scs_id}

        return {'devices': devices}
1157394
def init_device(self):
        """"""
        Device.init_device(self)

        # Add anything here that has to be done before the device is set to
        # its ON state.

        self._set_master_state('on')
        self._devProxy = DeviceProxy(self.get_name())
79201
def create_hosting_device_resources(self, context, complementary_id,
                                        tenant_id, mgmt_context, max_hosted):
        """"""
        mgmt_port = None
        if mgmt_context and mgmt_context.get('mgmt_nw_id') and tenant_id:
            # Create port for mgmt interface
            p_spec = {'port': {
                'tenant_id': tenant_id,
                'admin_state_up': True,
                'name': 'mgmt',
                'network_id': mgmt_context['mgmt_nw_id'],
                'mac_address': bc.constants.ATTR_NOT_SPECIFIED,
                'fixed_ips': self._mgmt_subnet_spec(context, mgmt_context),
                'device_id': "",
                # Use device_owner attribute to ensure we can query for these
                # ports even before Nova has set device_id attribute.
                'device_owner': complementary_id}}
            try:
                mgmt_port = self._core_plugin.create_port(context, p_spec)
            except n_exc.NeutronException as e:
                LOG.error('Error %s when creating management port. '
                          'Cleaning up.', e)
                self.delete_hosting_device_resources(
                    context, tenant_id, mgmt_port)
                mgmt_port = None
        # We are setting the 'ports' to an empty list as it is expected by
        # the callee: device_handling_db._create_svc_vm_hosting_devices()
        return {'mgmt_port': mgmt_port, 'ports': []}
444134
def _detect_available_configs(serial_matcher=None):
        
        if serial_matcher:
            channels = find_serial_devices(serial_matcher)
        else:
            channels = find_serial_devices()

        return [{'interface': 'usb2can', 'channel': c} for c in channels]
78680
def main():
    
    parser = argparse.ArgumentParser(
        description='Read or change status of verisure devices')
    parser.add_argument(
        'username',
        help='MyPages username')
    parser.add_argument(
        'password',
        help='MyPages password')
    parser.add_argument(
        '-i', '--installation',
        help='Installation number',
        type=int,
        default=1)
    parser.add_argument(
        '-c', '--cookie',
        help='File to store cookie in',
        default='~/.verisure-cookie')

    commandsparser = parser.add_subparsers(
        help='commands',
        dest='command')

    # installations command
    commandsparser.add_parser(
        COMMAND_INSTALLATIONS,
        help='Get information about installations')

    # overview command
    overview_parser = commandsparser.add_parser(
        COMMAND_OVERVIEW,
        help='Read status of one or many device types')
    overview_parser.add_argument(
        'filter',
        nargs='*',
        help='Read status for device type')

    # armstate command
    commandsparser.add_parser(
        COMMAND_ARMSTATE,
        help='Get arm state')

    # Set command
    set_parser = commandsparser.add_parser(
        COMMAND_SET,
        help='Set status of a device')
    set_device = set_parser.add_subparsers(
        help='device',
        dest='device')

    # Set smartplug
    set_smartplug = set_device.add_parser(
        'smartplug',
        help='set smartplug value')
    set_smartplug.add_argument(
        'device_label',
        help='device label')
    set_smartplug.add_argument(
        'new_value',
        choices=[
            'on',
            'off'],
        help='new value')

    # Set alarm
    set_alarm = set_device.add_parser(
        'alarm',
        help='set alarm status')
    set_alarm.add_argument(
        'code',
        help='alarm code')
    set_alarm.add_argument(
        'new_status',
        choices=[
            'ARMED_HOME',
            'ARMED_AWAY',
            'DISARMED'],
        help='new status')

    # Set lock
    set_lock = set_device.add_parser(
        'lock',
        help='set lock status')
    set_lock.add_argument(
        'code',
        help='alarm code')
    set_lock.add_argument(
        'serial_number',
        help='serial number')
    set_lock.add_argument(
        'new_status',
        choices=[
            'lock',
            'unlock'],
        help='new status')

    # Get climate history
    history_climate = commandsparser.add_parser(
        COMMAND_CLIMATE,
        help='get climate history')
    history_climate.add_argument(
        'device_label',
        help='device label')

    # Event log command
    eventlog_parser = commandsparser.add_parser(
        COMMAND_EVENTLOG,
        help='Get event log')
    eventlog_parser.add_argument(
        '-p', '--pagesize',
        type=int,
        default=15,
        help='Number of elements on one page')
    eventlog_parser.add_argument(
        '-o', '--offset',
        type=int,
        default=0,
        help='Page offset')
    eventlog_parser.add_argument(
        '-f', '--filter',
        nargs='*',
        default=[],
        choices=[
            'ARM',
            'DISARM',
            'FIRE',
            'INTRUSION',
            'TECHNICAL',
            'SOS',
            'WARNING',
            'LOCK',
            'UNLOCK'],
        help='Filter event log')

    # Capture command
    capture_parser = commandsparser.add_parser(
        COMMAND_CAPTURE,
        help='Capture image')
    capture_parser.add_argument(
        'device_label',
        help='Device label')

    # Image series command
    commandsparser.add_parser(
        COMMAND_IMAGESERIES,
        help='Get image series')

    # Get image command
    getimage_parser = commandsparser.add_parser(
        COMMAND_GETIMAGE,
        help='Download image')
    getimage_parser.add_argument(
        'device_label',
        help='Device label')
    getimage_parser.add_argument(
        'image_id',
        help='image ID')
    getimage_parser.add_argument(
        'file_name',
        help='Output file name')

    # Vacation mode command
    commandsparser.add_parser(
        COMMAND_VACATIONMODE,
        help='Get vacation mode info')

    # Door window status command
    commandsparser.add_parser(
        COMMAND_DOOR_WINDOW,
        help='Get door/window status')

    # Test ethernet command
    commandsparser.add_parser(
        COMMAND_TEST_ETHERNET,
        help='Update ethernet status')

    args = parser.parse_args()
    session = verisure.Session(args.username, args.password, args.cookie)
    session.login()
    try:
        session.set_giid(session.installations[args.installation - 1]['giid'])
        if args.command == COMMAND_INSTALLATIONS:
            print_result(session.installations)
        if args.command == COMMAND_OVERVIEW:
            print_result(session.get_overview(), *args.filter)
        if args.command == COMMAND_ARMSTATE:
            print_result(session.get_arm_state())
        if args.command == COMMAND_SET:
            if args.device == 'smartplug':
                session.set_smartplug_state(
                    args.device_label,
                    args.new_value == 'on')
            if args.device == 'alarm':
                print_result(session.set_arm_state(
                    args.code,
                    args.new_status))
            if args.device == 'lock':
                print_result(session.set_lock_state(
                    args.code,
                    args.serial_number,
                    args.new_status))
        if args.command == COMMAND_CLIMATE:
            print_result(session.get_climate(args.device_label))
        if args.command == COMMAND_EVENTLOG:
            print_result(
                session.get_history(
                    args.filter,
                    pagesize=args.pagesize,
                    offset=args.offset))
        if args.command == COMMAND_CAPTURE:
            session.capture_image(args.device_label)
        if args.command == COMMAND_IMAGESERIES:
            print_result(session.get_camera_imageseries())
        if args.command == COMMAND_GETIMAGE:
            session.download_image(
                args.device_label,
                args.image_id,
                args.file_name)
        if args.command == COMMAND_VACATIONMODE:
            print_result(session.get_vacation_mode())
        if args.command == COMMAND_DOOR_WINDOW:
            print_result(session.get_door_window())
        if args.command == COMMAND_TEST_ETHERNET:
            session.test_ethernet()
    except verisure.session.ResponseError as ex:
        print(ex.text)
17836
function Device(key, name, children) {
    /**
     * @property key
     * @type {String}
     */
    this.key = key;
    /**
     * @property name
     * @type {String}
     */
    this.name = name;
    /**
     * @propety children
     * @type {Array}
     */
    this.children = children;
    /**
     * @property processChannels
     * @type {Array}
     */
    this.processChannels = [];
}
848743
def setup(self):
        
        self.devices = self.system.devman.devices
        self.ndevice = len(self.devices)

        self.gcalls = [''] * self.ndevice
        self.fcalls = [''] * self.ndevice
        self.gycalls = [''] * self.ndevice
        self.fxcalls = [''] * self.ndevice
        self.jac0s = [''] * self.ndevice

        self.build_vec()
        self.build_strings()
        self._compile_newton()
        self._compile_fdpf()
        self._compile_pfload()
        self._compile_pfgen()
        self._compile_seriesflow()
        self._compile_int()
        self._compile_int_f()
        self._compile_int_g()
        self._compile_bus_injection()
187986
def create_sync_ops(self, host_device):
    
    sync_ops = []
    host_params = self.params_device[host_device]
    for device, params in (self.params_device).iteritems():
      if device == host_device:
        continue
      for k in self.params_names:
        if isinstance(params[k], tf.Variable):
          sync_ops += [tf.assign(params[k], host_params[k])]
    return sync_ops
1116331
def add_x10_device(self, housecode, unitcode, feature='OnOff'):
        
        device = insteonplm.devices.create_x10(self, housecode,
                                               unitcode, feature)
        if device:
            self.devices[device.address.id] = device
        return device
107435
def create_equipamento_ambiente(self):
        """"""
        return EquipamentoAmbiente(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
56713
def add_known_devices(self, plm):
        """"""
        from insteonplm.devices import ALDBStatus
        for addr in self._saved_devices:
            if not self._devices.get(addr):
                saved_device = self._saved_devices.get(Address(addr).id, {})
                cat = saved_device.get('cat')
                subcat = saved_device.get('subcat')
                product_key = saved_device.get('firmware')
                product_key = saved_device.get('product_key', product_key)
                device = self.create_device_from_category(
                    plm, addr, cat, subcat, product_key)
                if device:
                    _LOGGER.debug('Device with id %s added to device list '
                                  'from saved device data.', addr)
                    aldb_status = saved_device.get('aldb_status', 0)
                    device.aldb.status = ALDBStatus(aldb_status)
                    aldb = saved_device.get('aldb', {})
                    device.aldb.load_saved_records(aldb_status, aldb)
                    self[addr] = device
        for addr in self._overrides:
            if not self._devices.get(addr):
                device_override = self._overrides.get(Address(addr).id, {})
                cat = device_override.get('cat')
                subcat = device_override.get('subcat')
                product_key = device_override.get('firmware')
                product_key = device_override.get('product_key', product_key)
                device = self.create_device_from_category(
                    plm, addr, cat, subcat, product_key)
                if device:
                    _LOGGER.debug('Device with id %s added to device list '
                                  'from device override data.', addr)
                    self[addr] = device
1147331
def _create_hosting_devices_from_config(self):
        
        hd_dict = config.get_specific_config('cisco_hosting_device')
        attr_info = ciscohostingdevicemanager.RESOURCE_ATTRIBUTE_MAP[
            ciscohostingdevicemanager.DEVICES]
        adm_context = bc.context.get_admin_context()

        for hd_uuid, kv_dict in hd_dict.items():
            # ensure hd_uuid is properly formatted
            hd_uuid = config.uuidify(hd_uuid)
            try:
                old_hd = self.get_hosting_device(adm_context, hd_uuid)
                is_create = False
            except ciscohostingdevicemanager.HostingDeviceNotFound:
                old_hd = {}
                is_create = True
            kv_dict['id'] = hd_uuid
            kv_dict['tenant_id'] = self.l3_tenant_id()
            # make sure we keep using same config agent if it has been assigned
            kv_dict['cfg_agent_id'] = old_hd.get('cfg_agent_id')
            # make sure we keep using management port if it exists
            kv_dict['management_port_id'] = old_hd.get('management_port_id')
            config.verify_resource_dict(kv_dict, True, attr_info)
            hd = {ciscohostingdevicemanager.DEVICE: kv_dict}
            try:
                if is_create:
                    self.create_hosting_device(adm_context, hd)
                else:
                    self.update_hosting_device(adm_context, kv_dict['id'], hd)
            except n_exc.NeutronException:
                with excutils.save_and_reraise_exception():
                    LOG.error('Invalid hosting device specification in '
                              'configuration file for device = %s',
                              hd_uuid)
252869
def _configure_computer(self):
        """"""
        print("Configuring '{}'".format(self.name))
        sshcfg = parse_sshconfig(self.hostname)
        authparams = {
            'compress': True,
            'gss_auth': False,
            'gss_deleg_creds': False,
            'gss_host': self.hostname,
            'gss_kex': False,
            'key_policy': 'WarningPolicy',
            'load_system_host_keys': True,
            'port': 22,
            'timeout': 60,
        }
        if 'user' in sshcfg:
            authparams['username'] = sshcfg['user']
        else:
            print ("SSH username is not provided, please run `verdi computer configure {}` "
                   "from the command line".format(self.name))
            return
        if 'proxycommand' in sshcfg:
            authparams['proxy_command'] = sshcfg['proxycommand']
        aiidauser = get_automatic_user()
        authinfo = DbAuthInfo(dbcomputer=Computer.get(self.name).dbcomputer, aiidauser=aiidauser)
        authinfo.set_auth_params(authparams)
        authinfo.save()
        print(check_output(['verdi', 'computer', 'show', self.name]))
1345456
function FtdiDevice(settings) {
  if (typeof(settings) === 'number') {
    settings = { index: settings };
  }

  EventEmitter.call(this);

  this.deviceSettings = settings;

  this.FTDIDevice = new FTDIDevice(settings);
}
625112
protected function configureModuleDevice()
    {
        $store_id = $this->getContext('store_id');

        $settings = array();
        $settings['theme'][$store_id]['mobile'] = 'mobile';
        $settings['theme'][$store_id]['tablet'] = 'mobile';

        $this->module->setSettings('device', $settings);
    }
525567
def _configure_device(commands, **kwargs):
    '''
    
    '''
    if salt.utils.platform.is_proxy():
        return __proxy__['nxos.proxy_config'](commands, **kwargs)
    else:
        return _nxapi_config(commands, **kwargs)
1206409
def setup (self):
        ''' 
        '''
        mainaccount = self.add_quotes(self.enter_config_value("mainaccount", 'ned'))
        keys = self.enter_config_value("keys", '[]')
        nodes = self.enter_config_value("nodes", 
                '["https://steemd.minnowsupportproject.org",'
                + '"https://rpc.buildteam.io",'
                + '"https://rpc.curiesteem.com",'
                + '"https://gtg.steem.house:8090",'
                + '"https://rpc.steemliberator.com",'
                + '"https://rpc.steemviz.com",'
                + '"https://steemd.privex.io"]')
        client_id = self.add_quotes(self.enter_config_value("client_id"))
        client_secret = self.add_quotes(self.enter_config_value("client_secret"))
        callback_url = self.add_quotes(self.enter_config_value("callback_url"))
        permissions = self.add_quotes(self.enter_config_value("permissions", "login,offline,vote"))
        logpath = self.add_quotes(self.enter_config_value("logpath", ""))
        screenmode = self.add_quotes(self.enter_config_value("screenmode", "quiet"))
        self.make(mainaccount=mainaccount, keys=keys, nodes=nodes, client_id=client_id, 
            client_secret=client_secret, callback_url=callback_url, permissions=permissions,
            logpath=logpath, screenmode=screenmode)