Beispiel #1
0
'''test telegram api'''

from backend.fcmapp import ApplicationService, ComponentName

APP = ApplicationService(ComponentName.fullcycle)

HUMID, TEMPER = APP.readtemperature()

MESSAGE = '{0}: Temp={1:0.1f}*  Humidity={2:0.1f}%'.format(
    APP.now(), TEMPER, HUMID)

APP.sendtelegrammessage(MESSAGE)

APP.shutdown()
Beispiel #2
0
            APP.send(QueueName.Q_DISCOVER, 'discover')
            DISCOVER.lastrun = datetime.datetime.now()

        if CAMERA.is_time_to_run():
            if APP.configuration.get('camera.size') is not None:
                print("[{0}] sending camera".format(APP.now()))
                PHOTO_NAME = APP.camera.take_picture()
                APP.camera.store_picture_cache(PHOTO_NAME)
                if APP.configuration.is_enabled('telegram'):
                    APP.telegram.sendphoto(PHOTO_NAME)
            CAMERA.lastrun = datetime.datetime.now()

        if TEMPERATURE.is_time_to_run():
            if APP.configuration.is_enabled('temperature'):
                print("[{0}] sending temperature".format(APP.now()))
                SENSOR_HUMID, SENSOR_TEMP = APP.readtemperature()
                if SENSOR_HUMID or SENSOR_TEMP:
                    MESSAGE = '{0}: Temp={1:0.1f}*  Humidity={2:0.1f}%'.format(
                        APP.now(), SENSOR_TEMP.value, SENSOR_HUMID.value)
                    APP.alert(MESSAGE)
            TEMPERATURE.lastrun = datetime.datetime.now()

        if HEARTBEAT.is_time_to_run():
            print("[{0}] sending heartbeat".format(APP.now()))
            MSG = 'At {0}'.format(APP.now())
            #get summary of known miners. name, hash or offline, pool
            if APP.configuration.is_enabled('temperature'):
                SENSOR_HUMID, SENSOR_TEMP = APP.readtemperature()
                if SENSOR_HUMID or SENSOR_TEMP:
                    MSG = MSG + 'Temp={0:0.1f}*  Humidity={1:0.1f}%'.format(
                        SENSOR_TEMP.value, SENSOR_HUMID.value)