Help! - Update string variable to show the next event from a list by date

Does anyone have an app or an idea how I could achieve this. I specifically want to have a string variable that is updated automatically to display text for the next event (chronologically) from a list. This could be used for birthdays/memorable (or not so!) dates, sporting calendar etc. I'm sure someone must have written something like that. If there was some code where I could amend a list and dates to suit my needs, I could edit that.

My use case is to show the upcoming sports. As I'm in the UK options such as Gametime and others are irrelevant as they won't show what I'm looking for. I want to display the next game for the 'Mighty Boro' (Middlesbrough FC) I'd like to input a list of dates with corresponding text that should be displayed in the variable (date - event description) The app/code should show the next event in the variable and as soon as the calendar passes to the day after that event, it should update the variable to the next event and so on (maybe completing with 'end of season' following the last event)

I'm hoping there's a simple way of doing this (I can't code but could easily update dates/events within existing code) as otherwise I'll have to use RM as I have in the below, ridiculously complicated (but fully working) rule I set up to show the next Moto GP/World Superbikes event. The rule updates a hub variable which is what I want. There might be a simpler way of doing that rule. Any help appreciated:

Currently the only apps I remember having some functionality like this are calendar based ([RELEASE] Google Calendar, Task, and Reminder Search, [RELEASE] gCalendar Driver - Display working Google Calendars on HE Dashboards, etc.), but if those don’t work for you it wouldn’t be too hard* to write a custom app that would allow you to either paste a formatted list into an input area, or read it from a file that you’d upload via File Manager.

*I could probably write it in an hour or so on Monday if you don’t find another solution…

4 Likes

Thanks @thebearmay :grinning: - if there's nothing that currently does it your help would really be appreciated. Key for me is that I can pick my hub variable for the resulting display. In the RM example I screenshot, I have a connector on the hub variable so that I can add that variable to my dashboards (SharpTools and Hubitat Dashboard)

I'd thought that if I could have gotten app code that had a couple of random dates and events already populated in it with the functionality to update a variable, I could maybe have replaced the example dates, events, variable name with my own (paste in my own info in the code and just duplicate the app if I needed additional instances) But any method would be great if it avoids me doing another RM instance with about 50 conditions in!

50+ conditions is a little more than I’d like to tackle in a rule. This could also be written as a virtual device if the desired result is a device to display on a dashboard (assuming Sharptools requires the connector and doesn’t read the hub variable directly).

1 Like

As someone who commits to too many projects without finishing those that have come before, I will only offer suggestions.... :slight_smile:

It would be nice if there were calendar drivers / apps that produced a common format stored either in a device or in a local file. So different drivers could read from Google, Apple, Outlook, etc, producing a consistent output that could be consumed by separate drivers / apps that could consume the data and either display the events on a dashboard or use them in a rule.

2 Likes

Yeah I think the preference for me is to get things to display in a variable if possible. The hub variable does need a connector for SharpTools or Hubitat Dashboard for Android but I'm fine with that. If I add a hub variable tile to either app, the correct display of it is guaranteed, whereas With a virtual device I'd be relying on the apps to display it how I want.

Fair enough. See if https://raw.githubusercontent.com/thebearmay/hubitat/main/dlyReminder.groovy
will do the trick.

App expects that you will load a date (multiple formats available) sorted text file* to the hub, supply it with the name of the file and a hub variable, and press the Load File and Start Daily Processing button. When you have done that the app will read the file and find either the current or next day's record, and set the variable according to the preferences you've selected. In addition it will schedule a job to run at 00:05 every day to reprocess your text file.

* record format should have the date, a space, the message to be displayed and be terminated by a line feed.
image

2 Likes

Wow :star_struck: thanks so much @thebearmay! I’ll give that a whirl first thing in the morning.

1 Like

I've just given that a try and it looks to do exactly what I want, thanks so much!

For me to do a fixture list in Rule Machine with all of the conditions could easily take over an hour (it probably took me twice that to work out and do the one I posted) and if a date changed it was a pain to edit. With your app it'll take just 5 mins to type out the .txt in notepad and upload it to File Manager. Additionally if a date in the list/calendar changes, I can simply amend and replace the text file. The ability to rename each instance in the app is great as I can keep them organised in the apps list.

It would be worth putting the app in HPM. I can't be alone in needing this for dashboards - this is so useful for those of us who don't want to integrate with a calendar to add specific dates - birthdays, holidays, sports etc....

2 Likes

I think so.... It could even be expanded upon, essentially acting as a reminder utility, whether that be for Calendar initiated reminders, or whatever source may be. Could potentially be used by apps to trigger reminders off the back of events like doors being left open, you could change targets to be a variable or notifications device, etc.... But I'm probably jumping too far ahead.... :slight_smile:

1 Like

Yup. I've just managed to set this up with list of every Middlesbrough game for the coming season. Time taken - around 5 minutes...

2 Likes

I’ll probably do that today, along with a release thread to track questions, etc.

Notification devices, virtual switches, possibly an http POST to an app endpoint with a JSON payload, destinations are easy adds…

Right now I force the date (dd MMM) to the front of the note, can make that optional or add formatting options. From a semi-calendaring perspective, a little more involved but it wouldn’t be too hard to add some options for creating a recurring event or possibly times to kick off notices (maybe a child app with a cron string for anything other than an annual recurrence).

1 Like

Looking at it again, what I added doesn't quite fit with the original request. Showing the next event in the future is different to having reminders of calendar entries. The first option can be on display at any time, showing an event that might be 2-3 weeks in the future, there on display whenever you want to look at it. A reminder is more like an event in it's own right to make you aware of something at a time when you may need to know.

I guess what I'm getting at is that they feel like two separate aps / drivers, mixing them may complicate things unnecessarily. Don't get me wrong, both useful and worth developing, but they may be better off separated.

As an example, I was literally setting this exact same thing up last night in my Google Calendar for the last half dozen or so games for our Rugby League season (I'm a struggling Knights fan...). I setup two styles of reminder, one at the beginning of the day as a kind of "it's game day" type reminder, plus a second reminder a few hours before. I had thought about setting something up at the beginning of each week, but decided I'd leave that for something I could construct in HE. It feels like the work done here could satisfy that need. In terms of reminders, or the same event I might want 2-3 reminders, one similar to the "when's the next game", requested here, plus some that are meant to elicit some response, to get ready for the game based on the event start time and whatever offset I may want, which may vary.

I should probably stop hogging the topic.... :slight_smile: Just my thoughts....

What's already been done fits great for me. The idea to be able to adjust the format of the displayed date is also a good idea. Alternatively - as a short format has to be selected in the app that matches what precedes the text to display, it would work equally well to just display the entire entry including the preceding date as is from the .txt file (a few more short date options would be needed for uk users ddmmyy etc)

Future events is exactly as I need it as it's a permanent 'up next' tile on my dashboard - once one passes, display the next. I could see how it wouldn't fit perfectly for an event that is more than one day - as at 00:05 it would bring up the next event in the list. This would be the case for my World Superbikes calendar where the races are on Saturday and Sunday. It's easy enough for me just to duplicate the event in the text file with the second day.

Release thread up at: [Release] Daily Reminder

2 Likes