Help with YAML Code to set key-value pair dynamically

Hi

I have a switch in my setup called switch.bedroom_addressable_led_relay_switch and the state can be either on or off.

I also have the wall panel mod to set the dashboard (called called lovelace-test1) in kiosk mode and so show a screensaver after 15 seconds of inactivity.

After the screensaver stops I am trying to set the screensaver_stop_navigation_path: to a lovelace dashboard depending on the state of the switch.bedroom_addressable_led_relay_switch.

If the state of the switch is off I would like the screensaver_stop_navigation_path: to be /lovelace-test1/lighting, and if the state of the switch is on, to be /lovelace-test1/lighting-on.

I am hoping I could do this without using templates and just via the YAML for the dashboard where the screensaver_stop_navigation_path: is set for the wall panel mod.

Here is the code I am using, but it isn’t working.

title: Test1
wallpanel:
  enabled: true
  hide_toolbar: true
  hide_sidebar: true
  fullscreen: true
  idle_time: 15
  fade_in_time: 5
  display_time: 0
  screensaver_stop_navigation_path: |
      [[[
        if (states['switch.bedroom_addressable_led_relay_switch'].state == 'off')  return '/lovelace-test1/lighting';  return '/lovelace-test1/lighting-on';
      ]]]

What the code above does is set the screensaver_stop_navigation_path: to:

/lovelace-test1/[[[%20%20if%20(states[%22switch.bedroom_addressable_led_relay_switch%22].state%20==%20%22off%22)%20%20return%20%22/lovelace-test1/lighting%22;%20%20return%20%22/lovelace-test1/[[[%20%20if%20(states[%22switch.bedroom_addressable_led_re...

and hence fails to set the dashboard depending on the state of the switch.

Thanks in advance for any help, Kal.

You’d have to use a custom card that allows templating. Something like config-template-card.