Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading Text File of Google Calendar Entries
#21
I have this driver working more or less, and wanted to ask more of a programming question.  I have some ideas, but wanted to see if there is something in CML that would make it easier.

The data comes in as a .json file like so:

email1
   Event1 with Name, Start and Stop Date
   Event2 with Name, Start and Stop Date
   ...
email2
   Event1 with Name, Start and Stop Date
   Event2 with Name, Start and Stop Date
   ...

So I can get all of these read into the driver in CQC and successfully populated, but because the .json file is in this order, I can't figure out a good way of having it sorted by start date.  Each individual email has its events sorted by start date, but email2 could have a date earlier than email1, etc.  

I have a few ideas with assigning indexes the first time through, doing the sort, then going through it again using the sort order by date and writing the fields/data to the driver the second time through.

In the end I would like these fields in CQC, sorted by date start:

Event1_Email
Event1_Name
Event1_Start
Event1_End
Event2_EMail
Event2_Name
Event2_Start
Event2_End
...
Just wanted to see if anyone had any ideas to do it better.
Reply
#22
How are you doing the sort. CML doesn't provide any sort functionality, that I can remember. How many e-mails are we talking about?
Dean Roddey
Explorans limites defectum
Reply
#23
Yea, couldn't find anything on sorting.  My thought was to assign an ID to each event which I can do from the Python Script and write it out to the .json file, which can be loaded into CQC.  When the driver reads in the data sequentially from each email address, it would place the ID and date/time start into an array, then sort.  When I build out the driver fields, I could access the array to build it sequentially by the sorted array.

Without a sorting function, I figure I could do multiple passes moving through the JSON file, determining the sort order for each ID.

I have 3 total emails I am interested in, and plan on capturing the first 10 events of each, so a total of 30 events.
Reply
#24
Why not just have the script store it pre-sorted?
Dean Roddey
Explorans limites defectum
Reply
#25
(05-29-2019, 06:09 PM)Dean Roddey Wrote: Why not just have the script store it pre-sorted?

From what I have read, you can't process multiple linked email addresses at the same time with the Google Calendar API, you have to do them sequentially, and with my limited knowledge of Python, not sure exactly how to do that.  I saw a post on StackOverflow a month or so ago, asking for this exact thing but with no replies.  I will keep working both ways and see if I can get a resolution - or just have tabs for the three calendars with the different event listings.
Reply
#26
I finally got this working - I added an index number in each JSON entry for tracking purposes, then loaded the index and Start Date into two Vectors.  Did a simple bubble sort, to get it in the right order, then loaded the data into fields using the order stored in the index vector.  Probably not efficient, but I am only polling this file only a couple of times a day.

I had a question on displaying the data in the IV.  Is there a way where I can change a font color based on a field entry?  Since I have three calendars that are being loaded into the driver, and I am flagging which calendar email addy has which event - just curious is there is a way to display one calendar event with one color font in a Field Widget, and another calendar event with a different color.
Reply
#27
I may be misunderstanding the question, but you can change the color of the text on any widgets. Just select it and use the appropriate color attribute in the attribute editor. Is that what you mean?

Oh, you mean on the fly? You can't do it dynamically, but you could do it when the interface loads in the OnLoad. There's a SetWidgetClr command that all widgets support. Unfortunately that guy doesn't know the 'smart names' of the colors which the editor figures out during editing, so you have to just use Bgn 1, Fgn 2 and so forth.

Do as long as you can figure out in the OnLoad which one it is, you could set the color on that one.
Dean Roddey
Explorans limites defectum
Reply
#28
Thanks, SetWidgetColor works great and is what I was hoping to do.  I now have 3 calendars displayed, and can have each associated email adress show up on the IV in a different color.
Reply
#29
I ended up using both the SetWidgetColor and the LinkToField options so that I can add color to the different calendars, and provide multi-page events (The Driver maxes out at 50, and I display 10 per page) that are controlled with up/down arrows.   I was even able to tie it into the TTS output, so now at 8am - my whole house audio provides the current weather and forecast and now also announces the event(s) of the day.

Is there anyway to conditionally change the format of the Field Time Widget when it starts at 12:00am (which means an all day event), so it doesn't show the time portion, just the date portion, but does show the time if its not an all day event?  I know I could do it by reading each entry as a GVar and reading it, or possibly add states, but thought I would ask before I headed down that fox hole.


Attached Files
.jpg   Calendar.jpg (Size: 46.11 KB / Downloads: 3)
Reply
#30
I can't think of a way right off hand. I could add a command to do that of course, if doing it manually is workable (i.e. not on the fly just because a field changed.)
Dean Roddey
Explorans limites defectum
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Text to Speach Voice George M 2 390 02-10-2022, 10:55 AM
Last Post: George M
  Help with Log File Error karenlee 4 666 10-28-2021, 08:17 AM
Last Post: Dean Roddey
  Underline of Static Text kblagron 1 1,060 03-04-2020, 01:01 PM
Last Post: Dean Roddey
  Generic-Network Monitor - Config File Error gReatAutomation 17 6,588 06-27-2019, 11:46 AM
Last Post: gReatAutomation
  Google Calendar and Web Browser kblagron 4 1,983 04-25-2019, 10:10 PM
Last Post: kblagron
  Is it possible to tie in CQC into a third part calendar to drive schedules ghurty 6 2,259 01-01-2019, 05:30 PM
Last Post: Dean Roddey
  File Tag Repository and .M4A Files kblagron 10 3,878 11-18-2018, 04:40 PM
Last Post: Dean Roddey
  Question on Formatting of Variable Text kblagron 2 2,842 09-07-2018, 08:52 PM
Last Post: kblagron
  Echo Config file issues ghurty 6 4,146 07-08-2018, 07:13 PM
Last Post: ghurty
  Embedded Variable in Text zra 2 2,496 05-07-2018, 09:59 AM
Last Post: zra

Forum Jump:


Users browsing this thread: 1 Guest(s)