Esempio n. 1
0
 def __init__(self, controller, host, address, cam):
     self.ready = False
     #print("%s(%s) @%s(%s)" % (cam["name"], cam["make"], cam["ip_addr"], cam["mac_addr"]))
     self.host = host
     self.cam = cam
     self.detected_obj_by_type = {}
     super(Camera, self).__init__(controller, address, address, get_valid_node_name(cam['name']))
     self.lpfx = '%s:%s' % (self.address,self.name)
Esempio n. 2
0
 def __init__(self, controller, address, host, camect_obj, new=True):
     self.ready = False
     self.controller = controller
     self.host = host
     self.camect = camect_obj  # The camect api handle
     self.new = new
     self.cams_by_id = {}  # The hash of camera nodes by id
     name = get_valid_node_name('Camect ' + self.camect.get_name())
     LOGGER.info(f'address={address} name={name} ')
     super(Host, self).__init__(controller, address, address, name)
Esempio n. 3
0
 def __init__(self, controller, elk):
     LOGGER.debug(f'OutputNode:init: {elk}')
     self.elk = elk
     self.controller = controller
     self.init = False
     self.address = f'output_{self.elk.index + 1}'
     self.on_time = 0
     name = get_valid_node_name(self.elk.name)
     if name == "":
         name = f'Output_{self.elk.index + 1}'
     LOGGER.debug(f'OutputNode:init: {name}')
     super(OutputNode, self).__init__(controller, controller.address,
                                      self.address, name)
     self.lpfx = f'{self.name}:'
Esempio n. 4
0
 def __init__(self, controller, parent, area, elk):
     LOGGER.debug(f'KeypadNode:init: {elk}')
     self.elk = elk
     self.controller = controller
     self.parent = parent
     self.area = area
     self.init = False
     self.address = f'keypad_{self.elk.index + 1}'
     self.on_time = 0
     self.has_temperature = False if self.elk.temperature == -40 else True
     LOGGER.info(f'KeyPadNode:init: has_temperature={self.has_temperature}')
     name = get_valid_node_name(self.elk.name)
     if name == "":
         name = f'Keypad_{self.elk.index + 1}'
     self.uoms = {
         DNAMES['status']: 2,
         DNAMES['user']: 25,
         DNAMES['temperature']: self.controller.temperature_uom,
     }
     self.drivers = [
         # On/Off
         {
             'driver': DNAMES['status'],
             'value': 0,
             'uom': self.uoms[DNAMES['status']]
         },
         {
             'driver': DNAMES['user'],
             'value': -1,
             'uom': self.uoms[DNAMES['user']]
         },  # Last User
     ]
     LOGGER.debug(f'KeypadNode:init: name="{name}" uom={self.uoms}')
     if self.has_temperature:
         self.id = 'keypadT'
         self.drivers.append({
             'driver': DNAMES['temperature'],
             'value': -40,
             'uom': self.uoms[DNAMES['temperature']]
         })
     LOGGER.debug(f'KeypadNode:init: name="{name}" drivers={self.drivers}')
     super(KeypadNode, self).__init__(controller, parent.address,
                                      self.address, name)
     self.lpfx = f'{self.name}:'
Esempio n. 5
0
 def discover(self):
     self.l_info('discover', 'start')
     for dev in Discover.discover().values():
         self.l_debug(
             'discover',
             "Got Device\n\tAlias:{}\n\tModel:{}\n\tMac:{}\n\tHost:{}".
             format(dev.alias, dev.model, dev.mac, dev.host))
         cname = dev.__class__.__name__
         self.l_debug('discover', 'cname={}'.format(cname))
         if cname == 'SmartStrip':
             nname = get_valid_node_name(dev.mac)
             self.l_info('discover', 'adding SmartStrip {}'.format(nname))
             self.addNode(
                 SmartStripNode(self, nname,
                                'SmartStrip {}'.format(dev.mac), dev))
         else:
             self.l_warning('discover',
                            "Device not yet supported: {}".format(dev))
     LOGGER.info("discover: done")
Esempio n. 6
0
 def __init__(self, controller, parent, area, elk):
     self.elk = elk
     self.controller = controller
     self.parent = parent
     self.area = area
     self.init = False
     self.physical_status = -2
     self.logical_status = -2
     self.voltage = None
     self.triggered = None
     self.last_changeset = {}
     self.offnode = None
     self.offnode_obj = None
     self.address = 'zone_{}'.format(self.elk.index + 1)
     self.parent_address = 'area_{}'.format(self.elk.area + 1)
     self.logger = controller.logger
     name = get_valid_node_name(self.elk.name)
     if name == "":
         name = f'Zone_{self.elk.index + 1}'
     super(ZoneNode, self).__init__(controller, self.parent_address,
                                    self.address, name)
     self.lpfx = f'{self.name}:Zone_{self.elk.index + 1}:'
Esempio n. 7
0
 def add_node(self, dev=None, cfg=None):
     if dev is not None:
         mac = dev.mac
         if dev.is_bulb:
             type = 'SmartBulb'
             name = dev.alias
         elif dev.is_strip:
             type = 'SmartStrip'
             # SmartStrip doesn't have an alias so use the mac
             name = 'SmartStrip {}'.format(mac)
         elif dev.is_plug:
             type = 'SmartPlug'
             name = dev.alias
         elif dev.is_light_strip:
             type = 'SmartLightStrip'
             name = dev.alias
         else:
             LOGGER.error(f"What is this? {dev}")
             return False
         LOGGER.info(f"Got a {type}")
         cfg = {
             "type": type,
             "name": name,
             "host": dev.host,
             "mac": mac,
             "model": dev.model,
             "address": get_valid_node_name(mac)
         }
     elif cfg is None:
         LOGGER.error(f"INTERNAL ERROR: dev={dev} and cfg={cfg}")
         return False
     LOGGER.info(f"adding {cfg['type']} '{cfg['name']}' {cfg['address']}")
     #
     # Add Based on device type.  SmartStrip is a unique type, all others
     # are handled by SmartDevice
     #
     if cfg['type'] == 'SmartStrip':
         node = self.addNode(
             SmartStripNode(self,
                            cfg['address'],
                            cfg['name'],
                            dev=dev,
                            cfg=cfg))
     elif cfg['type'] == 'SmartPlug':
         node = self.addNode(
             SmartPlugNode(self,
                           cfg['address'],
                           cfg['name'],
                           dev=dev,
                           cfg=cfg))
     elif cfg['type'] == 'SmartBulb':
         node = self.addNode(
             SmartBulbNode(self,
                           cfg['address'],
                           cfg['name'],
                           dev=dev,
                           cfg=cfg))
     elif cfg['type'] == 'SmartLightStrip':
         node = self.addNode(
             SmartLightStripNode(self,
                                 cfg['address'],
                                 cfg['name'],
                                 dev=dev,
                                 cfg=cfg))
     else:
         LOGGER.error(f"Device type not yet supported: {cfg['type']}")
         return False
     # We always add it to update the host if necessary
     self.nodes_by_mac[self.smac(cfg['mac'])] = node
     return True