示例#1
0
def trigger_action(status, alertname):
    try:
        action = '{}_{}'.format(
            status.lower(),
            re.sub(r'([A-Z]+)$', r'_\1', alertname).lower())
        logger.debug('Trigger %s action', action)
        eval(action)()
    except Exception as e:
        logger.error('Trigger %s caused error: %s', action, e)
示例#2
0
def firing_water_off():
    hardware.WATER_RELAY.off()
    logger.info('Toggle WATER OFF')
示例#3
0
def firing_water_on():
    hardware.FAN_RELAY.on()
    logger.info('Toggle WATER ON')
示例#4
0
def firing_fan_off():
    hardware.FAN_RELAY.off()
    logger.info('Toggle FAN OFF')
示例#5
0
def firing_fan_on():
    hardware.FAN_RELAY.on()
    logger.info('Toggle FAN ON')
示例#6
0
def firing_light_off():
    hardware.LIGHT_RELAY.off()
    logger.info('Toggle LIGHT OFF')
示例#7
0
def firing_light_on():
    hardware.LIGHT_RELAY.on()
    logger.info('Toggle LIGHT ON')