Lovelace Google Calendar

I second this request for information/modification.

It looks like we are using a similar theme and mine looks terrible as well.

Hey,

I started to get this error after I updated to the latest 0.86.2

2019-01-27 00:13:14 ERROR (MainThread) [frontend.js.latest.201901211] http://192.168.1.20:8123/local/custom_ui/calendar-card/calendar-card.js?v=1.0.1:10:7 Uncaught ReferenceError: moment is not defined

Anyone else experiencing this or know how to solve it?
The Calendar doesn’t show up anymore.

@rdehuyss is it something you also experience?

I have the same thing happening.

I am currently on 0.86.2 0.86.3 and have no issues, but I place no version after my import. So I just added the following in my Raw Edittor:

resources:

I like this plugin a lot, so big thanks to the creator!

Has anyone been able to add the months? Having only the date without the month is a bit confusing sometimes (I show 31 days, so if the month is shorter and an item is on the 1st one but there nothing else that month it would cause me to show up a month early on an appointment :wink: )
Colors for different calendars would also be usefull

Did you just place the calendar-card in the local folder and not in: \www\custom_ui\calendar-card ?

I placed it in the www folder, but not in a custom_ui folder below that. so for me it is just www/js file.

I still get the error. But do you have the calendar card on your front page or do you have it on one of the other tabs?

For me it is on my front page, but I tried adding it to another tab to see if that would cause an issue and it also works fine.

My code for my entity:

type: ‘custom:calendar-card’
numberOfDays: 31
showProgressBar: false
entities:

  • calendar.mycalendarID
  • calendar.contacts
  • calendar.feestdagen_in_belgie

Really weird… I tried adding your settings, but still the same:

Here is the top of my lovelace file (raw editior):

resources:
  - type: js
    url: 'https://unpkg.com/[email protected]/moment.js'
  - type: module
    url: /local/custom_ui/calendar-card/calendar-card.js?v=1.0.1
  - type: js
    url: /local/tracker-card.js?v=0.1.5
  - type: js
    url: /local/custom_ui/weather-card.js
  - type: module
    url: /local/mini-media-player-bundle.js?v=0.9.8
  - type: js
    url: /local/card-tools.js?v=445b68
  - type: js
    url: /local/card-tools.js?v=445b68

Here is the card-details (keep in mind it is inside a vertical-card):

cards:
  - entities:
      - sensor.date_time
      - sun.sun
      - sensor.xxxx
      - sensor.xxxx
    show_header_toggle: false
    title: Information
    type: entities
  - entities:
      - calendar.1
      - calendar.2
      - calendar.3
      - calendar.4
      - calendar.5
      - calendar.6
    name: Calendar
    numberOfDays: 14
    showProgressBar: false
    type: 'custom:calendar-card'
  - title: Shopping List
    type: shopping-list
type: vertical-stack

Translated: The Service system_log/write called
image

and then in the log it shows:

Any clue?

Do your other custom elements work? Because you define the type before the url (just to be sure that that isn’t the error).
Otherwise I can’t see any difference except the version number that I leave out.
How are they defined in your google_calendars.yaml ?

Yes all other works.

I agree, but when I edit that part in the raw editor and turn it around it simply reverts back after a reboot.
Also, I did try removing the versioning, but still the same.

My google_calendar.yaml looks like this:

- cal_id: [email protected]
  entities:
  - device_id: xxx
    ignore_availability: true
    name: xxx
    track: true

- cal_id: [email protected]
  entities:
  - device_id: xxx1
    ignore_availability: true
    name: xxx1
    track: true

- cal_id: [email protected]
  entities:
  - device_id: xxx2
    ignore_availability: true
    name: xx2
    track: true

- cal_id: [email protected]
  entities:
  - device_id: xxx3
    ignore_availability: true
    name: xxx3
    track: true

- cal_id: [email protected]
  entities:
  - device_id: xxx4
    ignore_availability: true
    name: xxx4
    track: true

- cal_id: xxx5#[email protected]
  entities:
  - device_id: xxx5
    ignore_availability: true
    name: xxx5
    track: true

- cal_id: [email protected]
  entities:
  - device_id: xxx6
    ignore_availability: true
    name: xxx6
    track: true

Thats the error I got, have tried without the version, with the version I still got issues. Running 0.86.2, really want to have this running.

local/calendar-card.js?v=1.0.1:10:7 Uncaught ReferenceError: moment is not defined

have u tried adding to y our configuration.yaml the line
frontend:
javascript_version: latest

Sorry :frowning: wouldn’t know what to say then. I would help more if I could.

Thanks for the try :blush:

Yes no change! (If it was my post you was referring to)

moment undefined means it hasnt pulled the moment.js file.
what u could try is download the moment.js file locally
save it under /local/moment.js
and define it in the resources as
resources:

  • type: js
    url: ‘/local/moment.js’

that will then or should pick it up from local…

Hi,
too change the appearance of the calendar day you just have to edit the block below in calendar-card.js

  getDayHtml(day, events) {
const className = moment().format('DD') === moment(day).format('DD') ? 'date now' : 'date';
let momentDay = moment(day);

return `
    <div class="calendar-day">
      <div class="${className}">
        <div>${momentDay.format('ddd')}</div>
        <div>${momentDay.format('DD.MMM')}</div>
      </div>
      <div class="events">
        ${events.map(event => this.getEventHtml(event)).join('')}
      </div>
    </div>`;

}

the line : <div>${momentDay.format('DD.MM')}</div> does the trick (DD.MM stands for “day.month”)
every combination is possible (MM.DD, MM-DD, DD-MM, …)
This only to show up numbers. If you like the month in text, so use MMMM for full month, or MMM for shortened month …

sry for ‘unconventional’ posting - its my very first, and i am not comfortably yet :slight_smile:

1 Like

Thanks! I’ll try that when I’m at home :slight_smile: will keep you posted.

Downloaded the moment.js file and changed the part, but its still the same error

Uncaught ReferenceError: moment is not defined

Is there some other thing to do?