Show off your picture-elements uses

Thank you @Ildar_Gabdullin , I will look into that and give it a try :slight_smile:

Styling Picture elements
Using card-mod for Picture elements
Styling conditional elements

1 Like

Sorry, found the information when I googled for css styling, so I removed the question before you answered.

But what I hae not fixed yet:
I would like the main image to have a tap_action.

Tap_action for the picture of picture elements card is not supported. So I figured I would simply use my target image in ‘type: image’.
But that leaves me with the issue of defining the (invisible) background image of the picture elements card.

I wanted to use a small “dummy” image to reduce the loading time etc. But I cannot figure out how to scale it to size.

type: picture-elements
elements:
  - type: image
    image: /local/images/alex_half.jpg
    style:
      width: 100%
      height: 100%
      transform: initial
      top: 0%
      left: 0%
    tap_action:
      action: navigate
      navigation_path: /lovelace-home/areas/
  - type: state-label
    entity: person.alex
    style:
      background-color: rgba(0, 0, 0, 0.5)
      bottom: 0
      color: white
      font-size: 12px
      text-align: left
      left: 0
      line-height: 100%
      padding: 0 0
      transform: initial
      width: 100%
image: /local/images/alex_half.jpg

This works, but it loads my alex_half_jpg twice, which is a waste of resources.
If I wanted to change the picture card image to e.g. a 1x1px image, how could I scale it to the size of the ‘type: image’ image?

I noticed that the layout looks quite different in my browser compared to the companion app. So it seems that the layout is not being applied correclty even though I am specifying everything in relative values (%) rather than absolute (px).
Is this a known issue or am I defining something wrongly?

Browser Editor Preview:
image
Browser dashboard after saving:
image

Companion app:

Code:

type: picture-elements
elements:
  - type: image
    image: /local/images/black_50.png
    style:
      bottom: 0%
      left: 0%
      width: 100%
      height: 15%
      transform: none
      background-color: rgba(0, 0, 0, 0.0)
    tap_action:
      action: navigate
      navigation_path: /lovelace-home/persons
    hold_action:
      action: none
  - type: state-icon
    entity: light.ambient_light_lr
    icon: mdi:ceiling-light-outline
    tap_action:
      action: toggle
    style:
      bottom: 0%
      right: 5%
      transform: none
      '--paper-item-icon-color': white
      border-radius: 5px
  - type: state-icon
    entity: light.main_light_lr
    icon: mdi:ceiling-light
    style:
      bottom: 0%
      right: 20%
      transform: none
      '--paper-item-icon-color': white
      border-radius: 5px
    tap_action:
      action: toggle
  - type: custom:slider-entity-row
    entity: climate.eq_3_living_room
    name: Living Room
    full_row: true
    min: 4.5
    max: 23
    step: 0.5
    hide_state: false
    style:
      bottom: 0%
      left: 10%
      transform: none
      '--paper-item-icon-color': white
      border-radius: 5px
  - type: state-label
    entity: sensor.eq_3_battery_living_room
    prefix: (
    suffix: )
    style:
      bottom: 0%
      left: 44%
      transform: none
      color: black
      font-weight: bold
      text-transform: lowercase
      text-shadow: 1px 1px 1px white
      opacity: 50%
      border-radius: 5px
image: /local/images/living_room_16_9.jpg

You can use text-element. It is available via HACS. The code in picture element card looks then following:

type: picture-elements
image: /local/ups_background.png
elements:
  - type: custom:text-element
    text: Your Label
    style:
      top: 90%
      left: 15%
1 Like

Am I the only one to observe this? Or am I doing something wrong?

No, that is common with picture element cards.
As far as I know there is only two ways to deal with it.

Live with it

or

Create different cards for different devices.

I believe a lot of us just sigh and go with #1.

1 Like

Strange. Has an issue been raised on github on this? Relative positions should be identical on all devices. I am terrible at living with things :joy:
Especially since the whole purpose of the picture elements card is to create something “pretty” :wink:

There are problems with scaling.
The same card may look differently on the same Chrome after resizing a windows, not to mention other screen sizes.
For example:

It could be just rounding the numbers that makes those differences.

I doubt that rounding is an issue given the extreme variations.
And if you look at my example above, the shift is not only horizontal but also vertical. So at least the base line should be identical given the identical vertical percentage used.

Scaling should also not be the issue given again that there is a baseline shift. So at least the base line should be identical. Scaling would cause a problem towards the top, not the bottom, IMHO.

The scaling/rounding has to be done both vertical and horizontal.

Yes, but if you define the base line at 0% from bottom then, unless there are multiple problems aside from the actual scaling, the object should be placed at the lowest possible point and then scaled upwards and sidewards from there.
So a horizontal shift would be explained by scaling problems. But a shift downwards if you are already at the lowest point (bottom: 0%), would not be a simple scaling problem. It would be a problem of the initial positioning.

And if the base line is e.g. at pixel 10 from bottom on one display and pixel 50 from bottom at another (each representing 0%), then all objects should be placed at pixel 10 from bottom or pixel 50 from bottom.
You should not see some at pixel 45, some 50 and some 55. Rounding cannot result in different values if the factor is a constant and the rounding is applied to the same variable.

Is it possible to somehow use the horizontal-stack card in picture elements? It seems like it is possible to use custom cards so I am not sure why an integrated card should be any different from a custom card.

Thomas Lovén’s custom hui-element card is usually the way to get around this limitation, but I’ve not tried it myself with a picture elements card, so can’t 100% guarantee it will work in this case. But worth a try I would think.

2 Likes

Thank you @reste_narquois , that seems to do the trick!

I think I get there by now combining grid & button & card-mod. Let’s see how it goes :slight_smile:

Having problems with the transparency overlay on the button click to turn the kitchen on and off.

got this black eclipse popping in there any clue ???

type: picture-elements
image: /local/floorplan/7gp-lights-on.png
elements:
  - type: image
    entity: light.kitchen_main_lights
    tap_action:
      action: none
    hold_action:
      action: none
    state_image:
      'on': /local/floorplan/transparent-square.png
      'off': /local/floorplan/kitchen-off.png
      unavailable: /local/floorplan/kitchen-off.png
    style:
      top: 50%
      left: 50%
      width: 100%
  - type: image
    entity: light.kitchen_main_lights
    tap_action:
      action: toggle
    state_image:
      'on': /local/floorplan/transp.png
      'off': /local/floorplan/transp.png
      unavailable: /local/unavailable.png
    style:
      top: 66%
      left: 60.5%
      width: 10%



any pointers many thanks

Deano

Is it with a default theme?

Not the system default no, it using a orange light theme, do you think it’s an issue with the theme and safari ?

Im beginning to think its a browser thing as the iPad app doesn’t suffer from the same issue.

anyone else want to chip in?

D