Issue with adding cards to lovelace since auto ID's started

Ever since LoveLace started with the automatic assignment of ID’s I can’t add extra cards to my LoveLace screens. If I save changes to the ui-lovelace.yaml file with a new card entered and then try to reload LoveLace I get an error:
image

error log:

018-11-07 10:02:24 ERROR (MainThread) [homeassistant.components.websocket_api.decorators] Unexpected exception
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/websocket_api/decorators.py”, line 16, in _handle_async_response
await func(hass, connection, msg)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/lovelace/init.py”, line 285, in websocket_lovelace_config
load_config, hass.config.path(LOVELACE_CONFIG_FILE))
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/lovelace/init.py”, line 141, in load_config
return load_yaml(fname)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/lovelace/init.py”, line 130, in load_yaml
return yaml.load(conf_file) or OrderedDict()
File “/usr/local/lib/python3.6/site-packages/ruamel/yaml/main.py”, line 325, in load
return constructor.get_single_data()
File “/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py”, line 108, in get_single_data
return self.construct_document(node)
File “/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py”, line 118, in construct_document
for _dummy in generator:
File “/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py”, line 1477, in construct_yaml_map
self.construct_mapping(node, data)
File “/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py”, line 1376, in construct_mapping
self.check_mapping_key(node, key_node, maptyp, key, value)
File “/usr/local/lib/python3.6/site-packages/ruamel/yaml/constructor.py”, line 279, in check_mapping_key
raise DuplicateKeyError(*args)
ruamel.yaml.constructor.DuplicateKeyError: while constructing a mapping
in “/config/ui-lovelace.yaml”, line 682, column 9
found duplicate key “title” with value “Switches” (original value: “all automations”)
in “/config/ui-lovelace.yaml”, line 737, column 9

To suppress this check see:
http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

ui-lovelace.yaml (section of it)

  - id: 9  # Automatically created id
    title: System
    icon: mdi:home-automation
    cards:
      - id: 08668da28abc42d2a9f3aee0995d63a9  # Automatically created id
        type: entities
        title: all automations
        show_header_toggle: true
        entities:
          - automation.alarm_auto_arm
          - automation.alarm_auto_disarm_for_rent_inspection
          - automation.auto_alarm_off_via_daves_phone
          - automation.auto_alarm_off_via_rowes_phone
          - automation.bedroom_remote_button_1
          - automation.bedroom_remote_button_2
          - automation.chromecast_audio_off_automations
          - automation.chromecast_audio_start_automations
          - automation.cube__mute_move
          - automation.cube__party_mode_shake_air
          - automation.cube__play_pause_tap_twice
          - automation.cube__skip_track_flip_90
          - automation.cube__stop_media_player_flip_180
          - automation.cube__volume_rotate
          - automation.doorbell
          - automation.doorbell_light_control
          - automation.ensuite_remote_button
          - automation.ensuite_light_off_after_2mins
          - automation.ensuite_light_auto_on_motion
          - automation.html5_push_notification_action_button_clicked
          - automation.kettle_tts_on
          - automation.kettle_tts_when_boiled
          - automation.kitchen_remote_button_1
          - automation.kitchen_light_off_after_2mins
          - automation.kitchen_light_auto_on_motion
          - automation.listen_radio
          - automation.living_room_light_toggle
          - automation.notify_if_entry_light_unavailable
          - automation.notify_if_light_unavailable
          - automation.notify_system_healthy
          - automation.occupancy_simulator__doorbell
          - automation.party_mode__start
          - automation.party_mode__stop
          - automation.passage_night_light_off
          - automation.passage_night_light_on
          - automation.reticulation_run_program_1
          - automation.reticulation_run_program_2
          - automation.set_chromecast_radio_volume
          - automation.smart_home_off
          - automation.smart_home_on
          - automation.tts_if_light_unavailable
          - automation.tv_off_automations
          - automation.tv_on_automations
          - automation.telegram_test
          - automation.wardrobe_light_on
          - automation.wardrobe_light_off_after_2mins
          - automation.welcome_home
          - automation.bedroom_light_on_and_play_music

        type: entities
        title: Switches
        show_header_toggle: false
        entities:
          - switch.circadian_lighting_circadian_lighting


      - id: fee1588f4f6146cbaa1423f6b2d482e9  # Automatically created id
        type: custom:tracker-card
        title:
        trackers:
          - sensor.custom_card_tracker
          - sensor.custom_component_tracker

The section which I added in the above and causes the above error is the bit for the circadian_lighting, however I have tried adding other cards in a different location of the file with the same resulting error.

Any ideas why?

Ok, I figured it out. It seems that you have to allocate an id for each card. The docs say they will be automatically assigned but I guess that was only for the first time, and it wont do it for cards added later on. I assigned an ID and lovelace now loads with my new card included.

  - id: circadian_lighting_control
    type: entities
    title: Switches
    show_header_toggle: false
    entities:
      - switch.circadian_lighting_circadian_lighting

Which version? I know they came in with 0.81 and were auto-created and if you deleted them they came back like zombies… but people screamed about it and they rolled back the change… I’m on 0.82.0b2 now and there is a beta edit function for Lovelace which I presume requires the ID’s again… dunno.

I’m on 0.81.2 The ID’s were auto created when I first updated to 0.81.0 but don’t get added to any cards that I code in since then

yeah because they rolled back the auto-creation. I’d be more inclined to think it’s a cache issue…

I tried cache refreshing many times, its not that. It doesn’t like having cards listed without an ID entry.

I’m not seeing any error with that

Probably because you are on a newer version where they have removed the requirement for ID’s on each card. I’d imagine that once I update I’ll not have to assign ID’s to any new cards I create…?

It was the same in 0.81.1 when they removed it

strange then… It wont let me add cards without an ID. It just holds up the loading of lovelace completely. Ctrl+F5 wont even fix it. I tried on multiple PC’s too

I’m a little confused by all this, especially since I’ve seen that IDs are a requirement for the new “UI editor for Lovelace cards” in 0.82

None of my cards have IDs. At all. Irrespective of if they were created before or after 0.81.x (although I might have skipped one or two of the point versions.)

Anyway, bottom line, do I need to go through and add IDs manually for all my cards? My ui-lovelace.yaml is HUGE!!

Also, I couldn’t find IDs documented anywhere… can you point me in the right direction please.

There is a special card you can create.

resources:
  - url: /local/custom-lovelace/migrate-card/migrate-card.js
    type: module

then this…

          - type: custom:migrate-card

On one of your cards.

Then you will have this:
image

and tapping that will populate your cards with id’s

Where can migrate-card.js be found?

might be useful huh… https://github.com/bramkragten/custom-ui/tree/master/migrate-card
sorry about that!

1 Like

I can’t get it to work (hass.io ha 0.82.0). Doesn’t matter. I’ll just continue to punch them in manually like I always have been using the id parameter for it’s intent of naming the web page displayed.

I am using it on hass.io 0.82

In fact, when I added it, I didn’t even need to restart hassio it showed the migrate card immediately.

Works for me also on 0.82
Thanks David, saved a lot of typing

1 Like

Thanks David this looks really useful - especially now we know where to get it from :stuck_out_tongue_winking_eye:

I don’t want to get too OCD about this but does it add random IDs made up of meaningless strings of characters? I’m just wondering if I’d rather have them be meaningful… But does it matter in the slightest?

2 Likes

They have no real meaning so far as I know - they can be anything. If nothing else, they at least show you where the ID’s need to go as it’s a bit confusing… a stack for instance has one ID for the whole stack but if you just have multiple cards, they all get their own ID.

You can also run it again if you add new cards.

They just enable the ‘edit’ GUI in Lovelace.

1 Like

Mine doesn’t work either…

image