Hi,
I’d like to use the picture of my bedroom and by clicking on it I’d like the picture to be colored or black and white according to the state of my TV. And the click should turn the TV on and off.
But the thing is, I have different entity for turning on the TV (a Broadlink mini), and a different entity to show the state of the TV.
- title: Bedroom TV
icon: mdi:television
cards:
- type: picture-entity
entity: ???
tap_action: toggle
state_image:
“on”: /local/bedroom.jpg
“off”: /local/bedroom-bw.jpg
The entity for the switch: switch.tv
The entity for the TV state: media_player.bedroom_tv
Anyone tried to use something like that?
You need to add a service (turn_on, turn_off) and then pass that service to your TV’s entitiy ID (service-call). Unfortunately, there aren’t any examples of how to do service calls on the picture entity instruction page. Take a look at the bottom of the picture elements page. You’ll see proper examples with the use of service and service-data there.
I’m sorry, but it didn’t help me
if you could be a bit more specific.
Direct copy and paste from the link I gave you. Your tap action needs to use a service call (i.e. turn on or turn off) to your Broadlink Mini.
tap_action:
action: call-service
service: media_player.media_play_pause #(CHANGE THIS TO THE SERVICE CALL SPECIFIC TO YOUR BROADLINK)
service_data:
entity_id: media_player.living_room #(PLACE THE ENTITY ID FOR YOUR BROADLINK HERE)
1 Like
Tried it with different services, but it still don’t work.
The Broadlink service is a bit difficult, so I’ve tried a more obviouse service, Spotify:
- title: main
icon: mdi:television
cards:
- type: picture-entity
entity: media_player.bedroom_tv
tap_action:
action: call-service
service: media_player.media_next_track
service_data:
entity_id: media_player.spotify
state_image:
“on”: /local/bedroom.jpg
“off”: /local/bedroom-bw.jpg
When I tap on the picture, it’s still showing the state of the Bedroom TV (media_player.bedroom_tv)
There more I think about your scenario, the more I think you might need to create two different versions of this card, one for each state, and then nest each card underneath a conditional card. I used this trick to show two different icons based on the state of an entity. Here’s an example that I use.
- type: conditional #Only shows when the light is On
conditions:
- entity: light.hallway_master
state: "on"
card:
type: "custom:card-modder"
style:
border-radius: 10px
card:
type: "custom:button-card"
entity: light.hallway_master
icon: mdi:toggle-switch
name: Hallway
show_state: true
- type: conditional #Only shows when the light is off
conditions:
- entity: light.hallway_master
state: "off"
card:
type: "custom:card-modder"
style:
border-radius: 10px
card:
type: "custom:button-card"
entity: light.hallway_master
icon: mdi:toggle-switch-off-outline
name: Hallway
show_state: true
The tricky part is going to be your use of multiple entities and ensuring that a scenario won’t exist where both cards would be displayed at the same time. It’ll definitely take some trial and error. The nice part about Conditional Cards is you can specify multiple entities and their expected state. Check out the first example on the Conditional Card document page to see an example.
but where is the tap action in your example?