How to create event in Local Calendar

Hello everyone,
I’m so happy that the create_event service is available.
I see a very useful option but I cannot figure how to use it.

The option is “in” and the documentation indicates :

in — days or weeks that you want to create the event in. — “days”: 2 or “weeks”: 2

I try whitout succes :

data: 
  summary: "blabla" 
  in: "days: 2"

or

data: 
  summary: "blabla" 
  in: ""days": 2"

or

data: 
  summary: "blabla" 
  in_days: 2

Does somebody succed in using the “in” yaml option?
Thanks

Here is the link to the create_event documentation

Edit :
I found the solution, it was:

data: 
  summary: "blabla" 
  in:
    days: 2
1 Like

Hey, I can’t seem to find this button?

Neither on my phone, nor on my desktop.

I don’t see any calendars either in the Dev Tools service call:

Even though they do exist, and I see actual entries in the calendar:

Hey Allen,

Thanks for getting the create-event service working a while back!

I was wondering if you knew if there was a way to ‘copy’ the functionality of the button in the sidebar calendar to my dashboard? I assume that button pops up a card with entry fields, then the event is created using the create_event service, but I didn’t really want to take a day or two of trial and error getting something like that working since it already exists, just on a different page…!

Thanks,
Matthew

Hi, not totally sure I understand what you have in mind, but not I don’t think there is any existing code to create events elsewhere in the UI

Ok thanks.
I was hoping the " + Add Event " button (in the calendar sidebar screen) might call a service/script that opens the pop-up, so I could link it to another button on another dashboard. It sounds like the button’s action might not work the same way as a button element though.

Thanks for replying though, I appreciate it.

I still don’t understand the big picture of what you are trying to accomplish, nor the specifics of what you are asking. But if you want to make a custom card to call websocket APIs, that is a thing that exists.

Thanks for persisting with me!
The screenshot is from the calendar page in the sidebar/menu. It is the default HA calendar. I want a button on another page that opens an identical pop-up, but it sounds like I have to build it. I know I can use calendar.create_event to add the event, once I have the details available in the pop-up.
I’ll make a button to open my own form I’ll build to gather the necessary event information, like the default pop-up form does, then call calendar.create_event. I was just looking for shortcuts :slight_smile:

Thanks.

For others in the same boat as @mattat - here’s some yaml for a create calendar form. You’ll need to create the input fields. I use the o365 plugin (i know it’s recently been split apart, I must update) but this is what i’m doing with button-card & browser_mod. Note - I had this in a popup but it caused issue with the date pickers.

type: vertical-stack
cards:
  - type: entities
    title: New Event
    entities:
      - entity: input_text.newevent_name
        name: Name
      - entity: input_text.newevent_description
        name: Description
      - entity: input_datetime.newevent_startdate
        name: Start Date
      - entity: input_datetime.newevent_enddate
        name: End Date
      - entity: input_boolean.newevent_allday
        name: All Day Event?
      - entity: input_text.newevent_location
        name: Location
    show_header_toggle: false
    state_color: false
  - type: custom:button-card
    icon: mdi:calendar-alert-outline
    show_icon: false
    name: Create Event
    styles:
      card:
        - margin: 0
        - padding: 0
      grid:
        - grid-template-areas: "\"i n\""
        - grid-template-columns: min-content 1fr
        - grid-template-rows: min-content min-content
      name:
        - align-self: center
        - font-weight: normal
        - margin: 10px
        - justify-self: center
      icon:
        - align-self: center
        - margin: 10px
        - width: 25px
        - height: 25px
    tap_action:
      action: fire-dom-event
      browser_mod:
        service: browser_mod.popup
        data:
          title: Confirm adding event
          content: Are you sure you wish to add this new event to the family calendar.
          right_button: "Yes"
          left_button: "No"
          right_button_action:
            service: script.create_calendar_event
          left_button_action:
            service: browser_mod.popup
            data:
              title: Operation cancelled.
              dismissable: false
              timeout: 500

and the script

alias: Create Calendar Event
fields:
  subject:
    name: Event Subject
    description: The summary or title for the calendar event
  body:
    name: Event Body
    description: The description for the calendar event
  location:
    name: Event Location
    description: The location for the calendar event
  start:
    name: Start Date
    description: The date & time the calendar event should start
  end:
    name: End Date
    description: The end time of the calendar event
sequence:
  - target:
      entity_id: calendar.your_calendar
    data:
      is_all_day: "{{ is_state('input_boolean.newevent_allday', 'on') }}"
      start: >
        {% set _start = states('input_datetime.newevent_startdate')|as_datetime
        %}   {% set x = _start.strftime("%Y-%m-%dT%H:%M:%S") %}   {{ x }}
      end: >
        {% set _start = states('input_datetime.newevent_startdate')|as_datetime
        %} {% set _end = states('input_datetime.newevent_enddate')|as_datetime
        %}  {% if (_end > _start) %}
          {% set x = _end.strftime("%Y-%m-%dT%H:%M:%S") %} 
          {{ x }}      
        {% else %}
          {% set _end = _start+timedelta(minutes=30) %}
          {% set x = _end.strftime("%Y-%m-%dT%H:%M:%S") %} 
          {{ x }}      
        {% endif %}
      subject: "{{ states('input_text.newevent_name') }}"
      body: "{{ states('input_text.newevent_description') }}"
      location: "{{ states('input_text.newevent_location') }}"
    action: o365.create_calendar_event
  - target:
      entity_id: input_boolean.newevent_allday
    data: {}
    action: input_boolean.turn_off
  - target:
      entity_id: input_text.newevent_name
    data:
      value: ""
    action: input_text.set_value
  - target:
      entity_id: input_text.newevent_description
    data:
      value: ""
    action: input_text.set_value
  - target:
      entity_id: input_text.newevent_location
    data:
      value: ""
    action: input_text.set_value
  - target:
      entity_id: input_datetime.newevent_startdate
    data:
      datetime: "{{ now() }}"
    action: input_datetime.set_datetime
  - target:
      entity_id: input_datetime.newevent_enddate
    data:
      datetime: "{{ now()+timedelta(minutes=30) }}"
    action: input_datetime.set_datetime
mode: queued
icon: mdi:calendar-edit
4 Likes

@iamdabe, thanks for posting. I’d managed to come up with a form that looks very much like yours, but you saved me some script writing time :slight_smile:, but I also had a dropdown to select the calendar to add it to (which I couldn’t add an entity to so need to hard code the options->entity map.

Is your New Event card simply a card on a dashboard? I had started building mine as a pop-up using browser_mod.popup, but found that the popup was replaced with the date selector, and then didn’t come back [EDIT: oh, just saw your releated comment] (I’ve only tested it in the browser mod menu section, not on a real dashboard, so maybe it will work in productions., but probably not)… so I was thinking of different ways to select the date. Clicking on a calendar day (as the crate event button) was one approach, but I’d be limited to days currently on my view… [EDIT 2: just looked into an expanding section to hide the form until the crete event buttoin is pressed. I haven’t read the details, but if I can expand it programatically it may be what I’m looking for!]

Thanks for your input. It is great to see someone has the essential functions working!

Even if I click the calendar View in the sidebar, there’s no “Add event” button anywhere, so I’m stuck until someone tells me how to solve this.

Before you can “Add event” you have to “Create calendar”. Did you click on “Create calendar”?

I already had a calendar and I assumed I could create events in it, but obviously not as it was a national holiday calendar.

Hi, thanks for the code. I was in the same boat as you too! :slight_smile:
Could you also help me create the input fields? can I do it from config.yaml? Do they have to have any particular requirements? Thanks

Apologies for the slow reply. I actually created mine via the UI. (apparently the preferred way of doing things!)

Settings > Devices & services > Helpers. Click the type (input boolean = toggle, input datetime = date and/or time, input text = text)

so am i right in thinking that there’s no way to add a “add event” button to a calendar in a card that is being displayed on a dashboard? I’m trying to make an intuitive system that my wife will engage with and if she has to go off onto different screens etc, i think it just won’t happen.

Hi all - Need help please. I’m getting this error when testing the script - Error in describing action: Cannot read properties of undefined (reading ‘create_event’). What am I missing please? -

Error running action
Action o365.create_event not found

Have you figured this out. I am on the same journey and was surprised that it is not easily able to be done.

Oh happy days! This has been automatically added, I think as a feature in 2026.2. I use the regular calendar card with my google calendars, and noticed an “Add Event” button (“Legg til hendelse” in norwegean) today on the card today. Shows a dialogue popup with the usual fields, works great. Also, It seems I can also delete, but not edit, events.