Lovelace Picture Element, how to call-service to activate scene using Icon element

Hi need some help here,
I have been trying to use ‘Icon’ element to activate a scene in Picture Element Cards. But fail to do so. When I use ‘Service-button’, I am able to activate the scene successfully. I check syntax vigorously, but they are just both similar and calling the same service. Is my coding wrong or is it that Icon element cannot call a service like scene.turn_on?

Here is my 2 code under “Picture Element”

  1. ‘Service Button’ - work perfectly
  2. ‘Icon’ - fail to activate the same scene, without error message.
    (The title is just a remark to remind myself)
  - title: Activate TV On Scene
    type: service-button
    service: scene.turn_on
    service_data:
      entity_id: scene.iwtzll25a32zrfov
    style:
      left: 60%
      top: 20%
  - title: icon - call service to activate TV On Scene
    type: icon
    icon: 'mdi:bug'
    style:
      left: 45%
      top: 35%
    tap_action:
      action: call-service
    service: scene.turn_on
    service_data:
      entity_id: scene.iwtzll25a32zrfov

Sorry, please let me know if my post is not complete or confusing, let me know what is lacking and I will try to provide more information. I am using Pi4, HASSOS, Windows 10.

My objective is to use picture element, I want to place a AirConditioner icon on the picture, when I click on the icon, it will activate a scene to trigger Tuya IR Remote to turn on my TV. (I learned that HA can only trigger the IR remote through Scene, please correct me if I am wrong) . At this moment, since the IR/HA do not feedback the state of the TV, i would not expect that the icon would change color, I am just trying to learn how to ‘call’ the service right now. Thanks for your kind help, I have been struggling for few days searching in the forum for sample code but without success.

The indentation for service and service_data is wrong. Try like this:

tap_action:
  action: call-service
  service: scene.turn_on
  service_data:
    entity_id: scene.iwtzll25a32zrfov

And how about changing the name of the script? I don’t know how people can work with these obscure names…

2 Likes

How simple and how effective is that ‘Indentation’, how foolish am I just to copy indentation from ‘service-button’ code…Thanks a million, I was scratching my head for 3days already…

When you say changing the name of the script, do you mean change the entity_id? like rename it from “scene.iwtzll25a32zrfov” to “scene.turn_on_tv” for example ? It was given from HA from Tuya integration, I didn’t know I can re-assign a new name. Would you mind teach me how? Thanks for your kind help.

OK, self help, did a simple search in HA, found the answer, Thanks for telling me that I can change the ID though…

1 Like