question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Toggle doesn't work for locks

See original GitHub issue

I believe this is a HA limitation, but toggle action doesn’t toggle lock domain entities. My simple workaround is as follows:

Change lines 542-547:

          case 'toggle':
          default:
            this.hass.callService('homeassistant', 'toggle', {
              entity_id: state.entity_id,
            });
            break;

to

          case 'toggle':
          default:
            if( state.entity_id.split('.', 2)[0] == 'lock'){
              if( state.state == 'locked' ){
                this.hass.callService('lock', 'unlock', {
                  entity_id: state.entity_id,
                });
              } else if( state.state == 'unlocked' ){
                this.hass.callService('lock', 'lock', {
                  entity_id: state.entity_id,
                });
              }
            } else if( state.entity_id.split('.', 2)[0] == 'cover'){
              if( state.state == 'open' ){
                this.hass.callService('cover', 'close_cover', {
                  entity_id: state.entity_id,
                });
              } else if( state.state == 'closed' ){
                this.hass.callService('cover', 'open_cover', {
                  entity_id: state.entity_id,
                });
              }
            } else {
              this.hass.callService('homeassistant', 'toggle', {
                entity_id: state.entity_id,
              });
            }
            break;

Hopefully this helps others.

EDIT: Apparently this is also true for covers - added cover functionality too.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jamesdawson3commented, Apr 21, 2019

Thanks for the comments guys. The more I think about this, the more I agree - the workaround shouldn’t live in a Lovelace card. Really the change should be made to the HA core to include toggle for the lock, cover, etc domains. I think I’ll change to template switches for now.

0reactions
jamesdawson3commented, Apr 26, 2019

Works exactly as expected! Well done, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Power Door Lock Not Working Drivers Side (8 Reasons)
Driver Door Won't Lock or Unlock With Remote Control: The Possible Reasons · Reason #1: Presence of Obstruction · Reason #2: Latch Lacking...
Read more >
Q: Car doors lock but won't unlock with interior button?
Again, check the unlock button for a poor wiring connection, a dirty switch, or any other sort of obvious damage.
Read more >
Door Locks won't lock with toggle or key!!
Both my door locks will not lock with the inside toggle or key. I checked the fuse and its fine. The weird thing...
Read more >
How to Use the Toggle Switch on a Mortise Lock Door
The toggle button on the door lock face provides a way to keep the door locked from the exterior. Curious how to operate...
Read more >
Door Not Unlocking? Diagnosing Truck or Car ... - YouTube
Shop for New Auto Parts at 1AAuto.com http://1aau.to/c/21/ar/power-door- lock -actuatorIs your vehicle's door not unlocking when you press the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found