šŸ”¹ Lovelace_gen - Add abilities to ui_lovelace.yaml

Iā€™m fairly sure itā€™s tojson, to_json is what HA built into jinja where tojson is whatā€™s built into jinja.

https://jinja.palletsprojects.com/en/stable/templates/#jinja-filters.tojson

Thatā€™s what you have to use.

tojson didnā€™t originally exist in jinja, so HA added to_json

Well thatā€™s pretty confusing (to me at least! Or are you saying that the HA to-json is now obsolete because jinja does it natively, with tojson?)

Butā€¦ it still isnā€™t solving it.
Interestingly VS Code still doesnā€™t like it but the dashboard will display correctly.

image

But no tap actions work.

well, itā€™s not obsolete, thereā€™s just 2 functions that do the same thing. But that function (to_json) only exists in HA, it does not exist in lovelace_gen.

VSCode will never like anything in lovelace_gen.

Any other ideas how to make the tap action work?
Or should I give up?

TBH Iā€™ve only really had that in the yaml for ESP Home :man_shrugging:

usually what I doā€¦

{% if tap_action is defined %}
tap_action: {{ tap_action }}
{% endif %}

Yeah, that works for the tap_action (and makes a mess of squiggles in VS Code :joy:) but I still canā€™t find a way to get it to default to

tap_action:
  action: toggle

if tap_action is not defined

the default tap action is toggle, so you shouldnā€™t have to specify it. Worse case, add an else.

{% if tap_action is defined %}
tap_action: {{ tap_action }}
{% else %}
tap_action:
  action: toggle
{% endif %}

Thatā€™s exactly what I tried.
Including leaving it off an expecting the default.

Neither worked though :man_shrugging:

I donā€™t see how that would fail. What card is this? Are you sure the card accepts action: toggle?

EDIT: Iā€™m using something similar here and it definitely works.

It is a custom button card and funnily enough it is based on one you came up with a few years ago.
Less funny, I found a ridiculous typo.

:blush:

In case you donā€™t remember it was these, theyā€™re still going strong for me albeit with quite a bit of hacking for various other uses. I keep thinking about moving on from them but I still like them!
(Yes, Iā€™m just trying to deflect from my stupidity)

Another question.
:blush:

I use lovelace_gen a lot in my config but I am at a loss as to why this dashboard refuses to load because it appears to be similar to countless other examples I have.

title: Announcements Settings
path: announcements_settings
icon: mdi:microphone-message
cards:
  - type: vertical-stack
    cards:
      - !include announcements_settings_testing_card.yaml

This is announcements_settings_testing_card.yaml

# lovelace_gen

type: custom:hui-element
card_type: entities
entities:
  - entity: input_number.announcement_test_ui_sonos_kitchen_volume

but if I remove the

# lovelace_gen

everything is ok.


For completenessā€¦
My file structure is:

lovelace (folder)
   settings (folder)
     view_settings.yaml
     announcements_settings_testing_card.yaml
ui-dashboard-settings.yaml

ui-dashboard-settings.yaml is simply a list of includes for all my views fro thet dashboard:

title: System Settings
views:
  - !include lovelace/settings/view_settings.yaml

pretty sure the include needs to be



title: Announcements Settings
path: announcements_settings
icon: mdi:microphone-message
cards:
  - type: vertical-stack
    cards:
      - !include "../settings/announcements_settings_testing_card.yaml"

No, the template and the dashboard are in the same folder.
I have the syntax form you suggest in almost every other !include in my config because usually they are not in the same folder.

The way I have it now it displays everything correctly it is just that if I add the # lovelace_gen to the first line it then refuses to load.

(Obviously, eventually I want to add some jinja, this is just to illustrate a trivial example)

Iā€™m fairly sure lovelace_gen only works from the bottom folder up with itā€™s includes.

Nope, still confusedā€¦

I have moved the !include file into the same place as all my other !include templates which pretty much all all have # lovelace_gen and still have the same problem.

This loads properly without the # lovelace_gen

          - !include ../templates/announcements_settings_testing_card.yaml

But doesnā€™t load with it

image

Not sure what to tell ya

Well I tried everything I could think of, in the end I just moved everything I wanted to do into a script which was slightly inconvenient, but offset by being ā€˜standardā€™ I suppose.

Still a bit of a mystery though.