elchininet / custom-sidebar

Custom HACS plugin that allows you to personalise the Home Assistant's sidebar per user or device basis
Apache License 2.0
83 stars 5 forks source link

item vs new_item #229

Open xstrex opened 2 hours ago

xstrex commented 2 hours ago

Thanks for putting all this together, just trying to get is going but having some issues, and noticing some inconsistencies, so wanted to ask.

I've successfully loaded your module:

frontend:
  themes: !include_dir_merge_named themes
  extra_module_url:
    - /hacsfiles/lovelace-card-mod/card-mod.js
    - /hacsfiles/custom-sidebar/custom-sidebar-yaml.js

The developer tools shows the module is loaded: image

Yet produces an invalid configuration (which is good, we're half way there)! Now it states that every item in an "order" array should have an "item" property. Which would imply the following:

order:
  - item
  - item
  - item

and your documentation for the order array states that item is the only required field.

Yet the example you provide doesn't follow this standard, and instead allows for either item or new_item. Which per the developer console should throw an exception..

So, which is it? Does the order array require item or new_item? Because utilizing both isn't working.

For reference here's my sidebar-config.yaml:

order:
  - item: overview
    order: 0
  - item: servers
    order: 1
  - itme: maintenance
    order: 2
  - new_item: true
    item: Integrations
    href: "/config/integrations"
    icon: mdi:puzzle
    order: 3
  # - new_item: true
  #   item: Entities
  #   href: "/config/entities"
  #   icon: mdi:hexagon-multiple
  #   order: 3
  - new_item: true
    item: Automations
    href: "/config/automation"
    icon: mdi:robot
    order: 4
  - item: terminal
    order: 5
    bottom: true
  - item: hacs
    order: 6
    bottom: true
    notification: |
      [[[
        const outdatedHacsEntities = Object.values(entities.update).filter(
          (entity) => entity.platform === 'hacs' && is_state(entity.entity_id, 'on')
        );
        return outdatedHacsEntities.length || '';
      ]]]
  - item: config
    bottom: true
    order: 7
  - item: developer
    name: Dev tools
    icon: mdi:tools
    bottom: true
    order: 8
  - item: studio code server
    name: Code Server
    icon: mdi:microsoft-visual-studio-code
    bottom: true
    order: 9
  - item: logbook
    hide: true
  - item: history
    hide: true
  - item: snapshots
    hide: true
  - item: backups
    hide: true
  - item: map
    hide: true
  - item: energy
    hide: true
  - item: media
    hide: true
# exceptions:
#   - user:
#     - Jim Hawkins
#     - Long John Silver
#     extend_from_base: false
#     order:
#       - new_item: true
#         item: Updates
#         href: "/config/updates"
#         icon: mdi:update
#   - user: Palaus
#     extend_from_base: true
#     order:
#       - item: history
#         order: 12
#       - item: media
#         order: 13
# id: example_yaml (remove this from your config or replace with any other string)

Also, when using HassOS, how would someone link to the esphome container- for instance the link in my default sidebar points to http://redacted.internal.host:8123/5c53de3b_esphome, I suspect since it's a container the 5c53de3b_esphome will change (unconfirmed). Studio code server is another example, just not sure how to reference it.

xstrex commented 2 hours ago

Fixed the typo in my config l:6 itme. Not it looks like the config is loading correctly, though my question about the item vs new_item remains.

elchininet commented 2 hours ago

Hi @xstrex,

I am seeing that the error that you received was because there was a typo in the item property, so that property was missing. You already fixed that.

Yet the example you provide doesn't follow this standard, and instead allows for either item or new_item. Which per the developer console should throw an exception.

I don't understand well your question. Every item in the example has an item property. new_item is in the items that are not already in the sidebar and need to be created. What do you mean with "the example you provide doesn't follow this standard"? Which standard do you mean?

So, which is it? Does the order array require item or new_item? Because utilizing both isn't working.

Only item is mandatory, new_item is to create a new item in the sidebar:

image

Also, when using HassOS, how would someone link to the esphome container- for instance the link in my default sidebar points to http://redacted.internal.host:8123/5c53de3b_esphome, I suspect since it's a container the 5c53de3b_esphome will change (unconfirmed). Studio code server is another example, just not sure how to reference it.

In my experience those links don't change (something different is the ingress iframe URL). But those links are already in the sidebar, you can add them if you activate the switch to show them in the sidebar from the addon configuration.

though my question about the item vs new_item remains.

I need to understand first your question, sorry if I am not able to get it correctly. 🙂