Skip to content

Bug Report and Fix: Calendar symbol not applied when broadcasting events #89

@donsenjor

Description

@donsenjor

Bug Report: Calendar symbol not applied when broadcasting events

Module

MMM-GoogleCalendar by randomBrainstormer

Description

When broadcastEvents: true is set and a custom symbol is defined per calendar in the config, the symbol is not transmitted correctly via the CALENDAR_EVENTS notification. Instead, all events receive the default symbol (calendar).

Root Cause

In MMM-GoogleCalendar.js, the broadcastEvents() function (line ~1079) calls symbolsForEvent(event) before assigning event.calendarID:

// Current (buggy) code:
const event = { ...ev };              // ev has no calendarID property
event.symbol = this.symbolsForEvent(event);  // event.calendarID is undefined here!
event.calendarName = this.calendarNameForCalendar(calendarID);
event.color = this.colorForCalendar(calendarID);
delete event.calendarID;

symbolsForEvent() relies on event.calendarID to look up the correct symbol via getCalendarProperty(). Since ev (from this.calendarData[calendarID]) does not contain a calendarID property, the lookup fails and falls back to this.config.defaultSymbol ("calendar").

Fix

Assign event.calendarID before calling symbolsForEvent():

// Fixed code:
const event = { ...ev };
event.calendarID = calendarID;        // ← add this line
event.symbol = this.symbolsForEvent(event);  // now calendarID is available
event.calendarName = this.calendarNameForCalendar(calendarID);
event.color = this.colorForCalendar(calendarID);
delete event.calendarID;

Steps to Reproduce

  1. Configure MMM-GoogleCalendar with broadcastEvents: true
  2. Set a custom symbol per calendar entry (e.g. symbol: "people-group")
  3. Use MMM-MonthlyCalendar (or any module listening to CALENDAR_EVENTS) with displaySymbol: true
  4. Observe that all events show the default calendar symbol instead of the configured one

Expected Behavior

Each event broadcast via CALENDAR_EVENTS should carry the symbol defined for its respective calendar in the config.

Actual Behavior

All events carry the default symbol ("calendar"), regardless of per-calendar symbol configuration.

Environment

  • MagicMirror² latest
  • MMM-GoogleCalendar latest
  • MMM-MonthlyCalendar (consumer of broadcast)
  • Raspberry Pi, Node.js

Suggested Fix

One-line fix in MMM-GoogleCalendar.js in the broadcastEvents() function:

event.calendarID = calendarID;

Add this line before event.symbol = this.symbolsForEvent(event);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions