Select Different Google Calendars

Tidbyt defaults to my personal google calendar, but the device is located in our kitchen where I’d want to view my family’s shared google calendar instead. I’d like the ability to choose which of my google calendar’s Tidbyt syncs to and displays.

So much this! My wife and I have a shared calendar that I’d love to have show up on my Tidbyt!

Why not Apple calendar for iPhone users ?

This is the first thing that I looked for! Turns out all of my events are on a shared calendar

I’m actually tinkering with doing exactly this right now, though it’s something of a PITA. I’m doing this in python and using Google Calendar’s APIs to access events on calendars I own and/or have access to: Python Quickstart  |  Calendar API  |  Google Developers. It works pretty well, though at the moment, Google seems to expire my refresh token at the end of a week.

1 Like

Hi

If you open Google Calendar in a Browser there is an option to access the calendar in iCal Format. “Privat address in iCal format”.

Below code downloads all my calendars and then searches for the calendar entries in the next 50 days and displays the next 4-5 events till the screen switches to the next app. I use python and PILLOW to generate the WEBP format and then use pixlet to pubslih. Coding is a bit ugly did not have the time to clean it up yet. Let me know if you have questions.

I use a jupyter notebook that is executed every 15 min - and then execute it with CRON from the server with the background option.



import requests
from datetime import datetime, timedelta


calendarlink=['https://calendar.google.com/calendar/ical/<your ICAL URL here>/basic.ics',
              'https://calendar.google.com/calendar/ical/<your second CAL URL here /basic.ics'
             ]

calendarentry = []

for cal in calendarlink: 
        message = "" 
        response = requests.get(cal)
        calendarsplit = response.text.split('BEGIN:VEVENT')
        #print(response.text)
        calendarname =  calendarsplit[0][calendarsplit[0].find('X-WR-CALNAME:')+13:calendarsplit[0].find('\n',calendarsplit[0].find('X-WR-CALNAME:')+13)-1]
        
        print("*************************************************")
        print("<"+calendarname+">")
        for event in calendarsplit:
            datestart = event[event.find('DTSTART:')+8:event.find('\n', event.find('DTSTART:')+8)]
            summary = event[event.find('SUMMARY:')+8:event.find('\n', event.find('SUMMARY:')+8)]
            if (datestart.find("VALUE=DATE") > 0):
                datestart = datestart[datestart.find("VALUE=DATE:"):datestart.find("VALUE=DATE:")+8]
            else: 
                datestart = datestart[0:8]
            von = event[event.find('DTSTART:')+17:event.find('\n', event.find('DTSTART:')+17)-4]
            bis = event[event.find('DTEND:')+15:event.find('\n', event.find('DTEND:')+14)-4]
    
    #print(summary)
            try: 
                dateformat = datetime.strptime(datestart, '%Y%m%d')
        #print(dateformat)
        #print(datetime.now()+timedelta(days=50))
                if(dateformat > datetime.now() and dateformat < (datetime.now()+timedelta(days=50))):
                     
                     print(calendarname + ":" + datestart[6:8] + "." + datestart[4:6], end='')
                     print(": " + summary)
                     timestr= (von[0:2]+":"+von[2:4] + "-" + bis[0:2]+":"+bis[2:4])
                     calendarentry.append({"Sortkey":datestart, "Name":calendarname, "Date":(datestart[6:8] + "." + datestart[4:6]), "Summary":summary, "Time":timestr} )
          #print("=========") 
          #print ("in next 50 days")
            except: 
                pass 
            
calendarentry.sort(key=lambda x: x["Sortkey"])      

#Second Cell in Notebook  

import os
from PIL import Image, ImageDraw, BdfFontFile, ImageFont
from datetime import datetime, timedelta

images = []
width = 32

f="/home/pixlet/build/pixlet/fonts/tb-8.bdf"

fp = open(f, "rb")
p = BdfFontFile.BdfFontFile(fp)
p.save(f)
font1 = ImageFont.load("/home/pixlet/build/pixlet/fonts/tb-8.pil")


for i in calendarentry:
  (x, y) = font1.getsize(i["Summary"], fill='#f0ff', font=font1)
  for j in range(0, x-32):  
    im = Image.new('RGBA', (64, 32), (0,0,0,0))
    draw = ImageDraw.Draw(im)
    
    #draw texbox 
    
    #top of calendar 
    draw.line([(2,2), (12,2)], fill="#f00f", width = 1 )
    draw.line([(2,3), (12,3)], fill="#f00f", width = 1 )
    draw.line([(2,4), (12,4)], fill="#f00f", width = 1 )
    #horizontals 
    draw.line([(2,5), (12,5)], fill="#ffff", width = 1 )
    draw.line([(2,7), (12,7)], fill="#ffff", width = 1 )
    draw.line([(2,9), (12,9)], fill="#ffff", width = 1 )
    draw.line([(2,11), (12,11)], fill="#ffff", width = 1 )
    #verticals
    draw.line([(2,5), (2,11)], fill="#ffff", width = 1 )
    draw.line([(4,5), (4,11)], fill="#ffff", width = 1 )
    draw.line([(6,5), (6,11)], fill="#ffff", width = 1 )
    draw.line([(8,5), (8,11)], fill="#ffff", width = 1 )
    draw.line([(10,5), (10,11)], fill="#ffff", width = 1 )
    draw.line([(12,5), (12,11)], fill="#ffff", width = 1 )
    
    draw.text((15, 4), i["Date"], fill='#f0ff', font=font1)
    
    draw.text((38, 4), i["Name"], fill='#ffff', font=font1)
    
    draw.text((32-j, 14), i["Summary"], fill='#0fff', font=font1)
    
    draw.text((10, 22), i["Time"], fill='#ff0f', font=font1)
    
    
    images.append(im)    

 #save webp format    
images[0].save('calendar.webp', 'webp',
               save_all=True, append_images=images[1:], optimize=False, duration=50, loop=0, quality=100)
 #call shell script to publish using pixlet API 
os.system('sh /home/pixlet/publish.sh calendar')