One Button to Switch Lovelace view and Toggle Boolean


I’m designing my Lovelace interface and I want a header that stays the same but the content below will change based on the selected source.

My sources are Apple TV, PlayStation, and Shield. Also, I want a home button and All Off button.

If I press PlayStation for example I want it to toggle Boolean that will start an Automation and switch the view to Playstation view that will have the same header but the content below the switch buttons will be something else like the PlayStation Media Card with TV volume controls.

Here is a screenshot:

So my questions are:

  • Can I have a button that can do two actions? Toggle the Boolean and Switch the view?
  • Or, can I make the view once it load it toggle a Boolean?
  • Or, can I make an Automation switch the Lovelace view?

I hope explained my issue clearly.

Thanks in advance.

1 Like

Yes, call as script with your button.
Use browser_mod to switch the view.
For example, this script reloads lovelace and navigates to my home view.

      - service: browser_mod.lovelace_reload
            - pad_ez
      - delay: '00:00:03'
      - service: browser_mod.navigate
          navigation_path: /lovelace/tpad_home 
            - pad_ez

called from a custom button

              - type: custom:button-card
                entity: script.tpad_refresh_ui
                name: UI Refresh
                icon: mdi:reload
                  action: call-service
                  service: homeassistant.turn_on
                    entity_id: script.tpad_refresh_ui
1 Like

Conditional cards with the boolean as the condition? Isn’t that what you are looking for?


Thanks for your reply @VDRainer

I just tried it. It works only if I define deviceID in the service data, so I have to add every device I use and this is not a problem.

The problem is I use Home Assistant App for iOS and browser_mod doesn’t see it as a browser so it doesn’t give it a deviceID.

Hi @Hellis81

Can I make a condition do a navigation action without pressing a button? or you mean I load the device controls if the condition is “on” so I don’t have to create a view for each device?

That’s right, doesn’t work anymore on iOS App.

I think @Hellis81’s suggetion is a good alternative.

Maybe take a look at the state-switch. I think it has more options than the conditional card.

1 Like

Here’s how I do it, without having to call a script

	action: fire-dom-event
	  command: commands
		- command: navigate
		  navigation_path: /lovelace-home/diesel
		  deviceID: this
		- command: close_popup
		  deviceID: this
		- command: call-service
		  service: input_boolean.turn_on
			  entity_id: input_boolean.diesel_data
1 Like

I’m not sure I understand your questions.

The way I vision it is:

Each button is a boolean, you turn on and a script runs with various tasks. Last task is to set other booleans (Apple, shield etc.) to false.

I’m not completely sure about how conditional cards work, I have only used them in picture elements card, but have a “master boolean” (if any is on) then nest below if Apple is on display “this” and if shield is on, display “that” and so on.

It’s going to be hard and it will be confusing.
My advice is to build small blocks that work then try to integrate them together because otherwise it will be a major headache.

If I have time then I today then I can have a deeper look at it.

1 Like

Hello @Hellis81

I did what you wrote, and it worked just like how I want it. Thanks!

@VDRainer I will try state-switch and see how it works.

1 Like

This is the end result:

The TV volume shows only when the TV turns on, the same thing for the devices connected to it. It shows when the device boolean is on.

I changed the theme to Dark iOS.

Thanks all for your help.

1 Like