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!

1 Like

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.

2 Likes

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')

For folks who might want to run this at home, I made up a repo with the script I’m running for my own. Very much 1.0 here – the font I’m using is pretty teeny, and I’m trying to figure out whether/how to use a bigger one – but it works. https://github.com/adamehirsch/tidbyt-icalendar

This is kind of a deal breaker for me. I have multiple calendars that I want to show events on my Tidbyt, but also several other calendars that I don’t want appearing. I need a way to choose which Calendars to show on the Tidbyt. As it stands it is not working at all right now - I’m not seeing ANY events show up.

Adam, thanks for creating this. Would you would mind sharing an example screenshot of the end result sent to the Tidbyt? I’m considering setting up your solution but wasn’t sure if it will do what I need, so want to know what it looks like before I try and figure out how how to set it up! (It might be helpful to add a screenshot to the Github readme as well.)

This is the #1 thing that I need. This would also allow Tidbyt to support any arbitrary ical:// calendar since you can import those into Google Calendar.

2 Likes

Super important, since I have a calendar shared with my Google account that I use a lot

Does anyone have the source code for the existing Tidbyt Google Calendar app. There should be a quick fix to select all calendars in the connected Google account…

1 Like

just got my tidbyt yesterday and came here to say the need to select specific google calendars is SO important. definitely want to show my shared calendar with my girlfriend and not my default personal one. i have no tech skills at all so i have no clue how to run those custom programs to get it to work on my own, but someone really needs to update the calendar app to allow selection of specific calendars

4 Likes

Without this feature, the entire reason I bought a Tidbyt isn’t possible. This is a quick API update. Please fix ASAP!

Not sure what to do here. I started this thread in December of last year and the thread says it is going auto-close in a month. I see 41 votes for it as a feature request, but a solution hasn’t been developed nor has it been recognized by tidbyt before it falls off into an archive.

Unfortunately while the code for this is pretty straightforward, getting approval from Google to access additional calendars or use any of their new API’s is a process. We are working on it and going back & forth with them to get the access we need.

4 Likes

Belatedly, I wound up skipping using the Google API in favor of just reading the private iCal feed of the calendars of mine I wanted to access – here’s how to get at that URL in the Google Calendar settings interface

Do you use a different Tidbyt app to display and iCal feed?

I do! I’m using some python code I wrote to read an iCal feed and do a couple of tricks with it – one’s a text listing and one is a week’s worth of free-busy blocks.

The text listing is in grab_events.py and the free-busy blocks are in draw_freebusy.py – I am overdue to update the docs there.

This topic was automatically closed after 365 days. New replies are no longer allowed.