Customization of Home Assistant plugin in Stream Deck

Before we begin: For the purpose of this guide assume the following:
A- On your PC where Stream Deck is installed you have a “D:” drive. I’m using “D:” in this tutorial because files cannot be added to “C:” drive in Windows 11 in a simple way. (when you implement the guide, change the path and driver letter according to your needs)
B- The file name we’ll work with will be called “custom”. (when you implement the guide you can use any name you like)
In addition, you’ll have to have some prior knowledge of how to work with Home Assistant configuration files. You can watch some videos or read other guides for that.

THE GUIDE:

  1. Create a file in your “D:” drive and name it “custom.yml

  2. Copy all the text displayed in the “Reference” link below and paste it into custom.yml. This is the default configuration for Stream Deck Home Assistant plugin as provided by the developer.

Reference: https://raw.githubusercontent.com/cgiesche/streamdeck-homeassistant/refs/heads/master/public/config/default-display-config.yml

  1. Edit any part of the pasted text according to your desires and save your changes. For this you have to know how yaml works in Home Assistant.

  2. In Stream Deck Home Assistant buttons there’s a field captioned “Custom display configuration URL”; in that field paste this “file://d:/custom.yml”

  3. Don’t forget to change the path and file name (the part in italics in step 4 above) to your actual configuration.

  4. Click “Save and reconnect” and you’re done!!

there is so little help on this issue, thank you for at least this much, but would you mind extending your guide with simple feature - custom icon for when the switch is on and when it’s off?

Sorry for the late reply. Just saw this. I’ll try to add more info within the next few days. Sorry for the delay

1 Like

Sorry it took me a long time to do this, I hope it will be helpful:

Before we begin:
1- Customizing specific entities is not possible as far as I know, as of the time of writing this. What is possible, however, is customizing device types.
2- I tried to make additional custom icons appear on Stream Deck, but I failed. If someone knows how to use custom icons in Stream Deck that are already added to Home Assistant, please let us know how.

Note: If an icon is not displaying according to what you expect, try to play around with the options “Prefer icon from plugin” and “Prefer icon from HA” in the Stream Deck plugin. Sometimes this will fix things, but not always.

Now you can customize your Home Assistant buttons on Stream Deck by editing the “yml” file, as mentioned above in the original guide.

1- Open the “yml” file you created in the guide above and scroll down to a section you want to change.
Example: for me, I scrolled down to

 # ======================== On-States ======================
  on:
    color: '#17eb7e'
  playing:
    color: '#ffd484'
  open:
    color: '#ffd484'
  opening:
    color: '#ffd484'
  home:
    color: '#ffd484'
  locked:
    color: '#ffd484'
  heat:
    color: '#ffd484'
  active:
    color: '#17eb7e'
  # =========================================================

This section is the default for all devices. If a device matches a state, the specified color will be shown. The default color is a shade of light orange ‘#ffd484’. I changed the color to green ‘#ffd484’ when devices are in the “active” state, as you can see above.

2- I wanted to change the color and icon of lights depending on the state, so I scrolled down to this section

light:
  labelTemplates:
  icon: mdi:lightbulb
  color: '#888888'
  feedbackLayout: '$B1'
  feedback: |
    {% set defaultBrightness = (255 if state === 'on' else 0) %}
    {% set brightness = attributes.brightness | default(defaultBrightness, true) %}
    {
      "indicator": {{ brightness / 255 * 100 }},
      "value": "{{ (brightness / 255 * 100) | int }}%"
    }
  states:
    unavailable:
      icon: mdi:lightbulb-alert
    on:
      color: '#ffd484'

I modified the “states” to show a different color and, when the light is off, a different icon will be displayed.


    on:
      icon: mdi:lightbulb-on
      color: '#fae94d'
    off:
      icon: mdi:lightbulb-outline

Important: please manage your “spaces”. In “yml” certain lines have to be indented with certain spaces. In the example above, the line “states:” is two spaces inside compared to the line that reads “light:”. In other words, two spaces come before the word “states:”. And the “on” and “off” lines are indented two more spaces compared to “states:”. This means that they start with four spaces. And the “icon:” and “color:” are indented two more spaces.

3- One final change I made was to the air conditioner temperature colors. The original yml read

sensor:
  classes:
    humidity:
      icon: mdi:water-percent
      color: '#2C73D2'
    atmospheric_pressure:
      icon: mdi:thermometer-lines
      color: '#2C73D2'
    temperature:
      icon: mdi:thermometer
      color: |
        {% set numState = state | int %}
        {% if attributes.unit_of_measurement == '°F' %}
          {% set numState = (numState - 32) * 5 / 9  %}
        {% endif %}
        {% if numState <= -20 %}
          #0000FF
        {% elif numState <= -15 %}
          #0040FF
        {% elif numState <= -10 %}
          #0080FF
        {% elif numState <= -5 %}
          #00BFFF
        {% elif numState <= 0 %}
          #87CEFA
        {% elif numState <= 5 %}
          #B0E0E6
        {% elif numState <= 10 %}
          #90EE90
        {% elif numState <= 15 %}
          #ADFF2F
        {% elif numState <= 20 %}
          #FFFF00
        {% elif numState <= 25 %}
          #FFA500        
        {% else %}
          #FF0000
        {% endif %}

I changed it to

sensor:
  classes:
    humidity:
      icon: mdi:water-percent
      color: '#2C73D2'
    atmospheric_pressure:
      icon: mdi:thermometer-lines
      color: '#2C73D2'
    temperature:
      icon: mdi:thermometer
      color: |
        {% set numState = state | int %}
        {% if attributes.unit_of_measurement == '°F' %}
          {% set numState = (numState - 32) * 5 / 9  %}
        {% endif %}
        {% if numState <= 04 %}
          #6226bd
        {% elif numState <= 8 %}
          #0000FF
        {% elif numState <= 12 %}
          #428ffc
        {% elif numState <= 16 %}
          #54ccff
        {% elif numState <= 20 %}
          #61cfc0
        {% elif numState <= 25 %}
          #229c10
        {% elif numState <= 30 %}
          #6ea13b
        {% elif numState <= 35 %}
          #d6d64d
        {% elif numState <= 40 %}
          #ffd000
        {% elif numState <= 45 %}
          #ff9d00        
        {% else %}
          #FF0000
        {% endif %}

If you need to change more stuff, play around with the file. Test and adjust according to your needs. Good luck!

1 Like

This looks exactly like what I am looking for. But I do want to ask a question though. My goal is to show the status of a Discord sensor on the Stream Deck, and so I understand I need the sensor-section, but I am a bit uncertain what else I would need from the large file?

If you have time @ar_0 would you be able to give me a bit of guidance as to how to make the custom yaml file as simple as possible?

I have 3 status I want to color, offline, online and idle, and then 3 colors attached to them. That is the only thing I would need from this custom setup as of now.

Thanks in advance, and awesome work coming up with this :slight_smile:

Hi all, let me share a primitive way to customizing only specific entities that I just found:

_color: >-
    {% if 'formaldehyde' in attributes.friendly_name %}
      {% set numState = state | float(0) %}
      {% if numState <= 0.1 %}
        #00FF00
      {% elif numState <= 0.15 %}
        #FF9900
      {% else %}
        #FF0000
      {% endif %}
    {% else %}
      '#AAAAAA'
    {% endif %}

As I described above, changing the global config (_color) to check attributes.friendly_name works. You may set the friendly_name from HA and use it in the custom yml file to apply it only for the specific entity.
I think it would work for _icon and _labelTemplates as well, but not tried yet.