Scheduler card/custom component

hI, how do i configure the card to turn the lights on or off at sunrise or sunset?
Thanks

Check the box to automatically adapt to sunrise/sunset, and then enter in the sunrise time or the sunset time according to HA. If it’s a bit before or after, it’ll turn off the lights before or after.

For the scheduler card, add it as a plugin/lovelace. For the scheduler component, add it as a component/integration.


I was skeptical. I set it up initially just to try the schedule options out.

I’m really liking the ability to customize the groups and entities. I just setup switches to disable network access for my boys gaming PCs Sunday at midnight, and enable the network at noon on Friday. It is a lot easier than remembering to hide their power plugs every week. :slight_smile:

3 Likes

I tried a few times but the card doesn’t install. Any way to install it separately using HACS?

What do you mean?

I added it to the list of custom repos, clicked install “Scheduler component” but I still get “Custom element doesn’t exist: scheduler-card” when I try to add the card to a Lovelace dashboard.
I clicked “Reinstall” but stlll get the same error message.

Odd, I don’t get that error. Is it listed in your resources?

I appear to be experiencing the same problem.

Requisite files are present:
Screenshot from 2020-08-27 19-49-10

Resource present in ui-lovelace.yaml

resources:
  - url: /local/scheduler-card/dist/scheduler-card.js?v=0
    type: module

No amount of browser refreshes or Home Assistant restarts fixes this:
Screenshot from 2020-08-27 19-50-32

What do you see in the browser console?

Uncaught SyntaxError: expected expression, got ‘<’

Screenshot from 2020-08-27 19-57-45

@neliss Do you see what’s going on here? @123 try updating because I don’t see the problem:

All three files I’m currently using were downloaded (using wget) from here this evening:

scheduler-card/dist at main ¡ nielsfaber/scheduler-card ¡ GitHub


EDIT

The link in the error message (scheduler-card.js) leads to the generated HTML. I pasted it into VS Code and it didn’t identify any HTML syntax errors. I don’t know if that’s meaningful but I thought I’d mention it.

Could you take a quick look in the ui-lovelace.yaml under resources: if there is a reference to the scheduler-card directory. If so, can you also check if the files are there?
If this is all in place, then this is not related to HACS.
Currently there is no configuration check in place (my bad), so if you make a typo in the entities definition (or whatsoever) you will also get the same message. Perhaps the issue is caused there?

This is really weird, hard for me to see from here what is causing this.
Lines 1-10 only include references to external dependencies, and in case something is wrong in these files you would get a different error message.
Also this "<" is barely used at all in the code, so it provides little information.

The good news is that i’m preparing an update that gets rid of external file dependencies. Perhaps with this version, your problems will be gone.
I expect to be able to release this somewhere over the weekend, so maybe its best to just give it a try in a few days.

1 Like

@neliss It seems I do not even have a ui-lovelace.yaml file. Where is this supposed to be in HAOS?

I think @neliss uses YAML mode, you should look under config > dashboards > resources.

I don’t even have a /hacsfiles directory…

What should be in /root/config/custom-components/scheduler after (re-)install via HACS?
I get

➜  ls -l /root/config/custom_components/scheduler
total 48
-rw-r--r--    1 root     root          3654 Aug 28 22:07 __init__.py
drwxr-xr-x    2 root     root          4096 Aug 28 22:26 __pycache__
-rw-r--r--    1 root     root           695 Aug 28 22:07 config_flow.py
-rw-r--r--    1 root     root          2050 Aug 28 22:07 const.py
-rw-r--r--    1 root     root          6817 Aug 28 22:07 datacollection.py
-rw-r--r--    1 root     root          2963 Aug 28 22:07 helpers.py
-rw-r--r--    1 root     root           321 Aug 28 22:07 manifest.json
-rw-r--r--    1 root     root          1678 Aug 28 22:07 services.yaml
-rw-r--r--    1 root     root          9945 Aug 28 22:07 switch.py

Yes, it was automatic for me. For me it’s /hacsfiles/scheduler-card/scheduler-card.js.

As promised, I released an update of the card today.
Could you try to download the latest version from here?
All code is now in a single file without external references, so chances are that it solves your problem.

You can place the js file in www/scheduler-card/scheduler-card.js (no /dist/ needed).

In the resources section of ui-lovelace, you should add:

- url: /local/scheduler-card/scheduler-card.js?v=1.2.0
  type: module

This should solve your “custom element doesn’t exist” error.

1 Like