Toggle doesn't work for locks
See original GitHub issueI 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:
- Created 4 years ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Works exactly as expected! Well done, thank you!