Beispiel #1
0
def enableSensor(sensorname, sensorlibraryname, **kwargs):
    """
    Enable new sensor configuration
     - Create supervisor configuration
     - Create sensor user script from template
     - Create YAML configuration from sensor template
     """

    _LOGGER.info('enableSensor %(sensorname)s(%(sensorlibraryname)s)' %
                 locals())

    # Command line options
    force = '--force' in kwargs

    # Check packages installation
    modulename = 'mksensors.templates.sensor.%s' % sensorlibraryname
    mod = mks.loadModule(modulename)
    sensorobj = mod.Sensor()
    sensorobj.checkRequirements()

    # Create Supervisor configuration
    mks.enableSupervisorConf(sensorname=sensorname,
                             sensorlibraryname=sensorlibraryname,
                             force=force)

    # Copy module sensor code to bin folder
    mks.copySensorTemplateToUserBin(sensorname=sensorname,
                                    sensorlibraryname=sensorlibraryname,
                                    force=force)

    # Create sensor user configuration
    mks.enableSensorConfig(sensorname=sensorname, sensortype=sensorlibraryname)
Beispiel #2
0
def enableSensor(sensorname, sensorlibraryname, **kwargs):
    """
    Enable new sensor configuration
     - Create supervisor configuration
     - Create sensor user script from template
     - Create YAML configuration from sensor template
     """

    _LOGGER.info("enableSensor %(sensorname)s(%(sensorlibraryname)s)" % locals())

    # Command line options
    force = "--force" in kwargs

    # Check packages installation
    modulename = "mksensors.templates.sensor.%s" % sensorlibraryname
    mod = mks.loadModule(modulename)
    sensorobj = mod.Sensor()
    sensorobj.checkRequirements()

    # Create Supervisor configuration
    mks.enableSupervisorConf(sensorname=sensorname, sensorlibraryname=sensorlibraryname, force=force)

    # Copy module sensor code to bin folder
    mks.copySensorTemplateToUserBin(sensorname=sensorname, sensorlibraryname=sensorlibraryname, force=force)

    # Create sensor user configuration
    mks.enableSensorConfig(sensorname=sensorname, sensortype=sensorlibraryname)
Beispiel #3
0
def enableSender(sendername, **kwargs):
    _LOGGER.info('enableSender %(sendername)s' % locals())

    # Check packages installation
    modulename = 'mksensors.lib.sender.%s' % sendername

    # Check sender requirements
    mod = mks.loadModule(modulename)
    senderobj = mod.Sender()
    senderobj.checkRequirements()

    # Create sensor user configuration
    mks.enableSenderConfig(sendername=sendername, )

    # Check mksensors configuration
    mks.checkMkSensors()
Beispiel #4
0
def enableSender(sendername, **kwargs):
    _LOGGER.info("enableSender %(sendername)s" % locals())

    # Check packages installation
    modulename = "mksensors.lib.sender.%s" % sendername

    # Check sender requirements
    mod = mks.loadModule(modulename)
    senderobj = mod.Sender()
    senderobj.checkRequirements()

    # Create sensor user configuration
    mks.enableSenderConfig(sendername=sendername)

    # Check mksensors configuration
    mks.checkMkSensors()
Beispiel #5
0
def showSendersList():
    _LOGGER.info('showSendersList')

    allsenders = mks.getSenderPluginsList()
    enabledsenders = mks.getEnabledSenderNames()

    senders = []
    for sendername in allsenders:
        # Get senders information
        try:
            modulename = 'mksensors.lib.sender.%s' % sendername
            mod = mks.loadModule(modulename)
            senderobj = mod.Sender()
            description = senderobj.getDescription()
            enabled = 'Yes' if sendername in enabledsenders else ''
        except Exception as e:
            enabled = ''
            description = 'Cannot load the sender'

        senders.append((sendername, description, enabled))

    header = ['Sender name', 'Description', 'Enabled']
    print tabulate(senders, headers=header, tablefmt="orgtbl")
Beispiel #6
0
def showSendersList():
    _LOGGER.info("showSendersList")

    allsenders = mks.getSenderPluginsList()
    enabledsenders = mks.getEnabledSenderNames()

    senders = []
    for sendername in allsenders:
        # Get senders information
        try:
            modulename = "mksensors.lib.sender.%s" % sendername
            mod = mks.loadModule(modulename)
            senderobj = mod.Sender()
            description = senderobj.getDescription()
            enabled = "Yes" if sendername in enabledsenders else ""
        except Exception as e:
            enabled = ""
            description = "Cannot load the sender"

        senders.append((sendername, description, enabled))

    header = ["Sender name", "Description", "Enabled"]
    print tabulate(senders, headers=header, tablefmt="orgtbl")