WebRTC icon indicating copy to clipboard operation
WebRTC copied to clipboard

Javascript template not working when adding css styles.

Open TitjyDev opened this issue 7 months ago • 0 comments

Hello. First of all, sorry cause i posted this issue in the wrong repo. My bad.

So, WebRTC documentation says we can use javascript template in style:

Templates New in v3.6.0.

Card options shortcuts, style and ptz supports JavaScript templates In shortcuts and style you can use states related templates

While javascript template works in shorcuts option, it don't in style

  shortcuts:
    - name: >-
        Camera Mode :
        ${ states['switch.camera8active'].state === 'on' ? 'Off' : 'On' }
      icon: >-
        ${ states['switch.camera_active'].state === 'on' ?
        'mdi:camcorder' : 'mdi:camcorder-off' }

  style: >-
    ${ states['switch.camera_active'].state === 'on' ? '.shortcuts ha-icon {background-color:red}' : '.shortcuts ha-icon {background-color:green}' }

My icon should be displayed with a red or green background regarding the entity state but no icon is displayed.

This works as expected of course:

 style: >-
    .shortcuts ha-icon {background-color: red}

So what i'm doing wrong?

TitjyDev avatar May 04 '25 13:05 TitjyDev