Hi, I’m pretty new to HA, but I have a question about lock domains.
From what I can work out, a lock entity can only have a “lock” or “unlock” service. If I try to make it toggle, it fails.
My question is, firstly- is this correct? Are Locks unlike say switches, and can’t be toggled?
And if so, is there an easy work around solution? Can a lock be converted to a switch to allow toggling on/off (lock/unlock)?
To give some background, I have an automated WiFi CatFlap, (Surepet) and its HACs-added entity creates it as a lock able door.
I have successfully created a small 1x1 widget using HTTP Shortcut for my Android, but currently I need to have 2 widgets - 1 for lock, and 1 for unlock.
It would be much more preferable to have a single toggle widget (with a bonus if I can work out a way to change its icon based on the Lock’s status, which appears in HA as a seperate sensor)
Apologies for the lack of technical terms, as mentioned, pretty new to the game, but learning quickly!
Cheers
I know this is an old request, but here’s what I use. I trigger it from a tap_action on a picture-glance card so I have one-click lock/unlock (default shows more info).
Adding my 2 cents, I was able to solve this by using a couple of conditional types within my entities card and by creating two separate sensors (lock, unlocked), conditionally displayed based on the state of the lock. A template switch might be a better choice, but I did not consider that while working through this. I think its actually the smarter choice and I’ll look at moving that way. In any case, here’s my approach, hope it helps someone:
In the UI:
The code example you have with conditional, maybe I’m little dumb her. I don’t get it where to type that, I thought it was conditional card, but I get errors when using that. Could you please guide me how to be able to use toggle together with a lock
You need to edit the UI code directly. I believe I started with an entities card and edit its code to add the conditional cards. FWIW, I stopped doing it that way, as I found the highlight color was the same between the two conditions, locked/unlocked.
What I ended up doing instead was using an entities card. Here is the code for that:
I have a Garmin watch and couldn’t for the life of me figure out how to toggle the lock with one button. I was set on making two buttons, one to unlock and another to lock. I don’t know too much about coding and everything was gibberish. Probably could figure out what everyone was talking about if I really looked into it. But then I had a moment of inspiration and created a script using if-then.
IF lock is unlocked THEN lock, ELSE, unlock. Super simple.
Might look into a template switch, so I can get the icons to change, but if you just want it to work, this is it.