neilimixamo / Home-Assistant-Quick-Look-Mobile

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rapid Toggle Switch

Michelone86 opened this issue Β· comments

Hello @neilimixamo, it would be interesting to insert a section with some Toggle switches for quickly activating some entities, which do not necessarily have to be lights, doors, routines, scripts, etc..

For example, in my home automation I created the guest mode. I activate this mode with a button when my parents from the south of Italy come to visit me at home (at Christmas 😊). Guest mode is a boolean switch that, when turned on, deactivates all the automations that usually activate when my wife and I are away from home.

Or a simple button restarts the modem (button entity of the Fritzbox).

In these two cases the keys would remain colored as long as the activations are in operation.

What do you think about it? Thanks πŸ˜‰

Hi @Michelone86 , I think the current device template should be able to handle these two scenarios :

1/ Regarding the 'input_boolean' entity, it should be recognized without any issues and will display a blue color when active and no color when inactive.

- type: custom:button-card # ENTITY 01
  template: device
  variables:
    entity: input_boolean.guest_mode
    name: 
    label_on: 'Active'
    label_off: 'Inactive'

2/ If I understand correctly, you want to be able to restart your modem by activating its 'button.modem_restart' entity and display the card in blue until it is fully rebooted.

Managing the 'button' entity is not as straightforward since it doesn't have a binary on-off state. It also doesn't seem that the button waits for a complete reboot of the device before it can be clicked again, which would make managing the color of the card difficult as well. However, I believe there is a simple way to achieve what you're looking for, still via the 'device' template.

Instead of refering your 'button.modem_restart' as entity, you should refer the binary_sensor that looks for the connectivity of your modem. Perhaps your device already has a 'binary_sensor.modem_state'. If not, you can simply create this binary_sensor through the Ping integration by specifying the IP address of your modem.

At that point, the card will display a blue color when your modem is 'on' and a gray color when it's 'off'.

Finally, adding the following code will easily allow you to activate its 'button' entity with a simple click on its icon

- type: custom:button-card # ENTITY 02
  template: device
  variables:
    entity: binary_sensor.modem_state
    name: 
    label_on: 'Active'
    label_off: 'Inactive'
    icon_tap_action:
      action: call-service
      service: button.press
      service_data:
        entity_id: button.modem_restart

Try this out and let me know what you think. We can then fine-tune additional settings according to your preferences

Hi @neilimixamo, I really like the idea of using the modem connection sensor!
It works great, I'm very happy!

Another request came to mind, I'll open a new topic straight away and in the meantime I'll buy you a couple of coffees πŸ˜‰

Thanks my friend, over and out 😎✌🏻