Cannot get any images to show up on any cards?!

Please help, it’s been 2 weeks and I am throwing in the towel and asking for help. I have been trying to get images to appear in really any card that I find examples online of hoping that one will work and I can reverse engineer it, but ideally the room card as shown through a room card tweak here: https://www.reddit.com/r/homeassistant/comments/154l0aj/minimalist_ui_room_card_tweak/

At the very bottom there is the template code and example. Please somebody look at my code and tell me what the heck I am doing wrong. I think it is just a formating issue, I had the gradients working at one time without the image and I decided to call it a night. I reboot and must have had my tweaks in the wrong custom card dir because just like that it was gone and I havent been able to get it back.

My code looks like this:

---
custom_room_pic_on:
  state:
  - styles:
      card:
        - background-image: >
            [[[
              var opacity = states[variables.custom_picture_brightness_entity].attributes.brightness/variables.custom_picture_brightness_max;
              if (hass.themes.darkMode) {
                return 'linear-gradient(to top right,rgba(' + variables.custom_card_bg_color + ',' + opacity + '),rgba(0,0,0,0))';
              } else {
                return 'linear-gradient(to top right,rgba(' + variables.custom_card_bg_color + ',' + opacity + '),rgba(0,0,0,0))';
              }
            ]]]
        - background-color: rgba(var(--color-background-yellow),var(--opacity-bg))
      icon:
        - opacity: 0.0
      img_cell:
        - background-image: "[[[ return 'url(' + variables.custom_picture + ')'; ]]]"
        - background-size: contain
        - width: 85%
        - height: 85%
        - transition: filter 0.5s, opacity 0.5s, width 0.5s, height 0.5s
      id: 'on'
      value: 'on'
  - styles:
      card:
        - background-color: rgba(var(--color-background-yellow),var(--opacity-bg))
      icon:
        - opacity: 0.1
      img_cell:
        - background-image: "[[[ return 'url(' + variables.custom_picture + ')'; ]]]"
        - background-size: contain
        - filter: grayscale(65%)
        - opacity: 0.25
        - width: 65%
        - height: 65%
        - transition: filter 0.5s, opacity 0.5s, width 0.5s, height 0.5s
      id: 'off'
      value: 'off'
`

And my card looks like this:

    - type: 'custom:button-card'
      template:
        - card_room
        - custom_room_pic_on
      name: Living_room
      entity: light.livingroom
      tap_action:
        action: toggle
      hold_action:
        action: more-info
      double_tap_action:
        action: navigate
        navigation_path: living_room
      variables:
        custom_picture: /local/pictures/living_room.jpg
        custom_picture_brightness_entity: light.livingroom_light
        custom_picture_brightness_max: 188
        custom_card_bg_color: 170,110,1
        label_use_temperature: false
        label_use_brightness: true
        entity_1:
          entity_id: light.livingroom_light
          custom_icon: mdi:lightbulb
          templates:
            - yellow_on
          tap_action:
            action: toggle
          hold_action:
            action: more-info
        entity_2:
          entity_id: light.living_room_tv_light
          templates:
            - purple_on
          tap_action:
            action: toggle
          hold_action:
            action: more-info
        entity_3:
          entity_id: light.upper_landing_light
          templates:
            - green_on
          tap_action:
            action: toggle
          hold_action:
            action: more-info
        entity_4:
          entity_id: sensor.livingroom_tempsense_temperature
          templates:
            - red_on
          tap_action:
            action: more-info
          hold_action:
            action: navigate
            navigation_path: thermostat

I’m new to home assistant (6weeks), I’m a roofer and this became a little project of mine when my son was born and I had a few weeks off and no sleep. I’m working again and would love love love if somebody could help me make this work?! My brain will not let me finish the rest of my dashboard until those damn room cards have pictures of my damn rooms in them haha.

could you step back a sec and explain what you’re trying to accomplish overall?

you have a block where you say it’s your code, and another that says it’s your card… which makes it sound like you’ve got them in completely separate locations.

and it looks like you’ve got variables defined in one scope (where you say your card is) and being used in another place where i’m guessing those variables don’t exist.

if this is your first go, you’ve got a pretty complex first config…

so could you explain overall what you’re trying to achieve… why you have things separated between “your code” and “your card” (both of them look like card specs)

also just to make sure you’ve got the images configed right, have you already replaced all the image locations in your “code” with the direct path (e.g. /local/pictures/living_room.jpg) and made sure that if it gets resolved to what you intend, that the image will show?

sorry, yes the images are in the www/pictures etc and I have tested the path by creating a background image in the default ui dashboard.

so the first set of code is for a custom card adding the custom_picture variables to be used on the room card. It is located in my config/custom_cards/custom_room_pic_on/custom_room_pic_on.yaml

The second set is my home.yaml. In the link I included, if you scroll to the bottom there is what I copied from as well as a screenshot of what I want. However the cusom card code posted is not “preformatted” so I’ve done my best. At one point I did have the yellow background gradient functioning from the lower left to upper right with the brightness variable working as well. Unfortunately, I didn’t realise the 2 custom_card directories and I was in the one that wiped when I restarted and not the dir it pulls from.

Either way I have never gotten an image to work and I really really want to. Title cards etc. lol I feel it brings it to life and with a newborn I can make some fun things down the road that my wife will enjoy haha

those pics you posted are not what you have right? what do you actually get so far? do you have the minimalist card layout all set except for the image?

I presume you have the hacs extension installed properly and tested? sorry if it’s an insulting question … you didn’t mention whether you had done that or how far you are to success.

The first is my dashboard. (In dark mode)


Still working on it. The second imag i posted in lightmode is the room card tweak i am trying to achieve

I got it!! I couldn’t get it to work via a custom card so I just changed every room card individually. Had to change size: contain to cover and a few little preference tweaks. If anybody could shed light on why i am unable to use this in a custom card?

      - type: 'custom:button-card'
        template:
          - card_room
        state:
          - styles:
              card:
                - background-image: >
                    [[[
                      var opacity = states[variables.custom_picture_brightness_entity].attributes.brightness/variables.custom_picture_brightness_max;
                      if (hass.themes.darkMode) {
                        return 'linear-gradient(to top right,rgba(' + variables.custom_card_bg_color + ',' + opacity + '),rgba(0,0,0,0))';
                      } else {
                        return 'linear-gradient(to top right,rgba(' + variables.custom_card_bg_color + ',' + opacity + '),rgba(0,0,0,0))';
                      }
                    ]]]
                - background-color: rgba(var(--color-background-yellow),var(--opacity-bg))
              icon:
                - opacity: 0.0
              img_cell:
              - background-image: "[[[ return 'url(' + variables.custom_picture + ')'; ]]]"
              - background-size: cover
              - width: 95%
              - height: 95%
              - transition: filter 0.5s, opacity 0.5s, width 0.5s, height 0.5s
            id: 'on'
            value: 'on'
          - styles:
              card:
                - background-color: rgba(var(--color-background-yellow),var(--opacity-bg))
              icon:
                - opacity: 0.1
              img_cell:
                - background-image: "[[[ return 'url(' + variables.custom_picture + ')'; ]]]"
                - background-size: cover
                - filter: grayscale(65%)
                - opacity: 0.25
                - width: 75%
                - height: 75%
                - transition: filter 0.5s, opacity 0.5s, width 0.5s, height 0.5s
            id: 'off'
            value: 'off'
        name: Office
        entity: light.office
        icon: mdi:desktop-classic
        tap_action:
          action: toggle
        hold_action:
          action: more-info
        double_tap_action: 
          action: navigate
          navigation_path: office
        variables:
          custom_picture: /local/pictures/office.jpg
          custom_picture_brightness_entity: light.office
          custom_picture_brightness_max: 100
          custom_card_bg_color: 170,110,1
          label_use_brightness: true
          label_use_temperature: false
          entity_1:
            entity_id: light.office_light_switch
            custom_icon: mdi:lightbulb
            templates:
              - yellow_on
            tap_action:
              action: toggle
            hold_action:
              action: more-info
          entity_2:
            entity_id: light.desk_lights
            templates:
              - purple_on
            tap_action:
              action: toggle
            hold_action:
              action: more-info
          entity_3:
            entity_id: media_player.nesthuba11b
            templates:
              - green_no_state
            tap_action:
              action: more-info
          entity_4:
            entity_id: vacuum.baby_shark
            templates:
              - red_on
            tap_action:
              action: more-info

I think in the template code in post 1 the content starting at “- styles:” needs to be intended once more.

That was one of my issues among lots of other small dumb mistakes on my part, such as not including the “custom_card_bg_color: 170,110,1” variable, but been using what I’ve learned to customize other cards and chips!