I have very a basic question which drives me nuts:
I’m setting up a “glance” card where I have included several switches, e.g., “- switch.xyz”. How can I add a toggle action to these switches? In case of a “standard entity” I usually add “toogle” as “tap_action” which works fine. But how can I add a toogle action to a “- switch.xyz” as mentioned above?
thank you very much for your response. With your help, I got it up and running. If someone else stumbles over the same problem, I will post below my working solution:
I have tried the solution above with “lock.starnuki” of my smart lock in order to toggle the lock and unlock state by replacing “switch.xyz” by “lock.starnuki” in the snippet above. However, this doesn’t seem to work as nothing happens when I click in the icon. Any idea which this doesn’t work?
Just one minor thing that doesn’t currently work as expected: I have implemented the switch in a glance card, where the status “OFF” is shown when the door lock is locked. Do you have any idea how to display the status “Locked” instead. Evidently, it would be nice to display “Unlocked” for an unlocked status.
Personally, I simply display that switch based on a condition and only when it’s ‘on’ - so I never really see the ‘on’ / ‘off’ state - only the result of it via the UI:
One last thing, if you want to display these in a GLANCE card, then you can also customize the icon/image (by using a custom image [which you can create / download from MDI (https://materialdesignicons.com/) and upload to your /config/www directory (where mine are referenced). Note the entity_picture_template section (which I omitted for brevity in my post above).
your link was gold and very interesting to read. I’ve set a bookmark because I am sure that I will need this info in the near future. Thanks!
What I currently have at my GLANCE card looks like this image:
Two things are currently wrong with this image. First, the current status of the lock is “unlocked” and the icon is highlighted in yellow. IMHO, a yellow icon would be more appropriate for the “locked” status. Second, the label states “On” for the “unlocked” lock. It would be nice to show “locked” for a locked state and “unlocked” for an unlocked state instead of “Off” and “On” in the GLACE card, respectively.
Glad I could ‘help’ somebody! I haven’t been doing this for too long myself, and there’s a ton of people here who know a TON more than I, but tinkering enough I’ve figured a bit out.
Personally, I use BLUE icons for closed / off and YELLOW for open / on. Your personal preference is allowed to be whatever you’d like Here’s my open gate and closed garage at present:
So for the garage I made a blue closed icon (one on left) and then a yellow open (one on right)
materialdesignicons.com also has a few unlocked icons (though I’ve found not all of these work by default in HA, if you’re making them custom, doesn’t matter…)
lock-open-outline
lock-open-variant-outline
The two above are the outline ones below
I think w/out using something other than a typical glance card, the only other way to do change the ‘state’ is to create a custom sensor which reports ‘open’ or ‘locked’ or ‘unlocked’ and then have two rows ‘stacked’ - something like this thread (Display both state and last_changed in glance?)
Something like this:
gate_friendly_status:
friendly_name: "Friendly Gate Status"
value_template: >-
{% if is_state('switch.front_drive_gate', 'on') %}
open
{% else %}
closed
{% endif %}
Again, there might be a custom card someone’s design out there, but I’ve decided on my glance cards that having them show a different color when they’re open/on/unlocked is enough for me to quickly tell - w/out having to show their exact state - so I personally haven’t gone this extra-sensor route.
I thought about the color choice for locked and unlocked states and you’re right. Yellow indicating an unlocked state is much better because in this way I am visually notified if I forgot to lock the door.
I will play around with the custom icon settings and will try to implement the “LOCK” and “UNLOCKED” label in my GLANCE card.
Btw, right now, my overview panel looks like this:
*.starnet is my local network, i.e., 192.168.whatever is operated from my local DNS server and thus only accessible from my LAN. I don’t use HA access from the internet.