Change switch to a Lock (visually)

Hello,
I have two sonoff switch on my door that only indicated ON and OFF (two to the right), but I want it to “act” as my other locks (yaleman) and indicate locked/open (two to the left)
image.
I have tried to use the Template lock but don’t really get it to work. I want both the names and icon to be the same as the lock, but don’t know how to go on to make that happen (if even possible).

lock:
  - platform: template
    value_template: "{{ is_state('switch.sonoff_1000514ace', 'on') }}"
    lock:
      service: switch.turn_on
      data:
        entity_id: switch.sonoff_1000514ace
    unlock:
      service: switch.turn_off
      data:
        entity_id: switch.sonoff_1000514ace

Hopefully that will achieve what you want. Look at the device_class option.

Thanks, but I dont think that it will do the trick since the device_classes are for binary sensors and mine is an switch. Hence i haven’t got it to work

Ah - bummer… I suppose you could template a binary sensor, then do an automation for a click action?

You can use a template lock based on the switch.

1 Like

Aha! - that’s a better way - it’s even there as an example. Well done - I hope it works for him.

Thanks, but I dont get it to work. That is the code that I have pasted in above, but its not working

Can you elaborate? What isn’t working?

Hi @DudeShemesh, well there are 2 things i would like to do. And the back ground is that i have two Sonoff SV connected to two magnetic locks. The Sonoff have two states On and Off (for the the output).
First thing i want to change is to change name from on/off (av/på in swedish) to locked/unlocked in the card.
And the second part is to make them look like a lock, meaning, i want it to look like the other two doors.
Thanks for the help

I understand what you’re trying to do - what I don’t understand is what you mean by “it’s not working”.
Are you using the lock entities in your lovelace cards?

edit:
Sorry @DudeShemesh, took a while, but now I understood that you meant. So its working now, thanks

Well that part i have not, had missed that totally. I used a standard button card hence not working.
Have now tried to google how to do that and what to write and I haven’t found anything.
Could you perhaps be able to helo with that? Thanks

1 Like