Home Assistant Streamdeck Yaml

Control Home Assistant on Stream Deck with support on all operating systems and configuration via YAML

Home Assistant on Stream Deck

Configured via YAML (with templates) and running on Linux, MacOS, and Windows

Introducing: Home Assistant on Stream Deck!

If you use Home Assistant and want a seamless way to control it, you've come to the right place. With this Python script, you can control your Home Assistant instance via a Stream Deck, making it easier than ever to manage your smart home devices and scenes.

Key Features:

  • Easy to use
  • Highly customizable
  • Home Assistant Add-on support
  • Supports Linux, MacOS, and Windows
  • YAML configuration
  • Runs from same machine as Home Assistant
  • Template support for advanced customization
  • Automatically sync state of entity_id to turn display on/off


Why choose our solution over others?

You might have seen a similar project (cgiesche/streamdeck-homeassistant) on Github before []. However, our solution is more versatile and allows you to connect a Stream Deck to the same Linux machine where Home Assistant is running. The native Stream Deck software doesn't support Linux, but we've got you covered with the help of the python-elgato-streamdeck library. If you are looking for some inspiration, check out the >20 Button Configurations ideas section below.

Check out the video below to see it in action!


๐Ÿ“š Table of Contents

Share Your Success

I love hearing from users! If you're using Home Assistant StreamDeck YAML in your projects, please consider opening an issue on the GitHub repository to let me know. Your feedback and success stories not only help to improve the library but also inspire others in the community. By sharing your experience, you can contribute to the growth and development of Home Assistant StreamDeck YAML. I truly appreciate your support!

๐Ÿš€ Getting Started

Follow the steps below to get up and running with Home Assistant on Stream Deck.

๐Ÿก Installation as Home Assistant Add-on

Click to expand.
  1. In your Home Assistant instance, navigate to Supervisor > Add-on Store.
  2. Click the menu icon (three vertical dots) in the top right corner and select Repositories.
  3. Add the following repository URL: https://github.com/basnijholt/home-assistant-streamdeck-yaml-addon.
  4. The add-on should now appear in the Add-on Store. Click on "Home Assistant Stream Deck YAML" and then click "Install".
  5. After the installation is complete, configure the add-on using either the .env file or the individual configuration options (see the add-on configuration documentation for more information).
  6. Start the add-on and check the logs for any errors.

๐Ÿณ Installation with Docker

Click to expand.
  1. Edit the .env.example file and rename it to .env.
  2. Setup a configuration.yaml file (see below).
  3. Install Docker, see this page for instructions
  4. Use the basnijholt/home-assistant-streamdeck-yaml:latest Docker image with:
docker run --rm -it --privileged --env-file=$(pwd)/.env -v $(pwd)/configuration.yaml:/app/configuration.yaml basnijholt/home-assistant-streamdeck-yaml:latest

Or use the a docker-compose file, an example of which is here: docker-compose.yaml

Optionally, you can build the Docker image yourself with:

docker build -t basnijholt/home-assistant-streamdeck-yaml:latest .

๐Ÿ’ป Installation without Docker

Click to expand common steps for Linux ๐Ÿง, ๐ŸŽ MacOS, and ๐Ÿ–ฅ Windows.
  1. Run pip install -e . in the repo folder to install the required dependencies.
  2. Edit the .env.example file and rename it to .env.
  3. Setup a configuration.yaml file (see below).
  4. Follow the platform-specific steps for Linux, MacOS, or Windows.

๐Ÿง Linux

Click to expand.

On Linux you need to install some extra dependencies:

sudo apt-get update
sudo apt-get install -y libudev-dev libusb-1.0-0-dev libhidapi-libusb0 libffi-dev

and add a udev rule to allow access to the Stream Deck, run sudo nano /etc/udev/rules.d/99-streamdeck.rules and add the following line:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0fd9", GROUP="users", TAG+="uaccess"

๐ŸŽ MacOS

Click to expand.

On MacOS you need to install some extra dependencies:

brew install hidapi cairo libffi

๐Ÿ–ฅ Windows

Click to expand.

For Windows, see this page.

โš™๏ธ Configuration

  1. Create a configuration.yaml file in the same directory.
  2. Choose one of the two usage options:
  • Option 1: With environment variables. (See .env.example for details)
  • Option 2: With command-line arguments. (Run home-assistant-streamdeck-yaml -h to see the available options)

You're all set!

Now you can enjoy controlling your smart home devices with ease. Check out the configuration.yaml file for an example configuration or feel free to share your own with the community.

Happy controlling!

๐Ÿ“„ configuration.yaml

Here's an example configuration.yaml file to help

brightness: 100  # Default brightness of the Stream Deck (0-100)
state_entity_id: binary_sensor.anyone_home  # Entity to sync display state with
auto_reload: true  # Automatically reload the configuration file when it changes
  - name: Home
      - entity_id: light.bedroom_lights
        service: light.toggle
        text: |
      - icon: netflix.png
        service: script.start_spotify
      - icon: xbox.png
        service: script.start_xbox
      - icon_mdi: restart
        service: homeassistant.restart
        text: |
      # Special light control page
      - entity_id: light.living_room_lights
        special_type: light-control
          colormap: hsv
        text: |
          Living room

      # Move pages
      - special_type: previous-page
      - special_type: next-page
  - name: Example
      # Empty button
      - special_type: empty
      # Change pages
      - special_type: go-to-page
        special_type_data: Home
      - special_type: go-to-page
        special_type_data: 0
      - special_type: previous-page
      - special_type: next-page
  - name: Other
      # Spotify playlist
      - service_data:
          id: playlist:37i9dQZF1DXaRycgyh6kXP
          source: KEF LS50
        icon: "spotify:playlist/37i9dQZF1DXaRycgyh6kXP"  # Downloads the cover art
        service: script.start_spotify
      # (Advanced) Use templates!
      - entity_id: media_player.kef_ls50
        service: media_player.volume_set
          volume_level: '{{ (state_attr("media_player.kef_ls50", "volume_level") - 0.05) | max(0) }}'
          entity_id: media_player.kef_ls50
        text: '{{ (100 * state_attr("media_player.kef_ls50", "volume_level")) | int }}%'
        text_size: 16
        icon_mdi: "volume-minus"
      - special_type: go-to-page
        special_type_data: 0

๐Ÿ“‹ Config YAML configuration

Each YAML config can take the following configuration

Variable name Description Default Type
pages A list of Pages in the configuration. List[Page]
anonymous_pages A list of anonymous Pages in the configuration. These pages are hidden and not displayed when cycling through the pages. They can only be reached using the special_type: 'go-to-page' button. Designed for single use, these pages return to the previous page upon clicking a button. List[Page]
state_entity_id The entity ID to sync display state with. For example input_boolean.streamdeck or binary_sensor.anyone_home. None Optional[str]
brightness The default brightness of the Stream Deck (0-100). 100 int
auto_reload If True, the configuration YAML file will automatically be reloaded when it is modified. False bool

๐Ÿ“‘ Page YAML configuration

Each button can take the following configuration

Variable name Description Default Type
name The name of the page. str
buttons A list of buttons on the page. List[Button]

๐Ÿ”ณ Button YAML configuration

Each button can take the following configuration

Variable name Allow template Description Default Type
entity_id The entity_id that this button controls. This entitity will be passed to the service when the button is pressed. Optional[str]
service The service that will be called when the button is pressed. Optional[str]
service_data The service_data that will be passed to the service when the button is pressed. If empty, the entity_id will be passed. Optional[Mapping[str, Any]]
target The target that will be passed to the service when the button is pressed. Optional[Mapping[str, Any]]
text The text to display on the button. If empty, no text is displayed. You might want to add \n characters to spread the text over several lines, or use the | character in YAML to create a multi-line string. str
text_color Color of the text. If empty, the color is white, unless an entity_id is specified, in which case the color is amber when the state is on, and white when it is off. Optional[str]
text_size Integer size of the text. 12 int
text_offset The text's position can be moved up or down from the center of the button, and this movement is measured in pixels. The value can be positive (for upward movement) or negative (for downward movement). int
icon The icon filename to display on the button. Make the path absolute (e.g., /config/streamdeck/my_icon.png) or relative to the assets directory (e.g., my_icon.png). If empty, a icon with icon_background_color and text is displayed. The icon can be a URL to an image, like 'url:https://www.nijho.lt/authors/admin/avatar.jpg', or a spotify: icon, like 'spotify:album/6gnYcXVaffdG0vwVM34cr8'. If the icon is a spotify: icon, the icon will be downloaded and cached. The icon can also display a partially complete ring, like a progress bar, or sensor value, like ring:25 for a 25% complete ring. Optional[str]
icon_mdi The Material Design Icon to display on the button. If empty, no icon is displayed. See https://mdi.bessarabov.com/ for a list of icons. The SVG icon will be downloaded and cached. Optional[str]
icon_background_color A color (in hex format, e.g., '#FF0000') for the background of the icon (if no icon is specified). #000000 str
icon_mdi_color The color of the Material Design Icon (in hex format, e.g., '#FF0000'). If empty, the color is derived from text_color but is less saturated (gray is mixed in). Optional[str]
icon_gray_when_off When specifying icon and entity_id, if the state is off, the icon will be converted to grayscale. bool
delay The delay (in seconds) before the service is called. This is useful if you want to wait before calling the service. Counts down from the time the button is pressed. If while counting the button is pressed again, the timer is cancelled. Should be a float or template string that evaluates to a float. Union[float, str]
special_type Special type of button. If no specified, the button is a normal button. If next-page, the button will go to the next page. If previous-page, the button will go to the previous page. If turn-off, the button will turn off the SteamDeck until any button is pressed. If empty, the button will be empty. If go-to-page, the button will go to the page specified by special_type_data (either an int or str (name of the page)). If light-control, the button will control a light, and the special_type_data can be a dictionary, see its description. If reload, the button will reload the configuration file when pressed. Optional[Literal['next-page', 'previous-page', 'empty', 'go-to-page', 'turn-off', 'light-control', 'reload']]
special_type_data Data for the special type of button. If go-to-page, the data should be an int or str (name of the page). If light-control, the data should optionally be a dictionary. The dictionary can contain the following keys: The colors key and a value a list of max (n_keys_on_streamdeck - 5) hex colors. The colormap key and a value a colormap (https://matplotlib.org/stable/tutorials/colors/colormaps.html) can be used. This requires the matplotlib package to be installed. If no list of colors or colormap is specified, 10 equally spaced colors are used. Optional[Any]

๐Ÿ’ก More than 30 Button Configurations ideas

Here are >30 interesting uses for the Stream Deck with Home Assistant (click on text to expand):

1. Activate a scene:
- service: scene.turn_on
    entity_id: scene.movie_night
  icon_mdi: movie
  text: Movie Night
2. Toggle a cover (e.g., blinds or garage door):
- entity_id: cover.garage_door
  service: cover.toggle
  icon_mdi: "{{ 'garage-open' if is_state('cover.garage_door', 'open') else 'garage-lock' }}"
  text: "{{ 'Open' if is_state('cover.garage_door', 'open') else 'Close' }}"
3. Start or stop the vacuum robot:
- entity_id: vacuum.cleaning_robot
  service: >-
    {% if is_state('vacuum.cleaning_robot', 'docked') %}
    {% else %}
    {% endif %}
  icon_mdi: robot-vacuum
  text: >-
    {% if is_state('vacuum.cleaning_robot', 'docked') %}
    {% else %}
    {% endif %}
4. Mute/unmute a media player:
- entity_id: media_player.living_room_speaker
  service: media_player.volume_mute
    entity_id: media_player.living_room_speaker
    is_volume_muted: >-
      {% if is_state_attr('media_player.living_room_speaker', 'is_volume_muted', true) %}
      {% else %}
      {% endif %}
  icon_mdi: >-
    {% if is_state_attr('media_player.living_room_speaker', 'is_volume_muted', true) %}
    {% else %}
    {% endif %}
  text: >-
    {% if is_state_attr('media_player.living_room_speaker', 'is_volume_muted', true) %}
    {% else %}
    {% endif %}
5. Control the brightness of a light (+10% on press):
- entity_id: light.living_room_lights
  service: light.turn_on
    entity_id: light.living_room_lights
    brightness: >-
      {% set current_brightness = state_attr('light.living_room_lights', 'brightness') %}
      {% set next_brightness = (current_brightness + 25.5) % 255 %}
      {{ next_brightness | min(255) | int }}
  text: >-
    {% set current_brightness = state_attr('light.living_room_lights', 'brightness') %}
    {% set brightness_pct = (current_brightness / 255) * 100 %}
    {{ brightness_pct | round }}%
6. Toggle a fan:
- entity_id: fan.bedroom_fan
  service: fan.toggle
  icon_mdi: "{{ 'fan' if is_state('fan.bedroom_fan', 'on') else 'fan-off' }}"
  text: |
    {{ 'On' if is_state('fan.bedroom_fan', 'on') else 'Off' }}
7. Lock/unlock a door after 30 seconds:
- entity_id: lock.front_door
  service: lock.toggle
  delay: "{{ 30 if is_state('lock.front_door', 'unlocked') else 0 }}"
  icon_mdi: "{{ 'door-open' if is_state('lock.front_door', 'unlocked') else 'door-closed' }}"
  text: |
    Front Door
    {{ 'Unlocked' if is_state('lock.front_door', 'unlocked') else 'Locked' }}
  text_size: 10
  text_color: "{{ 'green' if is_state('lock.front_door', 'unlocked') else 'red' }}"
8. Arm/disarm an alarm system after 30 seconds:
- entity_id: alarm_control_panel.home_alarm
  delay: "{{ 0 if is_state('alarm_control_panel.home_alarm', 'armed_away') else 30 }}"
  service: "{{ 'alarm_control_panel.alarm_disarm' if is_state('alarm_control_panel.home_alarm', 'armed_away') else 'alarm_control_panel.alarm_arm_away' }}"
  icon_mdi: "{{ 'shield-check' if is_state('alarm_control_panel.home_alarm', 'armed_away') else 'shield-off' }}"
  text: |
    {{ 'Disarm' if is_state('alarm_control_panel.home_alarm', 'armed_away') else 'Arm' }}
  text_color: "{{ 'red' if is_state('alarm_control_panel.home_alarm', 'armed_away') else 'green' }}"

Arm the alarm system in 30 seconds if it's disarmed, disarm it immediately if it's armed.

9. Set an alarm time for the next day:
- service: input_datetime.set_datetime
    entity_id: input_datetime.alarm_time
    time: "{{ '07:00:00' if states('input_datetime.alarm_time') != '07:00:00' else '08:00:00' }}"
  icon_mdi: "alarm"
  text: |
    Set Alarm
    {{ '7AM' if states('input_datetime.alarm_time') != '07:00:00' else '8AM' }}
10. Control a media player (play/pause):
- entity_id: media_player.living_room_speaker
  service: media_player.media_play_pause
  icon_mdi: "{{ 'pause' if is_state('media_player.living_room_speaker', 'playing') else 'play' }}"
  text: "{{ 'Pause' if is_state('media_player.living_room_speaker', 'playing') else 'Play' }}"
11. Control a media player (skip tracks):
- entity_id: media_player.living_room_speaker
  service: media_player.media_next_track
  icon_mdi: skip-next
  text: Next Track
12. Set a specific color for a light:
- entity_id: light.living_room_light
  service: light.toggle
    color_name: blue
  icon_mdi: "{{ 'lightbulb-on' if is_state('light.living_room_light', 'on') else 'lightbulb-off' }}"
  text: Blue Light
13. Adjust the thermostat between two specific temperatures:
- entity_id: climate.living_room
  service: climate.set_temperature
    temperature: "{{ 17 if state_attr('climate.living_room', 'temperature') >= 22 else 22 }}"
  icon_mdi: thermostat
  text: |
    {{ '17C' if state_attr('climate.living_room', 'temperature') >= 22 else '22C' }}
    ({{ state_attr('climate.living_room', 'current_temperature') }}C now)
14. Trigger a script to send a notification to your mobile device:
- service: script.send_mobile_notification
  icon_mdi: bell
  text: Send Notification

Which uses this script (which needs to be defined in Home Assistant):

  alias: "Send Mobile Notification"
    - service: notify.mobile_app_<your_device_name>
        message: "Your custom notification message."
15. Toggle a day/night mode (using an input_boolean):
- entity_id: input_boolean.day_night_mode
  service: input_boolean.toggle
  icon_mdi: "{{ 'weather-night' if is_state('input_boolean.day_night_mode', 'on') else 'weather-sunny' }}"
  text: |
    {{ 'Night' if is_state('input_boolean.day_night_mode', 'on') else 'Day' }}
16. Control a TV (e.g., turn on/off or change input source):
- entity_id: media_player.living_room_tv
  service: media_player.select_source
    source: HDMI 1
  text: HDMI 1
17. Control a group of lights (e.g., turn on/off or change color):
- entity_id: group.living_room_lights
  service: light.turn_on
    color_name: red
  icon_mdi: "{{ 'lightbulb-group' if is_state('group.living_room_lights', 'on') else 'lightbulb-group-off' }}"
  text: Red Group Lights
18. Trigger a script to announce the doorbell:
- service: script.trigger_doorbell_announcement
  text: Doorbell Announcement

Which uses this script (which needs to be defined in Home Assistant):

  alias: "Trigger Doorbell Announcement"
    - service: tts.google_translate_say
        entity_id: media_player.<your_media_player>
        message: "Someone is at the door."
19. Enable/disable a sleep timer (using an input_boolean):
- entity_id: input_boolean.sleep_timer
  service: input_boolean.toggle
  icon_mdi: "{{ 'timer' if is_state('input_boolean.sleep_timer', 'on') else 'timer-off' }}"
  text: |
    {{ 'Cancel' if is_state('input_boolean.sleep_timer', 'on') else 'Set' }}
    Sleep Timer
20. Display current temperature:
- entity_id: sensor.weather_temperature
  text: '{{ states("sensor.weather_temperature") }}C'
  text_size: 16
  icon_mdi: weather-cloudy
21. Toggle Wi-Fi on/off (using a switch):
- entity_id: switch.wifi_switch
          service: switch.toggle
          icon_mdi: "{{ 'wifi' if is_state('switch.wifi_switch', 'on') else 'wifi-off' }}"
          text: |
            {{ 'Disable' if is_state('switch.wifi_switch', 'on') else 'Enable' }}
22. Activate voice assistant:
- service: script.activate_voice_assistant
  icon_mdi: microphone
  text: Voice Assistant

Which uses this script (which needs to be defined in Home Assistant):

  alias: "Activate Voice Assistant"
    - service: media_player.play_media
        entity_id: media_player.<your_media_player>
        media_content_id: "http://<your_url>/<filename>.mp3"
        media_content_type: "music"
23. Start/Stop air purifier:
- entity_id: switch.air_purifier
  service: switch.toggle
  icon_mdi: "{{ 'air-purifier' if is_state('switch.air_purifier', 'on') else 'air-purifier-off' }}"
  text: |
    {{ 'Stop' if is_state('switch.air_purifier', 'on') else 'Start' }}
    Air Purifier
24. Start/stop a security camera recording:
- service: script.toggle_security_camera_recording
  icon_mdi: cctv
  text: Toggle Camera Recording

Which uses this script (which needs to be defined in Home Assistant):

  alias: "Toggle Security Camera Recording"
    - service: camera.record
        entity_id: camera.<your_camera>
        duration: 10
        lookback: 2
        filename: "/config/www/recordings/camera_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4"
25. Enable/disable a nightlight after 30 min:
- entity_id: light.nightlight
  service: light.toggle
  delay: 1800
  icon_mdi: "{{ 'lightbulb-on' if is_state('light.nightlight', 'on') else 'lightbulb-off' }}"
  text: "{{ 'Disable' if is_state('light.nightlight', 'on') else 'Enable' }} Nightlight"
  text_color: "{{ 'red' if is_state('light.nightlight', 'on') else 'green' }}"
26. Control a smart fireplace:
- entity_id: switch.smart_fireplace
  service: switch.toggle
  icon_mdi: "{{ 'fire' if is_state('switch.smart_fireplace', 'on') else 'fire-off' }}"
  text: |
    {{ 'Turn Off' if is_state('switch.smart_fireplace', 'on') else 'Turn On' }}
27. Toggle a smart plug:
- entity_id: switch.smart_plug
  service: switch.toggle
  icon_mdi: "{{ 'power-plug' if is_state('switch.smart_plug', 'on') else 'power-plug-off' }}"
  text: |
    {{ 'Turn Off' if is_state('switch.smart_plug', 'on') else 'Turn On' }}
    Smart Plug
28. Toggle irrigation system:
- entity_id: switch.irrigation_system
  service: switch.toggle
  icon_mdi: "{{ 'water' if is_state('switch.irrigation_system', 'on') else 'water-off' }}"
  text: |
    {{ 'Turn Off' if is_state('switch.irrigation_system', 'on') else 'Turn On' }}
29. Change the position of a cover (e.g., blinds or curtains):
- entity_id: cover.living_room_blinds
  service: cover.set_cover_position
    position: "{{ 0 if state_attr('cover.living_room_blinds', 'position') >= 50 else 100 }}"
  icon_mdi: window-shutter
  text: |
    {{ 'Close' if state_attr('cover.living_room_blinds', 'position') >= 50 else 'Open' }}
30. Toggle a media player (e.g., TV) and show different images:
- entity_id: media_player.tv
  service: media_player.toggle
  icon: >
    {% if is_state('media_player.tv', 'on') %}
    {% else %}
    {% endif %}
  text: >
    Turn {{ 'Off' if is_state('media_player.tv', 'on') else 'On' }}
31. Turn off all lights in 60s:
- entity_id: light.all_lights
  service: light.turn_off
  text: |
    Turn off
    in 60s
  delay: 60
32. Display outside temperature with a ring indicator:
- entity_id: sensor.temperature_sensor_outside_temperature
  icon: >
    {%- set temp = states('sensor.temperature_sensor_outside_temperature') -%}
    {%- set min_temp = -10 -%}
    {%- set max_temp = 40 -%}
    {%- set pct = ((temp - min_temp) / (max_temp - min_temp)) * 100 -%}
    ring:{{ pct | round }}
  text: |
    {%- set temp = states('sensor.temperature_sensor_outside_temperature') -%}
    {{ temp | round(1) }}C

This sets 0% to -10C and 100% to 40C.

33. Reload the `configuration.yaml` file:
- special_type: reload

When pressed, the configuration.yaml is reloaded.

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.