From db658555af0c8a1b3bdc398f128105b1ff9c629b Mon Sep 17 00:00:00 2001 From: Robert Ison Date: Mon, 23 Mar 2026 23:17:37 -0400 Subject: [PATCH 1/3] Remove test data, add zone number to display, better check for current action, update display for 'today' instead of date when status is current day, explicitly explain what type of skip, clean up icon to look sharper on a Tidbyt --- apps/rachio/images/rachio_icon.png | Bin 655 -> 652 bytes apps/rachio/rachio.star | 133 ++++++++++++++++------------- 2 files changed, 75 insertions(+), 58 deletions(-) diff --git a/apps/rachio/images/rachio_icon.png b/apps/rachio/images/rachio_icon.png index 89d54fc9ed18365586c02cae6ff834a9ec6f288b..89dc07a5ae22c261e3e5f6a39c2fc316f4e9c784 100644 GIT binary patch delta 508 zcmVCNtad~V0005dNkl&|Yj zwHmt^8yd3)6+@7OQ*MjVJv^u@U#!}uNnvSVS)end3%-5_!2F}d+aF0h&XPHT6J zYgfA^Q}9sV;uaJVj{3Q)t6gMBRBj^$Q*8cH(_CH9z0~ zK;L$PZQH6Jq>ayclvn^sma0Q4LM;MhUfpFkzgnL_pIAVjSRmMQhSZf4*cE4n&6(%! y*n17HG{1yT^%F|$?}S|`v%9(GIcVvy>%0do7?ZDEarpTF0000Jwgy1sfOBF;%{2cMSPbp44@qD%mOY~ld zlDKx#SO3?EEPq0Td)fT*277f8Ywl(J z!7do+14C3dipT+#U}}J0uSXHauX&Z6O+Z)B;`N 0 - - if (not show_recent_events): + if not show_recent_events: if skip_when_empty: return [] - else: - return display_error_screen(now, "No Events within a week.", "", delay, screen_width, font_height, font, font_width, icon_width) - - # whew, made it with at least one event to display - - #do we have any current events? + return display_error_screen(now, "No Events within a week.", "", delay, screen_width, font_height, font, font_width, icon_width) + + # 2. Get our main event data + latest_event = recent_events[len(recent_events) - 1] + readable_date = time.from_timestamp(int(int(latest_event["eventDate"]) / 1000.0)).in_location(tz) + + # 3. Handle the "Stale" logic (Stop showing 'Current' if it's been > 3 hours) + time_since_event = now - readable_date + is_stale = time_since_event > time.parse_duration("3h") + show_current_events = current_events != None and len(current_events) > 0 + if is_stale or (latest_event["type"] == SCHED_STOP): + show_current_events = False + + # 4. Handle "Today" vs Date logic + is_today = (readable_date.year == now.year and + readable_date.month == now.month and + readable_date.day == now.day) + + preface = "Current" if show_current_events else "Last" + + line_1 = device_name if show_device_name else "Rachio" + line_2 = readable_date.format("Today at 3:04 PM") if is_today else readable_date.format("Mon, Jan 2 at 3:04 PM") + line_3 = "%s: %s (%s)" % (preface, latest_event["display_type"], readable_date.format("3:04 PM")) + line_4 = "" - if show_recent_events: - latest_event = recent_events[len(recent_events) - 1] - - #this current event is only relevant if the latest_event - if (latest_event["type"] and latest_event["type"] == SCHED_STOP): - show_current_events = False - - preface = "Last" - if show_current_events: - preface = "Current" - - readable_date = time.from_timestamp(int(int(latest_event["eventDate"]) / 1000.0)).in_location(tz) - line_2 = readable_date.format("Mon Jan 2 at 3:04 PM") - line_3 = "%s: %s - %s" % (preface, latest_event["summary"], readable_date.format("Mon Jan 2 at 3:04 PM")) - + # 5. Add Zone details if something is currently running if show_current_events: current_event = current_events[len(current_events) - 1] display = current_event["summary"].strip() if len(display) > 0: - display = "Zone: %s" % display - - if line_3 == "": - line_3 = display - else: - line_4 = display - + line_4 = "Zone %d: %s" % (current_event.get("zoneNumber", 0), display) return render.Root( render.Column( children = [ @@ -238,6 +233,14 @@ def get_events(deviceId, api_key, start, end): return event_response.json() def get_selected_events(tz, events, current): + SUBTYPE_MAP = { + "WEATHER_INTELLIGENCE_SKIP": "Rain Skip", + "WEATHER_INTELLIGENCE_CLIMATE_SKIP": "Soil Saturation Skip", + "WEATHER_INTELLIGENCE_FREEZE_SKIP": "Freeze Skip", + "SCHEDULE_STARTED": "Started", + "SCHEDULE_COMPLETED": "Finished", + } + selected_sub_types = [] if current: selected_sub_types = [ZONE_STARTED] @@ -245,13 +248,27 @@ def get_selected_events(tz, events, current): selected_sub_types = [SCHED_START, SCHED_STOP, WEATHER_SKIP, WEATHER_CLIMATE_SKIP] selected_events = [] + for event in events: - if "subType" in event.keys(): - if event["subType"] in selected_sub_types: - eventDateSecs = time.from_timestamp(int(event["eventDate"] / 1000)).in_location(tz) - parsedDate = eventDateSecs.format("Monday 03:04PM") - newEvent = dict(type = event["subType"], date = parsedDate, summary = event["summary"], eventDate = event["eventDate"]) - selected_events.append(newEvent) + # .get() returns None if the key doesn't exist, preventing a crash + sub_type = event.get("subType") + + # Now check if the sub_type is one we care about + if sub_type in selected_sub_types: + eventDateSecs = time.from_timestamp(int(event["eventDate"] / 1000)).in_location(tz) + parsedDate = eventDateSecs.format("Monday 03:04PM") + display_name = SUBTYPE_MAP.get(sub_type, sub_type) + + # Create the dictionary and append + newEvent = dict( + type = sub_type, + display_type = display_name, + date = parsedDate, + summary = event.get("summary", ""), + eventDate = event["eventDate"], + zoneNumber = event.get("zoneNumber", 0), + ) + selected_events.append(newEvent) return selected_events From 48210a87107ebe4325a32ccbe9c38d925af7a741 Mon Sep 17 00:00:00 2001 From: Robert Ison Date: Mon, 23 Mar 2026 23:18:11 -0400 Subject: [PATCH 2/3] Lint/Format fixes --- apps/rachio/rachio.star | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/rachio/rachio.star b/apps/rachio/rachio.star index 6a2282cf0..a62d0402c 100644 --- a/apps/rachio/rachio.star +++ b/apps/rachio/rachio.star @@ -147,7 +147,7 @@ def display_error_screen(time, line_3, line_4 = "", delay = 45, screen_width = 6 def render_rachio(tz, config, device_name, recent_events, current_events, now, delay, skip_when_empty = True, screen_width = 64, icon_width = 16, font_height = 8, font_width = 5, font = "5x8"): show_device_name = config.bool("title_display", True) - + # 1. Check if we even have events show_recent_events = recent_events != None and len(recent_events) > 0 if not show_recent_events: @@ -158,22 +158,22 @@ def render_rachio(tz, config, device_name, recent_events, current_events, now, d # 2. Get our main event data latest_event = recent_events[len(recent_events) - 1] readable_date = time.from_timestamp(int(int(latest_event["eventDate"]) / 1000.0)).in_location(tz) - + # 3. Handle the "Stale" logic (Stop showing 'Current' if it's been > 3 hours) time_since_event = now - readable_date is_stale = time_since_event > time.parse_duration("3h") - + show_current_events = current_events != None and len(current_events) > 0 if is_stale or (latest_event["type"] == SCHED_STOP): show_current_events = False # 4. Handle "Today" vs Date logic - is_today = (readable_date.year == now.year and - readable_date.month == now.month and + is_today = (readable_date.year == now.year and + readable_date.month == now.month and readable_date.day == now.day) - + preface = "Current" if show_current_events else "Last" - + line_1 = device_name if show_device_name else "Rachio" line_2 = readable_date.format("Today at 3:04 PM") if is_today else readable_date.format("Mon, Jan 2 at 3:04 PM") line_3 = "%s: %s (%s)" % (preface, latest_event["display_type"], readable_date.format("3:04 PM")) From b03e2d43fb4861fd7bf98c68b2cb83e1eeeb469c Mon Sep 17 00:00:00 2001 From: Robert J Ison Date: Tue, 24 Mar 2026 10:22:45 -0400 Subject: [PATCH 3/3] Update apps/rachio/rachio.star Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- apps/rachio/rachio.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/rachio/rachio.star b/apps/rachio/rachio.star index a62d0402c..b249f7832 100644 --- a/apps/rachio/rachio.star +++ b/apps/rachio/rachio.star @@ -57,7 +57,7 @@ def main(config): if (not devices or selected_device == None or selected_device == ""): if not devices: # No device selected, and no device available from the list, send an error - return display_error_screen(now, "No devices found.", "Check API key and device selection", delay, screen_width, font_height, font, font_width, icon_width) + return display_error_screen(now, "No devices found.", "Check API key and device selection", delay, screen_width, font_height, font, font_width) else: selected_device = devices[0]["id"]