'''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()
'''test broadcast''' from helpers.queuehelper import BroadcastSender, QueueName #from messaging.messages import * #from domain import mining, rep from backend.fcmapp import ApplicationService, ServiceName APP = ApplicationService() QBROAD = BroadcastSender(QueueName.Q_LOG, APP.getservice(ServiceName.messagebus)) QBROAD.broadcast('{0} WORKING! test_broadcast {1}'.format( APP.now(), QBROAD.queue_name)) QBROAD.close()
CAMERA.interval = 60 * APP.configuration.get('schedule.camera.minutes') TEMPERATURE = TaskSchedule(run_on_init=True) TEMPERATURE.start = datetime.datetime.now().replace( microsecond=0, second=0, minute=0) + datetime.timedelta(hours=1) TEMPERATURE.interval = 60 * APP.configuration.get( 'schedule.temperature.minutes') UPDATEWEB = TaskSchedule(run_on_init=False) UPDATEWEB.interval = 60 * APP.configuration.get( 'update.fullcycleweb.interval.minutes') while True: try: if MONITOR.is_time_to_run(): print("[{0}] Time to monitor".format(APP.now())) print('Pushing monitor command to {0}.'.format( QueueName.Q_MONITOR)) APP.send(QueueName.Q_MONITOR, 'monitor') MONITOR.lastrun = datetime.datetime.now() if DISCOVER.is_time_to_run(): print("[{0}] Time to discover".format(APP.now())) print('Pushing discover command to {0}.'.format( QueueName.Q_DISCOVER)) 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()))
'''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.value or 0, HUMID.value or 0) APP.logdebug(MESSAGE) APP.shutdown()
'''test telegram api''' from backend.fcmapp import ApplicationService, ComponentName APP = ApplicationService(ComponentName.fullcycle) MESSAGE = 'Full Cycle Mining test {}'.format(APP.now()) if APP.is_enabled_configuration('telegram'): APP.sendtelegrammessage(MESSAGE) else: print('telegram is not enabled in configuration') if APP.is_enabled_configuration('camera'): FILEOUT = APP.take_picture('fullcycle_camera.png') APP.sendtelegramphoto(FILEOUT) else: print('camera is not enabled in configuration') APP.shutdown()