code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
msg = StandardSend(self._address, COMMAND_GET_INSTEON_ENGINE_VERSION_0X0D_0X00) self._send_msg(msg)
def get_engine_version(self)
Get the device engine version.
13.480439
10.46007
1.288752
msg = StandardSend(self._address, COMMAND_PING_0X0F_0X00) self._send_msg(msg)
def ping(self)
Ping a device.
13.202
10.856326
1.216065
self._plm.manage_aldb_record(0x40, 0xe2, 0x00, self.address, self.cat, self.subcat, self.product_key) self.manage_aldb_record(0x41, 0xa2, 0x00, self._plm.address, self._plm.cat, self._plm.subcat, self._plm.product_key) for link in self._stateList: state = self._stateList[link] if state.is_responder: # IM is controller self._plm.manage_aldb_record(0x40, 0xe2, link, self._address, 0x00, 0x00, 0x00) # Device is responder self.manage_aldb_record(0x41, 0xa2, link, self._plm.address, state.linkdata1, state.linkdata2, state.linkdata3) if state.is_controller: # IM is responder self._plm.manage_aldb_record(0x41, 0xa2, link, self._address, 0x00, 0x00, 0x00) # Device is controller self.manage_aldb_record(0x40, 0xe2, link, self._plm.address, 0x00, 0x00, 0x00) self.read_aldb()
def create_default_links(self)
Create the default links between the IM and the device.
2.559231
2.36369
1.082727
if self._aldb.version == ALDBVersion.Null: _LOGGER.info('Device %s does not contain an All-Link Database', self._address.human) else: _LOGGER.info('Reading All-Link Database for device %s', self._address.human) asyncio.ensure_future(self._aldb.load(mem_addr, num_recs), loop=self._plm.loop) self._aldb.add_loaded_callback(self._aldb_loaded_callback)
def read_aldb(self, mem_addr=0x0000, num_recs=0)
Read the device All-Link Database.
3.824139
3.459275
1.105474
if isinstance(mode, str) and mode.lower() in ['c', 'r']: pass else: _LOGGER.error('Insteon link mode: %s', mode) raise ValueError("Mode must be 'c' or 'r'") if isinstance(group, int): pass else: raise ValueError("Group must be an integer") target_addr = Address(target) _LOGGER.debug('calling aldb write_record') self._aldb.write_record(mem_addr, mode, group, target_addr, data1, data2, data3) self._aldb.add_loaded_callback(self._aldb_loaded_callback)
def write_aldb(self, mem_addr: int, mode: str, group: int, target, data1=0x00, data2=0x00, data3=0x00)
Write to the device All-Link Database. Parameters: Required: mode: r - device is a responder of target c - device is a controller of target group: Link group target: Address of the other device Optional: data1: Device dependant data2: Device dependant data3: Device dependant
3.504048
3.206185
1.092903
self._aldb.del_record(mem_addr) self._aldb.add_loaded_callback(self._aldb_loaded_callback)
def del_aldb(self, mem_addr: int)
Delete an All-Link Database record.
5.674197
4.363516
1.300373
if self.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: for mem_addr in self.aldb: rec = self.aldb[mem_addr] if linkcode in [0, 1, 3]: if rec.control_flags.is_high_water_mark: _LOGGER.debug('Removing HWM record %04x', mem_addr) self.aldb.pop(mem_addr) elif not rec.control_flags.is_in_use: _LOGGER.debug('Removing not in use record %04x', mem_addr) self.aldb.pop(mem_addr) else: if rec.address == self.address and rec.group == group: _LOGGER.debug('Removing record %04x with addr %s and ' 'group %d', mem_addr, rec.address, rec.group) self.aldb.pop(mem_addr) self.read_aldb()
def _refresh_aldb_records(self, linkcode, address, group)
Refresh the IM and device ALDB records.
2.666584
2.647539
1.007194
_LOGGER.debug('Starting Device.receive_message') if hasattr(msg, 'isack') and msg.isack: _LOGGER.debug('Got Message ACK') if self._sent_msg_wait_for_directACK.get('callback') is not None: _LOGGER.debug('Look for direct ACK') asyncio.ensure_future(self._wait_for_direct_ACK(), loop=self._plm.loop) else: _LOGGER.debug('DA queue: %s', self._sent_msg_wait_for_directACK) _LOGGER.debug('Message ACK with no callback') if (hasattr(msg, 'flags') and hasattr(msg.flags, 'isDirectACK') and msg.flags.isDirectACK): _LOGGER.debug('Got Direct ACK message') if self._send_msg_lock.locked(): self._directACK_received_queue.put_nowait(msg) else: _LOGGER.debug('But Direct ACK not expected') if not self._is_duplicate(msg): callbacks = self._message_callbacks.get_callbacks_from_message(msg) for callback in callbacks: _LOGGER.debug('Scheduling msg callback: %s', callback) self._plm.loop.call_soon(callback, msg) else: _LOGGER.debug('msg is duplicate') _LOGGER.debug(msg) self._last_communication_received = datetime.datetime.now() _LOGGER.debug('Ending Device.receive_message')
def receive_message(self, msg)
Receive a messages sent to this device.
3.784528
3.749445
1.009357
_LOGGER.debug('Starting X10Device.receive_message') if hasattr(msg, 'isack') and msg.isack: _LOGGER.debug('Got Message ACK') if self._send_msg_lock.locked(): self._send_msg_lock.release() callbacks = self._message_callbacks.get_callbacks_from_message(msg) _LOGGER.debug('Found %d callbacks for msg %s', len(callbacks), msg) for callback in callbacks: _LOGGER.debug('Scheduling msg callback: %s', callback) self._plm.loop.call_soon(callback, msg) self._last_communication_received = datetime.datetime.now() _LOGGER.debug('Ending Device.receive_message')
def receive_message(self, msg)
Receive a message sent to this device.
4.013073
4.053251
0.990087
self._stateList[group] = stateType(plm, device, stateName, group, defaultValue=defaultValue)
def add(self, plm, device, stateType, stateName, group, defaultValue=None)
Add a state to the StateList.
5.433671
4.564144
1.190513
memhi = userdata.get('d3') memlo = userdata.get('d4') memory = memhi << 8 | memlo control_flags = userdata.get('d6') group = userdata.get('d7') addrhi = userdata.get('d8') addrmed = userdata.get('d9') addrlo = userdata.get('d10') addr = Address(bytearray([addrhi, addrmed, addrlo])) data1 = userdata.get('d11') data2 = userdata.get('d12') data3 = userdata.get('d13') return ALDBRecord(memory, control_flags, group, addr, data1, data2, data3)
def create_from_userdata(userdata)
Create ALDB Record from the userdata dictionary.
2.80664
2.435863
1.152216
userdata = Userdata({'d3': self.memhi, 'd4': self.memlo, 'd6': self.control_flags, 'd7': self.group, 'd8': self.address.bytes[2], 'd9': self.address.bytes[1], 'd10': self.address.bytes[0], 'd11': self.data1, 'd12': self.data2, 'd13': self.data3}) return userdata
def to_userdata(self)
Return a Userdata dictionary.
3.219115
3.065706
1.05004
flags = int(self._in_use) << 7 \ | int(self._controller) << 6 \ | int(self._bit5) << 5 \ | int(self._bit4) << 4 \ | int(self._used_before) << 1 return flags
def byte(self)
Return a byte representation of ControlFlags.
5.101906
4.557131
1.119543
in_use = bool(control_flags & 1 << 7) controller = bool(control_flags & 1 << 6) bit5 = bool(control_flags & 1 << 5) bit4 = bool(control_flags & 1 << 4) used_before = bool(control_flags & 1 << 1) flags = ControlFlags(in_use, controller, used_before, bit5=bit5, bit4=bit4) return flags
def create_from_byte(control_flags)
Create a ControlFlags class from a control flags byte.
2.758487
2.554923
1.079675
if callback not in self._cb_aldb_loaded: self._cb_aldb_loaded.append(callback)
def add_loaded_callback(self, callback)
Add a callback to be run when the ALDB load is complete.
5.789292
3.335271
1.735779
if self._version == ALDBVersion.Null: self._status = ALDBStatus.LOADED _LOGGER.debug('Device has no ALDB') else: self._status = ALDBStatus.LOADING _LOGGER.debug('Tring to lock from load') await self._rec_mgr_lock _LOGGER.debug('load yielded lock') mem_hi = mem_addr >> 8 mem_lo = mem_addr & 0xff log_output = 'ALDB read' max_retries = 0 if rec_count: max_retries = ALDB_RECORD_RETRIES if mem_addr == 0x0000: log_output = '{:s} first record'.format(log_output) else: log_output = '{:s} record {:04x}'.format(log_output, mem_addr) else: max_retries = ALDB_ALL_RECORD_RETRIES log_output = '{:s} all records'.format(log_output) if retry: log_output = '{:s} retry {:d} of {:d}'.format(log_output, retry, max_retries) _LOGGER.info(log_output) userdata = Userdata({'d1': 0, 'd2': 0, 'd3': mem_hi, 'd4': mem_lo, 'd5': rec_count}) msg = ExtendedSend(self._address, COMMAND_EXTENDED_READ_WRITE_ALDB_0X2F_0X00, userdata=userdata) msg.set_checksum() self._send_method(msg, self._handle_read_aldb_ack, True) if not self._load_action: self._set_load_action(mem_addr, rec_count, -1, False)
async def load(self, mem_addr=0x0000, rec_count=0, retry=0)
Read the device database and load.
3.798973
3.746762
1.013935
if not (self._have_first_record() and self._have_last_record()): _LOGGER.error('Must load the Insteon All-Link Database before ' 'writing to it') else: self._prior_status = self._status self._status = ALDBStatus.LOADING mem_hi = mem_addr >> 8 mem_lo = mem_addr & 0xff controller = mode == 'c' control_flag = ControlFlags(True, controller, True, False, False) addr = Address(target) addr_lo = addr.bytes[0] addr_mid = addr.bytes[1] addr_hi = addr.bytes[2] userdata = Userdata({'d1': 0, 'd2': 0x02, 'd3': mem_hi, 'd4': mem_lo, 'd5': 0x08, 'd6': control_flag.byte, 'd7': group, 'd8': addr_lo, 'd9': addr_mid, 'd10': addr_hi, 'd11': data1, 'd12': data2, 'd13': data3}) msg = ExtendedSend(self._address, COMMAND_EXTENDED_READ_WRITE_ALDB_0X2F_0X00, userdata=userdata) msg.set_checksum() _LOGGER.debug('writing message %s', msg) self._send_method(msg, self._handle_write_aldb_ack, True) self._load_action = LoadAction(mem_addr, 1, 0)
def write_record(self, mem_addr: int, mode: str, group: int, target, data1=0x00, data2=0x00, data3=0x00)
Write an All-Link database record.
4.010868
3.799684
1.055579
record = self._records.get(mem_addr) if not record: _LOGGER.error('Must load the Insteon All-Link Database record ' 'before deleting it') else: self._prior_status = self._status self._status = ALDBStatus.LOADING mem_hi = mem_addr >> 8 mem_lo = mem_addr & 0xff controller = record.control_flags.is_controller control_flag = ControlFlags(False, controller, True, False, False) addr = record.address addr_lo = addr.bytes[0] addr_mid = addr.bytes[1] addr_hi = addr.bytes[2] group = record.group data1 = record.data1 data2 = record.data2 data3 = record.data3 userdata = Userdata({'d1': 0, 'd2': 0x02, 'd3': mem_hi, 'd4': mem_lo, 'd5': 0x08, 'd6': control_flag.byte, 'd7': group, 'd8': addr_lo, 'd9': addr_mid, 'd10': addr_hi, 'd11': data1, 'd12': data2, 'd13': data3}) msg = ExtendedSend(self._address, COMMAND_EXTENDED_READ_WRITE_ALDB_0X2F_0X00, userdata=userdata) msg.set_checksum() _LOGGER.debug('writing message %s', msg) self._send_method(msg, self._handle_write_aldb_ack, True) self._load_action = LoadAction(mem_addr, 1, 0)
def del_record(self, mem_addr: int)
Write an All-Link database record.
3.84782
3.610021
1.065872
found_rec = None mode_test = None if mode.lower() in ['c', 'r']: link_group = int(group) link_addr = Address(addr) for mem_addr in self: rec = self[mem_addr] if mode.lower() == 'r': mode_test = rec.control_flags.is_controller else: mode_test = rec.control_flags.is_responder if (mode_test and rec.group == link_group and rec.address == link_addr): found_rec = rec return found_rec
def find_matching_link(self, mode, group, addr)
Find a matching link in the current device. Mode: r | c is the mode of the link in the linked device This method will search for a corresponding link in the reverse direction. group: All-Link group number addr: Inteon address of the linked device
3.510952
3.494197
1.004795
release_lock = False userdata = msg.userdata rec = ALDBRecord.create_from_userdata(userdata) self._records[rec.mem_addr] = rec _LOGGER.debug('ALDB Record: %s', rec) rec_count = self._load_action.rec_count if rec_count == 1 or self._have_all_records(): release_lock = True if self._is_first_record(rec): self._mem_addr = rec.mem_addr if release_lock and self._rec_mgr_lock.locked(): _LOGGER.debug('Releasing lock because record received') self._rec_mgr_lock.release()
def record_received(self, msg)
Handle ALDB record received from device.
5.059715
4.486345
1.127803
if isinstance(status, ALDBStatus): self._status = status else: self._status = ALDBStatus(status) for mem_addr in records: rec = records[mem_addr] control_flags = int(rec.get('control_flags', 0)) group = int(rec.get('group', 0)) rec_addr = rec.get('address', '000000') data1 = int(rec.get('data1', 0)) data2 = int(rec.get('data2', 0)) data3 = int(rec.get('data3', 0)) self[int(mem_addr)] = ALDBRecord(int(mem_addr), control_flags, group, rec_addr, data1, data2, data3) if self._status == ALDBStatus.LOADED: keys = list(self._records.keys()) keys.sort(reverse=True) first_key = keys[0] self._mem_addr = first_key
def load_saved_records(self, status, records)
Load ALDB records from a set of saved records.
2.520789
2.368514
1.064292
if self._have_all_records(): mem_addr = None rec_count = 0 retries = 0 elif read_complete: retries = 0 if rec_count: mem_addr = self._next_address(mem_addr) else: mem_addr = self._next_address(mem_addr) rec_count = 1 retries = 0 elif rec_count and retries < ALDB_RECORD_RETRIES: retries = retries + 1 elif not rec_count and retries < ALDB_ALL_RECORD_RETRIES: retries = retries + 1 elif not rec_count and retries >= ALDB_ALL_RECORD_RETRIES: mem_addr = self._next_address(mem_addr) rec_count = 1 retries = 0 else: mem_addr = None rec_count = 0 retries = 0 self._load_action = LoadAction(mem_addr, rec_count, retries) if mem_addr is not None: _LOGGER.debug('Load action: addr: %04x rec_count: %d retries: %d', self._load_action.mem_addr, self._load_action.rec_count, self._load_action.retries)
def _set_load_action(self, mem_addr, rec_count, retries, read_complete=False)
Calculate the next record to read. If the last record was successful and one record was being read then look for the next record until we get to the high water mark. If the last read was successful and all records were being read then look for the first record. if the last read was unsuccessful and one record was being read then repeat the last read until max retries If the last read was unsuccessful and all records were being read then repeat the last read until max retries or look for the first record.
2.021142
2.107488
0.959029
_LOGGER.debug("Registered callback for state: %s", self._stateName) self._observer_callbacks.append(callback)
def register_updates(self, callback)
Register a callback to notify a listener of state changes.
10.941486
9.41578
1.162037
self._value = val for callback in self._observer_callbacks: callback(self._address, self._group, val)
def _update_subscribers(self, val)
Save state value and notify listeners of the change.
7.141393
5.467733
1.306098
userdata = Userdata.from_raw_message(rawmessage[11:25]) return ExtendedReceive(rawmessage[2:5], rawmessage[5:8], {'cmd1': rawmessage[9], 'cmd2': rawmessage[10]}, userdata, flags=rawmessage[8])
def from_raw_message(cls, rawmessage)
Create message from raw byte stream.
5.854508
5.617728
1.042149
msgraw = bytearray([0x02, cls._code]) msgraw.extend(bytes(cls._receivedSize)) msg = ExtendedReceive.from_raw_message(msgraw) if commandtuple: cmd1 = commandtuple.get('cmd1') cmd2out = commandtuple.get('cmd2') else: cmd1 = None cmd2out = None if cmd2 is not -1: cmd2out = cmd2 msg._address = Address(address) msg._target = Address(target) msg._messageFlags = MessageFlags(flags) msg._cmd1 = cmd1 msg._cmd2 = cmd2out msg._userdata = Userdata.create_pattern(userdata) return msg
def template(cls, address=None, target=None, commandtuple=None, userdata=None, cmd2=-1, flags=None)
Create message template for callbacks.
4.167768
4.19345
0.993876
low_byte = None if self.target is not None and self._messageFlags.isBroadcast: low_byte = self.target.bytes[0] return low_byte
def targetLow(self)
Return the low byte of the target address field. Used in All-Link Cleanup messages.
8.277045
6.022344
1.374389
if val == 0: self.off() else: setlevel = 255 if val < 1: setlevel = val * 100 elif val <= 0xff: setlevel = val set_command = StandardSend( self._address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=setlevel) self._send_method(set_command, self._on_message_received)
def set_level(self, val)
Set the devive ON LEVEL.
6.565932
5.844889
1.123363
brighten_command = StandardSend( self._address, COMMAND_LIGHT_BRIGHTEN_ONE_STEP_0X15_0X00) self._send_method(brighten_command)
def brighten(self)
Brighten the device one step.
12.302196
8.360257
1.471509
dim_command = StandardSend( self._address, COMMAND_LIGHT_DIM_ONE_STEP_0X16_0X00) self._send_method(dim_command)
def dim(self)
Dim the device one step.
20.593138
12.634557
1.629906
speed = self._value_to_fan_speed(val) if val == 0: self.off() else: set_command = ExtendedSend(self._address, COMMAND_LIGHT_ON_0X11_NONE, self._udata, cmd2=speed) set_command.set_checksum() self._send_method(set_command, self._on_message_received)
def set_level(self, val)
Set the fan speed.
8.860751
7.747282
1.143724
open_command = StandardSend(self._address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=0xff) self._send_method(open_command, self._open_message_received)
def open(self)
Turn the device ON.
17.859106
13.004981
1.373251
open_command = StandardSend(self._address, COMMAND_LIGHT_ON_FAST_0X12_NONE, cmd2=0xff) self._send_method(open_command, self._open_message_received)
def open_fast(self)
Turn the device ON Fast.
16.677996
12.403074
1.344666
close_command = StandardSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00) self._send_method(close_command, self._closed_message_received)
def close(self)
Turn the device off.
14.619233
10.856676
1.346566
close_command = StandardSend(self._address, COMMAND_LIGHT_OFF_FAST_0X14_0X00) self._send_method(close_command, self._closed_message_received)
def close_fast(self)
Turn the device off.
13.323236
10.215391
1.304232
if val == 0: self.close() else: setlevel = 255 if val < 1: setlevel = val * 100 elif val <= 0xff: setlevel = val set_command = StandardSend( self._address, COMMAND_LIGHT_ON_0X11_NONE, cmd2=setlevel) self._send_method(set_command, self._open_message_received)
def set_position(self, val)
Set the devive OPEN LEVEL.
7.525833
6.658531
1.130254
if val == 0: self.close_fast() else: setlevel = 255 if val < 1: setlevel = val * 100 elif val <= 0xff: setlevel = val set_command = StandardSend( self._address, COMMAND_LIGHT_ON_FAST_0X12_NONE, cmd2=setlevel) self._send_method(set_command, self._open_message_received)
def set_position_fast(self, val)
Set the devive OPEN LEVEL.
7.789083
6.898866
1.129038
_LOGGER.debug('Setting up extended status') ext_status = ExtendedSend( address=self._address, commandtuple=COMMAND_EXTENDED_GET_SET_0X2E_0X00, cmd2=0x02, userdata=Userdata()) ext_status.set_crc() _LOGGER.debug('Sending ext status: %s', ext_status) self._send_msg(ext_status) _LOGGER.debug('Sending temp status request') self.temperature.async_refresh_state()
def async_refresh_state(self)
Request each state to provide status update.
6.986194
6.491675
1.076177
hc = list(HC_LOOKUP.keys())[list(HC_LOOKUP.values()).index(bytecode)] return hc.upper()
def byte_to_housecode(bytecode)
Return an X10 housecode value from a byte value.
4.52645
4.671574
0.968935
return list(UC_LOOKUP.keys())[list(UC_LOOKUP.values()).index(bytecode)]
def byte_to_unitcode(bytecode)
Return an X10 unitcode value from a byte value.
5.065969
5.04848
1.003464
command_type = X10CommandType.DIRECT if command in [X10_COMMAND_ALL_UNITS_OFF, X10_COMMAND_ALL_LIGHTS_ON, X10_COMMAND_ALL_LIGHTS_OFF]: command_type = X10CommandType.BROADCAST return command_type
def x10_command_type(command)
Return the X10 command type from an X10 command.
2.890182
2.904173
0.995182
bitshift = bit - 1 if is_on: return bitmask | (1 << bitshift) return bitmask & (0xff & ~(1 << bitshift))
def set_bit(bitmask, bit, is_on)
Set the value of a bit in a bitmask on or off. Uses the low bit is 1 and the high bit is 8.
3.658349
3.954632
0.925079
if (rawmessage[5] & MESSAGE_FLAG_EXTENDED_0X10) == MESSAGE_FLAG_EXTENDED_0X10: if len(rawmessage) >= ExtendedSend.receivedSize: msg = ExtendedSend.from_raw_message(rawmessage) else: msg = None else: msg = StandardSend(rawmessage[2:5], {'cmd1': rawmessage[6], 'cmd2': rawmessage[7]}, flags=rawmessage[5], acknak=rawmessage[8:9]) return msg
def from_raw_message(cls, rawmessage)
Create a message from a raw byte stream.
4.993402
4.797951
1.040736
userdata_dict = Userdata(rawmessage[8:22]) return ExtendedSend(rawmessage[2:5], {'cmd1': rawmessage[6], 'cmd2': rawmessage[7]}, userdata_dict, flags=rawmessage[5], acknak=rawmessage[22:23])
def from_raw_message(cls, rawmessage)
Create a message from a raw byte stream.
8.195702
7.883156
1.039647
msgraw = bytearray([0x02, cls._code]) msgraw.extend(bytes(cls._receivedSize)) msg = ExtendedSend.from_raw_message(msgraw) if commandtuple: cmd1 = commandtuple.get('cmd1') cmd2out = commandtuple.get('cmd2') else: cmd1 = None cmd2out = None if cmd2 is not -1: cmd2out = cmd2 msg._address = Address(address) msg._messageFlags = MessageFlags(flags) msg._messageFlags.extended = 1 msg._cmd1 = cmd1 msg._cmd2 = cmd2out msg._userdata = Userdata.template(userdata) msg._acknak = acknak return msg
def template(cls, address=None, commandtuple=None, userdata=None, cmd2=-1, flags=None, acknak=None)
Create a message template used for callbacks.
4.086232
4.050191
1.008899
data_sum = self.cmd1 + self.cmd2 for i in range(1, 14): data_sum += self._userdata['d{:d}'.format(i)] chksum = 0xff - (data_sum & 0xff) + 1 self._userdata['d14'] = chksum
def set_checksum(self)
Set byte 14 of the userdata to a checksum value.
4.851323
3.908073
1.241359
data = self.bytes[6:20] crc = int(0) for b in data: # pylint: disable=unused-variable for bit in range(0, 8): fb = b & 0x01 fb = fb ^ 0x01 if (crc & 0x8000) else fb fb = fb ^ 0x01 if (crc & 0x4000) else fb fb = fb ^ 0x01 if (crc & 0x1000) else fb fb = fb ^ 0x01 if (crc & 0x0008) else fb crc = ((crc << 1) | fb) & 0xffff b = b >> 1 self._userdata['d13'] = (crc >> 8) & 0xff self._userdata['d14'] = crc & 0xff
def set_crc(self)
Set Userdata[13] and Userdata[14] to the CRC value.
2.392705
2.242515
1.066974
return StandardReceive(rawmessage[2:5], rawmessage[5:8], {'cmd1': rawmessage[9], 'cmd2': rawmessage[10]}, flags=rawmessage[8])
def from_raw_message(cls, rawmessage)
Create message from a raw byte stream.
6.772773
6.375962
1.062235
med_byte = None if self.target.addr is not None and self._messageFlags.isBroadcast: med_byte = self.target.bytes[1] return med_byte
def targetMed(self)
Return the middle byte of the target message property. Used in All-Link Cleanup message types.
10.939186
8.009807
1.365724
hi_byte = None if self.target.addr is not None and self._messageFlags.isBroadcast: hi_byte = self.target.bytes[2] return hi_byte
def targetHi(self)
Return the high byte of the target message property. Used in All-Link Cleanup message types.
10.275775
7.988768
1.286278
return AllLinkComplete(rawmessage[2], rawmessage[3], rawmessage[4:7], rawmessage[7], rawmessage[8], rawmessage[9])
def from_raw_message(cls, rawmessage)
Create a message from a raw byte stream.
5.378466
5.240842
1.02626
rawmessage = _trim_buffer_garbage(rawmessage) if len(rawmessage) < 2: return (None, rawmessage) code = rawmessage[1] msgclass = _get_msg_class(code) msg = None remaining_data = rawmessage if msgclass is None: _LOGGER.debug('Did not find message class 0x%02x', rawmessage[1]) rawmessage = rawmessage[1:] rawmessage = _trim_buffer_garbage(rawmessage, False) if rawmessage: _LOGGER.debug('Create: %s', create) _LOGGER.debug('rawmessage: %s', binascii.hexlify(rawmessage)) msg, remaining_data = create(rawmessage) else: remaining_data = rawmessage else: if iscomplete(rawmessage): msg = msgclass.from_raw_message(rawmessage) if msg: remaining_data = rawmessage[len(msg.bytes):] # _LOGGER.debug("Returning msg: %s", msg) # _LOGGER.debug('Returning buffer: %s', binascii.hexlify(remaining_data)) return (msg, remaining_data)
def create(rawmessage)
Return an INSTEON message class based on a raw byte stream.
3.285813
3.16266
1.03894
if len(rawmessage) < 2: return False if rawmessage[0] != 0x02: raise ValueError('message does not start with 0x02') messageBuffer = bytearray() filler = bytearray(30) messageBuffer.extend(rawmessage) messageBuffer.extend(filler) msg = _get_msg_class(rawmessage[1]) if hasattr(msg, 'receivedSize') and msg.receivedSize: expectedSize = msg.receivedSize else: _LOGGER.error('Unable to find a receivedSize for code 0x%x', rawmessage[1]) return ValueError is_expected_size = False if len(rawmessage) >= expectedSize: is_expected_size = True return is_expected_size
def iscomplete(rawmessage)
Test if the raw message is a complete message.
3.668991
3.613365
1.015395
msg_classes = {} msg_classes = _add_msg_class(msg_classes, MESSAGE_STANDARD_MESSAGE_RECEIVED_0X50, StandardReceive) msg_classes = _add_msg_class(msg_classes, MESSAGE_EXTENDED_MESSAGE_RECEIVED_0X51, ExtendedReceive) msg_classes = _add_msg_class(msg_classes, MESSAGE_X10_MESSAGE_RECEIVED_0X52, X10Received) msg_classes = _add_msg_class(msg_classes, MESSAGE_ALL_LINKING_COMPLETED_0X53, AllLinkComplete) msg_classes = _add_msg_class(msg_classes, MESSAGE_BUTTON_EVENT_REPORT_0X54, ButtonEventReport) msg_classes = _add_msg_class(msg_classes, MESSAGE_USER_RESET_DETECTED_0X55, UserReset) msg_classes = _add_msg_class(msg_classes, MESSAGE_ALL_LINK_CEANUP_FAILURE_REPORT_0X56, AllLinkCleanupFailureReport) msg_classes = _add_msg_class(msg_classes, MESSAGE_ALL_LINK_RECORD_RESPONSE_0X57, AllLinkRecordResponse) msg_classes = _add_msg_class(msg_classes, MESSAGE_ALL_LINK_CLEANUP_STATUS_REPORT_0X58, AllLinkCleanupStatusReport) msg_classes = _add_msg_class(msg_classes, MESSAGE_GET_IM_INFO_0X60, GetImInfo) msg_classes = _add_msg_class(msg_classes, MESSAGE_SEND_ALL_LINK_COMMAND_0X61, SendAllLinkCommand) msg_classes = _add_msg_class(msg_classes, MESSAGE_SEND_STANDARD_MESSAGE_0X62, StandardSend) msg_classes = _add_msg_class(msg_classes, MESSAGE_X10_MESSAGE_SEND_0X63, X10Send) msg_classes = _add_msg_class(msg_classes, MESSAGE_START_ALL_LINKING_0X64, StartAllLinking) msg_classes = _add_msg_class(msg_classes, MESSAGE_CANCEL_ALL_LINKING_0X65, CancelAllLinking) msg_classes = _add_msg_class(msg_classes, MESSAGE_RESET_IM_0X67, ResetIM) msg_classes = _add_msg_class(msg_classes, MESSAGE_GET_FIRST_ALL_LINK_RECORD_0X69, GetFirstAllLinkRecord) msg_classes = _add_msg_class(msg_classes, MESSAGE_GET_NEXT_ALL_LINK_RECORD_0X6A, GetNextAllLinkRecord) msg_classes = _add_msg_class(msg_classes, MESSAGE_MANAGE_ALL_LINK_RECORD_0X6F, ManageAllLinkRecord) msg_classes = _add_msg_class(msg_classes, MESSAGE_SET_IM_CONFIGURATION_0X6B, SetIMConfiguration) msg_classes = _add_msg_class(msg_classes, MESSAGE_GET_IM_CONFIGURATION_0X73, GetImConfiguration) return msg_classes.get(code, None)
def _get_msg_class(code)
Get the message class based on the message code.
1.712476
1.693086
1.011453
while rawmessage and rawmessage[0] != MESSAGE_START_CODE_0X02: if debug: _LOGGER.debug('Buffer content: %s', binascii.hexlify(rawmessage)) _LOGGER.debug('Trimming leading buffer garbage') rawmessage = rawmessage[1:] return rawmessage
def _trim_buffer_garbage(rawmessage, debug=True)
Remove leading bytes from a byte stream. A proper message byte stream begins with 0x02.
3.835571
3.707902
1.034431
if hasattr(other, 'messageType'): messageTypeIsEqual = False if self.messageType is None or other.messageType is None: messageTypeIsEqual = True else: messageTypeIsEqual = (self.messageType == other.messageType) extendedIsEqual = False if self.extended is None or other.extended is None: extendedIsEqual = True else: extendedIsEqual = (self.extended == other.extended) return messageTypeIsEqual and extendedIsEqual return False
def matches_pattern(self, other)
Test if current message match a patterns or template.
2.177457
1.960681
1.110562
property_names = [p for p in dir(cls) if isinstance(getattr(cls, p), property)] return property_names
def get_properties(cls)
Get all properties of the MessageFlags class.
3.690945
3.007576
1.227216
direct = (self._messageType == 0x00) if self.isDirectACK or self.isDirectNAK: direct = True return direct
def isDirect(self)
Test if the message is a direct message type.
7.48734
5.97849
1.25238
flags = MessageFlags(None) if messageType < 8: flags._messageType = messageType else: flags._messageType = messageType >> 5 if extended in [0, 1, True, False]: if extended: flags._extended = 1 else: flags._extended = 0 else: flags._extended = extended >> 4 flags._hopsLeft = hopsleft flags._hopsMax = hopsmax return flags
def create(cls, messageType, extended, hopsleft=3, hopsmax=3)
Create message flags. messageType: integter 0 to 7: MESSAGE_TYPE_DIRECT_MESSAGE = 0 MESSAGE_TYPE_DIRECT_MESSAGE_ACK = 1 MESSAGE_TYPE_ALL_LINK_CLEANUP = 2 MESSAGE_TYPE_ALL_LINK_CLEANUP_ACK = 3 MESSAGE_TYPE_BROADCAST_MESSAGE = 4 MESSAGE_TYPE_DIRECT_MESSAGE_NAK = 5 MESSAGE_TYPE_ALL_LINK_BROADCAST = 6 MESSAGE_TYPE_ALL_LINK_CLEANUP_NAK = 7 extended: 1 for extended, 0 for standard hopsleft: int 0 - 3 hopsmax: int 0 - 3
2.72558
2.661183
1.024199
flagByte = 0x00 messageType = 0 if self._messageType is not None: messageType = self._messageType << 5 extendedBit = 0 if self._extended is None else self._extended << 4 hopsMax = 0 if self._hopsMax is None else self._hopsMax hopsLeft = 0 if self._hopsLeft is None else (self._hopsLeft << 2) flagByte = flagByte | messageType | extendedBit | hopsLeft | hopsMax return bytes([flagByte])
def bytes(self)
Return a byte representation of the message flags.
3.311404
2.843408
1.16459
norm = None if isinstance(flags, MessageFlags): norm = flags.bytes elif isinstance(flags, bytearray): norm = binascii.hexlify(flags) elif isinstance(flags, int): norm = bytes([flags]) elif isinstance(flags, bytes): norm = binascii.hexlify(flags) elif isinstance(flags, str): flags = flags[0:2] norm = binascii.hexlify(binascii.unhexlify(flags.lower())) elif flags is None: norm = None else: _LOGGER.warning('MessageFlags with unknown type %s: %r', type(flags), flags) return norm
def _normalize(self, flags)
Take any format of flags and turn it into a hex string.
2.71769
2.549429
1.066
flagByte = self._normalize(flags) if flagByte is not None: self._messageType = (flagByte[0] & 0xe0) >> 5 self._extended = (flagByte[0] & MESSAGE_FLAG_EXTENDED_0X10) >> 4 self._hopsLeft = (flagByte[0] & 0x0c) >> 2 self._hopsMax = flagByte[0] & 0x03 else: self._messageType = None self._extended = None self._hopsLeft = None self._hopsMax = None
def _set_properties(self, flags)
Set the properties of the message flags based on a byte input.
3.0891
2.733515
1.130083
value = 0 if dry_wet == self._dry_wet_type: value = 1 self._update_subscribers(value)
def set_value(self, dry_wet: LeakSensorState)
Set the value of the state to dry or wet.
7.433546
5.885873
1.262947
for callback in self._dry_wet_callbacks: callback(self._dry_wet_type) self._update_subscribers(0x01)
def _dry_wet_message_received(self, msg)
Report a dry or a wet state.
7.880949
7.142555
1.103379
if dry_wet == LeakSensorState.DRY: self._update_subscribers(0x11) else: self._update_subscribers(0x13)
def set_value(self, dry_wet: LeakSensorState)
Set the state to wet or dry.
4.703433
3.781008
1.243963
for callback in self._dry_wet_callbacks: callback(LeakSensorState.DRY) self._update_subscribers(0x11)
def _dry_message_received(self, msg)
Report a dry state.
20.514463
16.22077
1.264703
for callback in self._dry_wet_callbacks: callback(LeakSensorState.WET) self._update_subscribers(0x13)
def _wet_message_received(self, msg)
Report a wet state.
18.607147
15.117874
1.230804
if override: if isinstance(callback, list): self._dict[msg] = callback else: self._dict[msg] = [callback] else: cb = self[msg] cb.append(callback) self._dict[msg] = cb
def add(self, msg, callback, override=False)
Add a callback to the callback list. msg: Message template. callback: Callback method override: True - replace all existing callbacks for that template False - append the list of callbacks for that message Default is False
2.692644
2.814651
0.956653
if callback is None: self._dict.pop(msg, None) else: cb = self._dict.get(msg, []) try: cb.remove(callback) except ValueError: pass if cb: _LOGGER.debug('%d callbacks for message: %s', len(cb), msg) self.add(msg, cb, True) else: self._dict.pop(msg, None) _LOGGER.debug('Removed all callbacks for message: %s', msg)
def remove(self, msg, callback)
Remove a callback from the callback list. msg: Message template callback: Callback method to remove. If callback is None, all callbacks for the message template are removed.
2.659636
2.655524
1.001549
callbacks = [] for key in self._find_matching_keys(msg): for callback in self[key]: callbacks.append(callback) return callbacks
def get_callbacks_from_message(self, msg)
Return the callbacks associated with a message template.
4.4733
3.941917
1.134803
x10_product = None for product in self._x10_products: if feature.lower() == product.feature: x10_product = product if not x10_product: x10_product = X10Product(feature, None) return x10_product
def x10(self, feature)
Return an X10 device based on a feature. Current features: - OnOff - Dimmable
3.148815
2.9472
1.068409
return AllLinkRecordResponse(rawmessage[2], rawmessage[3], rawmessage[4:7], rawmessage[7], rawmessage[8], rawmessage[9])
def from_raw_message(cls, rawmessage)
Create message from raw byte stream.
5.661862
5.452024
1.038488
parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--device', default='/dev/ttyUSB0', help='Path to PLM device') parser.add_argument('--verbose', '-v', action='count', help='Set logging level to verbose') parser.add_argument('-l', '--logfile', default='', help='Log file name') parser.add_argument('--workdir', default='', help='Working directory for reading and saving ' 'device information.') args = parser.parse_args() loop = asyncio.get_event_loop() monTool = Tools(loop, args) asyncio.ensure_future(monTool.monitor_mode()) try: loop.run_forever() except KeyboardInterrupt: if monTool.plm: if monTool.plm.transport: _LOGGING.info('Closing the session') asyncio.ensure_future(monTool.plm.transport.close(), loop=loop) loop.stop() pending = asyncio.Task.all_tasks(loop=loop) for task in pending: task.cancel() try: loop.run_until_complete(task) except asyncio.CancelledError: pass except KeyboardInterrupt: pass loop.close()
def monitor()
Connect to receiver and show events as they occur. Pulls the following arguments from the command line: :param device: Unix device where the PLM is attached :param address: Insteon address of the device to link with :param group: Insteon group for the link :param: linkcode Link direction: 0 - PLM is responder 1 - PLM is controller 3 - IM is responder or controller' :param verbose: Show debug logging.
2.788687
2.72944
1.021706
parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--device', default='/dev/ttyUSB0', help='Path to PLM device') parser.add_argument('-v', '--verbose', action='count', help='Set logging level to verbose') parser.add_argument('-l', '--logfile', default='', help='Log file name') parser.add_argument('--workdir', default='', help='Working directory for reading and saving ' 'device information.') args = parser.parse_args() loop = asyncio.get_event_loop() cmd = Commander(loop, args) cmd.start() try: loop.run_forever() except KeyboardInterrupt: if cmd.tools.plm: if cmd.tools.plm.transport: # _LOGGING.info('Closing the session') cmd.tools.plm.transport.close() loop.stop() pending = asyncio.Task.all_tasks(loop=loop) for task in pending: task.cancel() try: loop.run_until_complete(task) except asyncio.CancelledError: pass except KeyboardInterrupt: pass loop.close()
def interactive()
Create an interactive command line tool. Wrapper for an interactive session for manual commands to be entered.
2.741445
2.726846
1.005354
await self.aldb_load_lock.acquire() device = self.host if self.host else self.device _LOGGING.info('Connecting to Insteon Modem at %s', device) self.device = device if device else self.device self.workdir = workdir if workdir else self.workdir conn = await insteonplm.Connection.create( device=self.device, host=self.host, port=self.port, username=self.username, password=self.password, loop=self.loop, poll_devices=poll_devices, workdir=self.workdir) _LOGGING.info('Connecton made to Insteon Modem at %s', device) conn.protocol.add_device_callback(self.async_new_device_callback) conn.protocol.add_all_link_done_callback( self.async_aldb_loaded_callback) self.plm = conn.protocol await self.aldb_load_lock if self.aldb_load_lock.locked(): self.aldb_load_lock.release()
async def connect(self, poll_devices=False, device=None, workdir=None)
Connect to the IM.
3.061955
2.935994
1.042902
print("Running monitor mode") await self.connect(poll_devices, device, workdir) self.plm.monitor_mode()
async def monitor_mode(self, poll_devices=False, device=None, workdir=None)
Place the IM in monitoring mode.
7.712468
6.823397
1.130297
_LOGGING.info( 'New Device: %s cat: 0x%02x subcat: 0x%02x desc: %s, model: %s', device.id, device.cat, device.subcat, device.description, device.model) for state in device.states: device.states[state].register_updates( self.async_state_change_callback)
def async_new_device_callback(self, device)
Log that our new device callback worked.
4.19236
3.915837
1.070617
_LOGGING.info('Device %s state %s value is changed to %s', addr, state, value)
def async_state_change_callback(self, addr, state, value)
Log the state change.
9.63735
8.195883
1.175877
if self.aldb_load_lock.locked(): self.aldb_load_lock.release() _LOGGING.info('ALDB Loaded')
def async_aldb_loaded_callback(self)
Unlock the ALDB load lock when loading is complete.
5.715443
4.21209
1.356914
_LOGGING.info('Starting the All-Linking process') if address: linkdevice = self.plm.devices[Address(address).id] if not linkdevice: linkdevice = create(self.plm, address, None, None) _LOGGING.info('Attempting to link the PLM to device %s. ', address) self.plm.start_all_linking(linkcode, group) asyncio.sleep(.5, loop=self.loop) linkdevice.enter_linking_mode(group=group) else: _LOGGING.info('Starting All-Linking on PLM. ' 'Waiting for button press') self.plm.start_all_linking(linkcode, group) await asyncio.sleep(self.wait_time, loop=self.loop) _LOGGING.info('%d devices added to the All-Link Database', len(self.plm.devices)) await asyncio.sleep(.1, loop=self.loop)
async def start_all_linking(self, linkcode, group, address=None)
Start the All-Linking process with the IM and device.
3.911265
3.703018
1.056237
if self.plm.devices: for addr in self.plm.devices: device = self.plm.devices[addr] if device.address.is_x10: _LOGGING.info('Device: %s %s', device.address.human, device.description) else: _LOGGING.info('Device: %s cat: 0x%02x subcat: 0x%02x ' 'desc: %s, model: %s', device.address.human, device.cat, device.subcat, device.description, device.model) else: _LOGGING.info('No devices found') if not self.plm.transport: _LOGGING.info('IM connection has not been made.') _LOGGING.info('Use `connect [device]` to open the connection')
def list_devices(self)
List devices in the ALDB.
3.494627
3.412308
1.024124
if Address(addr).id == self.plm.address.id: device = self.plm else: dev_addr = Address(addr) device = self.plm.devices[dev_addr.id] if device: if device.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: if device.aldb.status == ALDBStatus.PARTIAL: _LOGGING.info('ALDB partially loaded for device %s', addr) for mem_addr in device.aldb: record = device.aldb[mem_addr] _LOGGING.debug('mem_addr: %s', mem_addr) _LOGGING.info('ALDB record: %s', record) else: _LOGGING.info('ALDB not loaded. ' 'Use `load_aldb %s` first.', device.address.id) else: _LOGGING.info('Device not found.')
def print_device_aldb(self, addr)
Diplay the All-Link database for a device.
2.949266
2.897571
1.017841
addr = self.plm.address.id _LOGGING.info('ALDB for PLM device %s', addr) self.print_device_aldb(addr) if self.plm.devices: for addr in self.plm.devices: _LOGGING.info('ALDB for device %s', addr) self.print_device_aldb(addr) else: _LOGGING.info('No devices found') if not self.plm.transport: _LOGGING.info('IM connection has not been made.') _LOGGING.info('Use `connect [device]` to open the connection')
def print_all_aldb(self)
Diplay the All-Link database for all devices.
4.292649
3.971368
1.080899
dev_addr = Address(addr) device = None if dev_addr == self.plm.address: device = self.plm else: device = self.plm.devices[dev_addr.id] if device: if clear: device.aldb.clear() device.read_aldb() await asyncio.sleep(1, loop=self.loop) while device.aldb.status == ALDBStatus.LOADING: await asyncio.sleep(1, loop=self.loop) if device.aldb.status == ALDBStatus.LOADED: _LOGGING.info('ALDB loaded for device %s', addr) self.print_device_aldb(addr) else: _LOGGING.error('Could not find device %s', addr)
async def load_device_aldb(self, addr, clear=True)
Read the device ALDB.
2.743949
2.702154
1.015467
for addr in self.plm.devices: await self.load_device_aldb(addr, clear)
async def load_all_aldb(self, clear=True)
Read all devices ALDB.
8.415903
5.531068
1.521569
dev_addr = Address(addr) target_addr = Address(target) device = self.plm.devices[dev_addr.id] if device: _LOGGING.debug('calling device write_aldb') device.write_aldb(mem_addr, mode, group, target_addr, data1, data2, data3) await asyncio.sleep(1, loop=self.loop) while device.aldb.status == ALDBStatus.LOADING: await asyncio.sleep(1, loop=self.loop) self.print_device_aldb(addr)
async def write_aldb(self, addr, mem_addr: int, mode: str, group: int, target, data1=0x00, data2=0x00, data3=0x00)
Write a device All-Link record.
3.574091
3.271477
1.092501
dev_addr = Address(addr) device = self.plm.devices[dev_addr.id] if device: _LOGGING.debug('calling device del_aldb') device.del_aldb(mem_addr) await asyncio.sleep(1, loop=self.loop) while device.aldb.status == ALDBStatus.LOADING: await asyncio.sleep(1, loop=self.loop) self.print_device_aldb(addr)
async def del_aldb(self, addr, mem_addr: int)
Write a device All-Link record.
4.368311
3.821707
1.143026
self.plm.devices.add_override(addr, 'cat', cat) self.plm.devices.add_override(addr, 'subcat', subcat) if firmware: self.plm.devices.add_override(addr, 'firmware', firmware)
def add_device_override(self, addr, cat, subcat, firmware=None)
Add a device override to the PLM.
2.171793
2.031614
1.068999
device = None try: device = self.plm.devices.add_x10_device(self.plm, housecode, unitcode, dev_type) except ValueError: pass return device
def add_x10_device(self, housecode, unitcode, dev_type)
Add an X10 device to the PLM.
3.622473
2.94343
1.230698
addr = Address(address) device = self.plm.devices[addr.id] device.states[group].async_refresh_state()
def kpl_status(self, address, group)
Get the status of a KPL button.
9.999147
10.040703
0.995861
addr = Address(address) device = self.plm.devices[addr.id] device.states[group].on()
def kpl_on(self, address, group)
Get the status of a KPL button.
8.918708
9.537238
0.935146
addr = Address(address) device = self.plm.devices[addr.id] device.states[group].off()
def kpl_off(self, address, group)
Get the status of a KPL button.
8.848414
9.328602
0.948525
addr = Address(address) device = self.plm.devices[addr.id] device.states[group].set_on_mask(mask)
def kpl_set_on_mask(self, address, group, mask)
Get the status of a KPL button.
6.705499
6.367136
1.053142
self.loop.create_task(self._read_line()) self.loop.create_task(self._greeting())
def start(self)
Start the command process loop.
5.587726
4.909029
1.138255
params = args.split() device = '/dev/ttyUSB0' workdir = None try: device = params[0] except IndexError: if self.tools.device: device = self.tools.device try: workdir = params[1] except IndexError: if self.tools.workdir: workdir = self.tools.workdir if device: await self.tools.connect(False, device=device, workdir=workdir) _LOGGING.info('Connection complete.')
async def do_connect(self, args)
Connect to the PLM device. Usage: connect [device [workdir]] Arguments: device: PLM device (default /dev/ttyUSB0) workdir: Working directory to save and load device information
3.592759
3.475924
1.033613
for task in asyncio.Task.all_tasks(loop=self.loop): _LOGGING.info(task)
def do_running_tasks(self, arg)
List tasks running in the background. Usage: running_tasks Arguments:
6.194546
10.503519
0.589759
linkcode = 1 group = 0 addr = None params = args.split() if params: try: linkcode = int(params[0]) except IndexError: linkcode = 1 except ValueError: linkcode = None try: group = int(params[1]) except IndexError: group = 0 except ValueError: group = None try: addr = params[2] except IndexError: addr = None if linkcode in [0, 1, 3] and 255 >= group >= 0: self.loop.create_task( self.tools.start_all_linking(linkcode, group, addr)) else: _LOGGING.error('Link code %d or group number %d not valid', linkcode, group) self.do_help('add_all_link')
def do_add_all_link(self, args)
Add an All-Link record to the IM and a device. Usage: add_all_link [linkcode] [group] [address] Arguments: linkcode: 0 - PLM is responder 1 - PLM is controller 3 - PLM is controller or responder Default 1 group: All-Link group number (0 - 255). Default 0. address: INSTEON device to link with (not supported by all devices)
3.04456
2.661112
1.144093
params = args.split() addr = None try: addr = params[0] except IndexError: _LOGGING.error('Device address required.') self.do_help('print_aldb') if addr: if addr.lower() == 'all': self.tools.print_all_aldb() elif addr.lower() == 'plm': addr = self.tools.plm.address.id self.tools.print_device_aldb(addr) else: self.tools.print_device_aldb(addr)
def do_print_aldb(self, args)
Print the All-Link database for a device. Usage: print_aldb address|plm|all Arguments: address: INSTEON address of the device plm: Print the All-Link database for the PLM all: Print the All-Link database for all devices This method requires that the device ALDB has been loaded. To load the device ALDB use the command: load_aldb address|plm|all
3.616931
3.210208
1.126697
params = args.split() username = None password = None host = None port = None try: username = params[0] password = params[1] host = params[2] port = params[3] except IndexError: pass if username and password and host: if not port: port = 25105 self.tools.username = username self.tools.password = password self.tools.host = host self.tools.port = port else: _LOGGING.error('username password host are required') self.do_help('set_hub_connection')
def do_set_hub_connection(self, args)
Set Hub connection parameters. Usage: set_hub_connection username password host [port] Arguments: username: Hub username password: Hub password host: host name or IP address port: IP port [default 25105]
2.752784
2.398839
1.147548
params = args.split() try: filename = params[0] logging.basicConfig(filename=filename) except IndexError: self.do_help('set_log_file')
def do_set_log_file(self, args)
Set the log file. Usage: set_log_file filename Parameters: filename: log file name to write to THIS CAN ONLY BE CALLED ONCE AND MUST BE CALLED BEFORE ANY LOGGING STARTS.
3.109485
3.320908
0.936336