Hello everone,
I am losing some patience here and hoping someone can help me include moment.js
in my dashboard implementation. My Lovelace configuration is using mode: storage
and as such, I have added moment.js as a resource using the Home Assistant UI under http://homeassistant.local:8123/config/lovelace/resources as follows:
I see it being included in DEV tools, so I know it is being picked up and included:
My quite simple implementation looks like this:
let lastchanged = Date.parse(states['sensor.washer_laundryroom_runtime'].last_changed);
let stateString = moment().format(lastchanged);
return stateString;
(screenshot)
(specifically this section)
However, I am getting this error in DEV tools when I load the page:
caught TypeError: Cannot set properties of undefined (setting 'moment')
at moment-with-locales.js:4:19
at moment-with-locales.js:5:2
(screenshot)
I have tried:
- Adding a
var moment = require('moment');
statement and that results in require not being defined
I really do not know what else to do in order to leverage the power of moment.js in my lovelace cards. Any suggestions anyone?
Thanks in advance.