# ============================================================================== # FAMILY CALENDAR BACKEND PACKAGE # ============================================================================== # INSTRUCTIONS: # 1. Place this file in your /config/packages/ folder. # 2. Ensure your configuration.yaml has: # homeassistant: # packages: !include_dir_named packages # 3. RESTART Home Assistant. # ============================================================================== # 1. HELPERS (The Variables) input_text: # Filter Toggles (RegEx: .* = Show, ^$ = Hide) alice_calendar_filter: name: Alice Filter initial: ".*" bob_calendar_filter: name: Bob Filter initial: ".*" charlie_calendar_filter: name: Charlie Filter initial: ".*" daisy_calendar_filter: name: Daisy Filter initial: ".*" family_calendar_filter: name: Family Filter initial: ".*" birthdays_calendar_filter: name: Birthdays Filter initial: ".*" holidays_calendar_filter: name: Holidays Filter initial: ".*" # Event Form Data calendar_event_title: name: Event Title icon: mdi:format-title calendar_event_description: name: Event Description icon: mdi:text input_select: # The dropdown list for "Who is this event for?" calendar_select: name: Select Calendar options: - Alice - Bob - Charlie - Daisy - Family icon: mdi:calendar-check # The View selector (Week, Month, etc) calendar_view: name: Calendar View options: - Today - Tomorrow - Week - Biweek - Month initial: Week input_datetime: # Event start/end times calendar_event_start: has_date: true has_time: true calendar_event_end: has_date: true has_time: true calendar_day_event_start: has_date: true has_time: false calendar_day_event_end: has_date: true has_time: false input_boolean: # UI Toggles calendar_all_day_event: name: All Day Event icon: mdi:calendar-clock family_calendar_show: name: Show Family Calendar # 2. SCRIPTS (The Logic) script: # --- Filter Toggles --- alice_calendar_visible_filter: alias: Toggle Alice Calendar sequence: - action: input_text.set_value target: entity_id: input_text.alice_calendar_filter data: value: > {% if is_state('input_text.alice_calendar_filter', '.*') %} ^$ {% else %} .* {% endif %} bob_calendar_visible_filter: alias: Toggle Bob Calendar sequence: - action: input_text.set_value target: entity_id: input_text.bob_calendar_filter data: value: > {% if is_state('input_text.bob_calendar_filter', '.*') %} ^$ {% else %} .* {% endif %} charlie_calendar_visible_filter: alias: Toggle Charlie Calendar sequence: - action: input_text.set_value target: entity_id: input_text.charlie_calendar_filter data: value: > {% if is_state('input_text.charlie_calendar_filter', '.*') %} ^$ {% else %} .* {% endif %} daisy_calendar_visible_filter: alias: Toggle Daisy Calendar sequence: - action: input_text.set_value target: entity_id: input_text.daisy_calendar_filter data: value: > {% if is_state('input_text.daisy_calendar_filter', '.*') %} ^$ {% else %} .* {% endif %} family_calendar_visible_filter: alias: Toggle Family Calendar sequence: - action: input_text.set_value target: entity_id: input_text.family_calendar_filter data: value: > {% if is_state('input_text.family_calendar_filter', '.*') %} ^$ {% else %} .* {% endif %} birthdays_calendar_visible_filter: alias: Toggle Birthdays Calendar sequence: - action: input_text.set_value target: entity_id: input_text.birthdays_calendar_filter data: value: > {% if is_state('input_text.birthdays_calendar_filter', '.*') %} ^$ {% else %} .* {% endif %} holidays_calendar_visible_filter: alias: Toggle Holidays Calendar sequence: - action: input_text.set_value target: entity_id: input_text.holidays_calendar_filter data: value: > {% if is_state('input_text.holidays_calendar_filter', '.*') %} ^$ {% else %} .* {% endif %} # --- Add Event Logic --- add_google_calendar_event: alias: Process Add Calendar Event sequence: - variables: # ==================================================================== # CONFIGURATION: ENTITY MAPPING # Map the Dropdown Name (Left) to your Entity ID (Right). # ==================================================================== calendar_map: "Alice": "calendar.alice" "Bob": "calendar.bob" "Charlie": "calendar.charlie" "Daisy": "calendar.daisy" "Family": "calendar.family" # Selects the entity based on the map above target_calendar: "{{ calendar_map.get(states('input_select.calendar_select'), 'calendar.family') }}" - choose: # Scenario A: All Day Event - conditions: - condition: state entity_id: input_boolean.calendar_all_day_event state: "on" sequence: - action: calendar.create_event target: entity_id: "{{ target_calendar }}" data: summary: "{{ states('input_text.calendar_event_title') }}" description: "{{ states('input_text.calendar_event_description') }}" start_date: "{{ states('input_datetime.calendar_day_event_start') }}" end_date: "{{ states('input_datetime.calendar_day_event_end') }}" # Scenario B: Timed Event - conditions: - condition: state entity_id: input_boolean.calendar_all_day_event state: "off" sequence: - action: calendar.create_event target: entity_id: "{{ target_calendar }}" data: summary: "{{ states('input_text.calendar_event_title') }}" description: "{{ states('input_text.calendar_event_description') }}" start_date_time: "{{ states('input_datetime.calendar_event_start') }}" end_date_time: "{{ states('input_datetime.calendar_event_end') }}" # Cleanup and Close - action: input_text.set_value target: entity_id: input_text.calendar_event_title data: value: "" - action: input_text.set_value target: entity_id: input_text.calendar_event_description data: value: "" - action: browser_mod.close_popup data: {}