def getTodaysEvent():
    # connect to the (local) mySQL DB on the Raspi
    print('-'*95)
    conn  = getMySQLconn()
    if conn==-1: 
        print("Unable to get mySQL connection!")
        return
    cur = conn.cursor()        
    # get power and switch status data
    eventName, evtActive, toStart, room, sinceEnd, targetTemp, eventID, online_id = checkCurrentEvent(cur)
    if not eventName=='':
        print( "        eventName         | evtActive |    toStart | room |   sinceEnd | targetTemp | eventID" )
        print( hilite( ( 
                         eventName.center(25)+' | '+str(evtActive).center(9)+' | '+formatSeconds( toStart ) + ' |  '+
                          str(room).center(3)+' | '+formatSeconds(sinceEnd) +' | '+str(targetTemp).center(10)+' | ' + str(eventID).center(7) 
                       ), 'green' ) )
    else:
        print("No scheduled event today.")
    
    print('-'*95)
    
    lclConn  = getMySQLconn()
    localSQL = lclConn.cursor()      
    if not localSQL==1:
        # get last event data
        localSQL.execute('SELECT * FROM `heating_logbook` ORDER BY timestamp DESC LIMIT 1')
        data = localSQL.fetchone() 
        try:
            text  = "Heating activity: " 
            if data[0].date() == datetime.date.today():
                text += hilite( 'today at '+data[0].strftime("%H:%M"), 'none', True ) 
            else:
                text += 'on ' + hilite( data[0].strftime("%A, %Y-%m-%d %H:%M"), 'none', True ) 
            if data[3].seconds > 0:
                text += hilite(" Estimate on: ",'none', True) + hilite( formatSeconds(data[3].seconds, False), 'green' )
            if data[4].seconds > 0:
                text += hilite(" Actual on: ",  'none', True) + hilite( formatSeconds(data[4].seconds, False), 'green' )
            if data[5].seconds > 0:
                text += hilite(" Actual off: ", 'none', True) + hilite( formatSeconds(data[5].seconds, False), 'green' )
            print(text)
        except:
            print(data)
    # close all open ends
    localSQL.close     # sql cursor
    lclConn.close      # sql connection     

    if oneoff: 
        print('-' * 75)
        print( "Current Event DB TAN is:", hilite( getCurrentTAN(localSQL), 'none', True ) )
    
    print('-'*75, datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") )
file_log_handler = logging.FileHandler( os.path.join(logDir, logName) ) 
Logger.addHandler(file_log_handler)

stderr_log_handler = logging.StreamHandler()    # log to the console as well
Logger.addHandler(stderr_log_handler)

formatter = logging.Formatter('%(asctime)s-%(name)s-%(levelname)s: %(message)s')
file_log_handler.setFormatter(formatter)
stderr_log_handler.setFormatter(formatter)




# connect to the (local) mySQL DB on the Raspi
lclConn  = getMySQLconn()
if lclConn == -1: sys.exit(-1)     # failed to connect to local mySQL DB!
localSQL = lclConn.cursor()

#------------------------------------------------------------------------
# get last modify date of this script
#------------------------------------------------------------------------
scriptChangeDate = os.path.getmtime(__file__)


def getTmStmp():
    now = datetime.datetime.now()
    tms = now.strftime("%Y-%m-%d %H:%M:%S")
    return str(tms) + " " + str(round( datetime.datetime.timestamp( now )) )