Giter Site home page Giter Site logo

cgiesche / streamdeck-homeassistant Goto Github PK

View Code? Open in Web Editor NEW
747.0 22.0 38.0 3.68 MB

Control your Home Assistant devices from StreamDeck

License: MIT License

JavaScript 51.23% HTML 1.18% Vue 47.50% SCSS 0.08%
homeassistant streamdeck plugin

streamdeck-homeassistant's Introduction

StreamDeck Home-Assistant Plugin

The aim of this project is to allow owners of an elgato StreamDeck to control their entities or display sensor data via their StreamDeck. As the code is very generic, nearly every sensor should work out of the box as well as every service that does not need any more information but the entity id.

img.png

Features

Generic functions for any Home Assistant entity

  • Display state and additional attributes via customizable templates
  • Call services when a StreamDeck button is pressed (or hold for some time)

Entities with background-icons

  • Switches
  • Lights (same icon as switches)
  • Input Boolean (same icon as switches)
  • Binary Sensors
    • Plugs
  • Temperature
  • Humidity
  • Pressure
  • Power
  • Voltage
  • Battery-Level
  • Weather
  • Vacuum robots (experimental, tested with Roborock S5)

Installation

Prerequisites

  • Installed Stream-Deck application
  • Connected Stream-Deck

Installation

Via the official Stream Deck store

You can find and install this plugin from the official Stream Deck Store

Manual installation (not recommended)

  • Download the latest plugin release here
  • Open the downloaded .sdplugin file. It will be automatically installed into your Stream-Deck application

Configuration

There are two sections on the plugin's configuration panel:

  • Home Assistant Settings
    Contains global settings for your Home Assistant installation. Once saved, the settings are used for all Stream-Deck buttons.
  • Entity Settings Contains settings for an individual button.

Home Assistant Settings

  • Server URL: ws://your-homeassistant-ip-or-hostname:your-homeassistant-port/api/websocket, for example (local network) ws://192.126.0.5:8123/api/websocket or (public, with ssl enabled on default port 443) wss://my-secure-homeassistant.com/api/websocket.
  • Access Token: An long-lived access-token (with admin right) obtained from your Home Assistant. The plugin requires the admin rights, because it uses "execute-script" command that is restricted to admin users. Long-lived access tokens can be created using the "Long-Lived Access Tokens" section at the bottom of a user's Home Assistant profile page. (Quote from https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token)

After you save your Home Assistant Settings, the plugin will automatically try to connect to your Home Assistant installation. If the connection was successful, the Entity Settings section should allow you to see and configure your entities.

img_1.png

Entity Settings

Basic configuration

  • Domain: Home Assistant entities are grouped by domains. Select the domain (for example "switch") of an entity, you want to configure.
  • Entity: This is the actual entity you are going to configure (for example "Kitchen Light")
  • Service: The service will be called when you press the StreamDeck button (green marker at the top right corner).
  • Service (long press): The service that will be called every time you press and hold the StreamDeck button for more than 300ms (blue marker at the top right corner).
  • Service Data JSON: JSON formatted data that is sent with your service call when you press a button. Example:
    {
      "brightness": 120,
      "rgb_color": [255, 0, 0]
    }
    
    If not specified in the JSON, the attribute entity_id is being added automatically containing the selected entity's id. You can also specify the target entity_id manually, for example to switch multiple lights at once:
    {
      "entity_id": [
        "switch.osram_plug_01_bac00b0a_on_off",
        "switch.osram_plug_01_87c00a0a_on_off"
      ],
      "brightness": 120,
      "rgb_color": [255, 0, 0]
    }
    
    You can also use Jinja2 templates to dynamically process data based on the states or attributes of your Home Assistant entities. See Using Jinja2 Templates in Service Data JSON for more information.

img.png

Advanced configuration

  • Custom Title: Enable to override the main Title of this button. You have to clear the main Title field on top to make this work!

    • Title Template: A nunjucks template that will be used as the button's title. You can use any of the variables (depending on the selected entity) that are shown below the text-field. For example {{temperature}}ยฐC or {{friendly_name}} or (this won't fit the button, but you get the idea) The pressure is {{pressure}} and the wind speed is {{wind_speed}}.
      • The variable {{state}} always contains the "main state" of an entity (for example "on" and "off" for buttons or "12.4" for temperature sensors)
    • The variable {{unit_of_measurement}} often contains the ... unit of measurement ... of a sensor's state (for example "ยฐC" for a temperature sensor)
  • Custom Labels: Every button can display up to 4 lines of information

    • Each line in the text-box represents one line on the button

    • Depending on if there is an icon or a title for the entity, you may need to leave blank lines in order to not mess up the layout :)

    • You can use nunjucks template for dynamic content (see above).

      After you hit the save button, the button should immediately show the new configuration.

      img.png

  • Using Jinja2 Templates in Service Data JSON

    • Jinja2 Template Integration: You can incorporate Jinja2 templates within the Service Data JSON to dynamically process data based on the states or attributes of your Home Assistant entities.

    • Encapsulation with Raw Tags: It's crucial to enclose Jinja2 templates within {% raw %} and {% endraw %} tags. This encapsulation ensures that the StreamDeck plugin processes these templates as Jinja2, distinct from any Nunjucks templates you might use elsewhere in your configurations.

    • Example of Jinja2 Template Usage:

        {
        "temperature": "{% raw %}{{ state_attr('climate.ff_office_heating','temperature') + 0.5 }}{% endraw %}"
        }

Happy? Consider donating me a coffee :)

buy me a coffee

streamdeck-homeassistant's People

Contributors

carlosmn avatar cgiesche avatar joshmedeski avatar marcomsousa avatar philippwaller avatar tobidi0410 avatar ybizeul avatar zarmstrong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

streamdeck-homeassistant's Issues

How to specify Service Data

I am not sure if I get the full concept. Yet. Toggling a light or turning it on/off works.

I miss the possibility to specify service data for a more complex service. Think of climate and set_preset_mode. I would like to specify the mode like
{ "entity_id": "climate.temperatur_arbeiten", "preset_mode": "comfort" }

Am I missing something?

Sperate icons for switches

Hi,

first of all thanks you so much for this integration! Works great for me so far and one step further to retire my Homey ๐Ÿ˜„
There is one thing that would be very useful for me.
Other StreamDeck Apps have the abilty to set an icon for when the switch is turned on and a different icon for when its turned off (see Screenshots attached).
2021-02-04 01_01_26-Stream Deck
2021-02-04 01_01_19-Stream Deck

Would be really helpful to also have this option with your App.

Thanks in advance!

Regards
rvst

Button misconfiguration issues

When, for example, saving an invalid template for one button, the button image fails to update and causes (some) other buttons to fail to update, too.

  • Correctly configured buttons should not be affected by "defective" buttons
  • Misconfigured buttons should show an error instead of previous image.

sensor and action?

Is it possible to have a sensor displayed and when pressed preform an action?

e.g. room temperature and when pressing that button on the stream deck toggle a fan?

Add "generic" services to services dropdown.

Lights do not (any more) offer domain specific services to turn them on or off. They rely on generic services that are available for entities of all domains:

homeassistant.turn_on - Turns on an entity (that supports being turned on), for example an automation, switch, etc.
homeassistant.turn_off - Turns off an entity (that supports being turned off), for example an automation, switch, etc.
homeassistant.toggle - Turns off an entity that is on, or turns on an entity that is off (that supports being turned on and off)
homeassistant.update_entity - Request the update of an entity, rather than waiting for the next scheduled update, for example Google travel time sensor, a template sensor, or a light

Add those services to every entity.

Option to show "last changed" time

It would be awesome to have a nunjucks variable to show the "last_changed" and "last_updated" time values of entities.
This information is not part of the state attributes but should be accessible.

Is it possible to add this?

Logging when connection isnt available

When setting this up, I am putting in my HA URL per the example alongside my access token, but the app is not showing me domain, entities, etc. I assume the connection isn't being made but I can't tell. Is there any way to diagnose this further through logging in either Stream Deck or HA?

Timer {{remaining}} not updated

When showing a timer on a button, the {{remaining}} variable will only show the start value and won't be updated afterwards. The Idle/Active variable is, however, updated real time.

Redesign internal state architecture

Redesign internal state architecture to be able to access cross-entity-states inside templates. (#11)
=> states of all entities stored and accessible from all contexts1

Weather entity showing Celsius symbol with Fahrenheit temp

streamdeck-homeassistant-55/Home Assistant core-2021.11.5

Weather on the server side is set to Fahrenheit but it seems the celcius symbol is hard coded into the Weather entity button. Data is showing up correctly. If I attempt {{unit_of_measurement}} as a custom label nothing resolves.

Multiple Servers

I would like the ability to access multiple servers on the same profile. Maybe there is a work around?

Thanx, Michael

Failed to connect to HA

Hi everyone,
i'm trying this plugin but i can't connect with my HA.
MacMini osx10.15.7
Stream Deck Version: 5.1.3 (14750)
HA: Home Assistant OS 2021.12.2

The error I get on Stream Deck is "Failed to connect to ws: //...etc"
while going into the system log of HA I get this error:

2021-12-16 15:09:57 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1183, in _sendfile_fallback
read = await self.run_in_executor(None, file.readinto, view)
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 514, in start
resp, reset = await task
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 460, in _handle_request
reset = await self.finish_response(request, resp, start_time)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 613, in finish_response
await prepare_meth(request)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_fileresponse.py", line 286, in prepare
return await self._sendfile(request, fobj, offset, count)
File "/usr/local/lib/python3.9/site-packages/aiohttp/web_fileresponse.py", line 99, in _sendfile
await loop.sendfile(transport, fobj, offset, count)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1162, in sendfile
return await self._sendfile_fallback(transport, file,
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 1192, in _sendfile_fallback
await proto.restore()
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 263, in restore
self._transport.resume_reading()
File "/usr/local/lib/python3.9/asyncio/sslproto.py", line 343, in resume_reading
self._ssl_protocol._transport.resume_reading()
AttributeError: 'NoneType' object has no attribute 'resume_reading'

Why didn't you use home-assistant-js-websocket?

So not an issue with the code, but a question.

Home Assistant maintains home-assistant-js-websocket. A JS lib that is also used by the frontend and the Node-Red plugin to communicate with Home Assistant.

I see that you created your own for this plugin. Did you miss any functionality that you decided to go down this path?

Cannot Save Setting

I have tried entering the wbsocket address as
wss://:/api/websiocket per the readme. I've also tried ws:// (per the example)

I cannot get the "exclamation" icon to go "green"

The same goes for entering my long-term-access token.

Can enter is manually to avoid the validation process?

Green Circle in the top right?

As soon as I choose a service for the light that I have selected, what seems like part of a green circle appears in the top right corner of the icon on the stream deck. Why is this?
Clipboard01

Media Player toggle not working

I've tried to use the toggle function for a media_player domain but it doesn't do anything.

Happy to help troubleshoot if I can be told where to look.

I'm running StreamDeck on a Mac (version 4.9.4 (13228)) and version 1.3.1 of the Plugin. I'm on Home Assistant version 2021.5.3.

Custom Images?

First off, great app. Congrats and thanks so much for sharing here!

I have been using IFTTT so far to integrate to my smart home devices. I have spend many hours and days creating beautiful custom on / off icons. I would like to use them, how can I do that in your app? I can set one icon it seems, but no toggle icon. I have even created some animated gif which I use for countdowns and so on. Worked great in the IFTTT integration. Seems like I can only use one icon with your integration? Any plans to let us create custom toggle buttons?

Quite honestly, I get were you are coming form with your dynamically created icons. But believe me, it wont work. Most of the time the label text is not even fully visible. I have tried it so many times before myself. It will only be nice if you create custom icons (after all, we set them up once and that is it).

Anyway, thanks again for your hard work. I think I can say that we all appreciate it very much.

Cheers,
Walter

Toggle option not working/updating status

I'm having an issue where the toggle option is not working constantly. it will turn on a switch but doesn't change the icon to the on position. The green dot is there stating it is connected. (for my Tuya switches) the Phillips light works fine. Could this be an issue on the home assistant side? the toggle works fine on their portal.

possible to dim light?

I'm struggling to figure this out; is it possible to turn on a light to a certain percentage? I assume I'd use something like this in the Service Data JSON, but it doesn't seem to work:

[
  {
    "service": "light.turn_on",
    "target": {
      "entity_id": "light.office_cans"
    },
    "data": {
      "brightness": 50
    }
  }
]

Is this possible? Thanks!

Feature Request: Option to show state when using custom icon

When I add a custom icon to an entity, the state disappears. It also doesn't come back if I try to use a custom label like {{state}}. Is it currently possible to have a custom label or show the state when you add a custom icon? If not, it would be a great feature to have.

Does this work on MacOS?

When clicking the downloaded plugin, the Stream Deck app opens, but nothing seems to be installed.

Feature Request: Non-binary sensors

I have tried to configure a text sensor. I see it is not on the list on the readme page, so I assume it isn't implemented yet?
I would like to be able to configure a button that just shows the the state of the entity - For example, I want to show a watts reading.

When I try to assign it, the button seems to get stuck on the previous entity. For example, I set it to a temperature entity, then try to set is to my watts entity, but it keeps showing the temperature entity in a 'frozen' state.

Thanks

Edit: Adding image of the entities
image

Trying to use this on LegatoLegacy

Hi, thanks for the work on the plugin.
Just wanted to check with you on whether this should be compatible with the legacy version of StreamDeck that has been modified to work on Win7/8 etc?
I know this is a very small use case but there are still some who use win7 and doesn't seem like it would take a lot of work to make it work?

https://github.com/atom0s/ElgatoLegacy

I've tried it but settings for the plugin just has Title, nothing else.

Suggestion: stop opening external window by default (PI)

I like to move buttons around a lot, but thi splugin opens the settings window every time I select a button in the configuration. It makes the proces very slow an tedious. Would it be possible to only open the settings when pressing a button (like Elgato's example plugin has)?

data JSON fails

I want to set up a button to turn on my HVAC with heat mode, not auto.
image

So I've added this into the data JSON field:
{data: "hvac_mode": "heat"}

Somehow the command is not being sent. I've tested it in HA, under developer tools, with the following code, and the HVAC turn on, straight to heat.

service: climate.set_hvac_mode data: hvac_mode: heat

What am I doing wrong?

Templating in custom labels

Before I throw in a suggestion, please let me thank you for creating this. This is awesome. The channel back from HA to SD was missing so far and you closed that gap. Thank you.

I like the possibility to feed back values from HA onto the SD keyboard.

May I suggest adding full templating possibilities. Think of showing the volume for a media_player with
{{volume_level}} showing a value between 0 and one like 0.38. Can we improve that ideally with making use of the templating engine which exists in HA.

Think of {{ (state_attr('media_player.ralf', 'volume_level') * 10) | round(0) * 10 }} . Possibilities would be endless.

Custom Labels don't work with custom images

Great plugin, i only got my streamdeck today so apologies if I am being dumb

It seems when i set a custom image i can't get any of the 3 custom templates to work

Here it is without a custom icon
image

Here with a custom icon
image

Am i missing something?

Enhancement: Graphs for Sensors

This is already outstanding work! The only thing that would push it over the top is if we could get graphs for sensor data. Would love to see the history for my temp sensors! The HwInfo stream deck plugin is doing something super similar.

Thanks again for a killer plugin!

Can't access HA

Running HA on a docker container. The server is on the same local network.

Created a long access token.

Tried using http:// ws:// https:// wss:// with the local ip aswell as the public ip (which I can access via other devices).

Doesn't do anything and my HA doesn't produce an error log ie incorrect login attempt.

Feature Request: Custom Icons by State

First, this is an amazing plugin. It's literally the reason why I bought two Stream Decks. So far it works great. Is it possible to have a custom icon for binary switches like lights, switches and input booleans? Obviously, there are the icons that come with the plugin, so it's possible. If it's not possible through the Stream Deck app, is it possible to edit it some other way? Or is this a feature you could add?

Small green dot visible on icons

The sandard entity switch icons have a small greent dot visible in the top right corner, making them awkard to look at - not sure if there's something specific causing this or if iot's just an oversight?

Also, THANK YOU for making this. I had no idea there was even plugins available that were not in the official app.
Is there a reason this cannot be published to the offical app? I think it would increase visibility of the project and get it into more users hands.

thanks again.

Information Not Saving

I configure everything (websocket address, token) and it seems to connect to the server. I configure the entity, in this case a light toggle, and click save config. However, when I click off of the newly created button and then back on, everything is blank. Have tried this multiple times and it doesn't seem to save anything inside the button text fields.

Group Domain Limitations

There are limitations on the types of service calls for groups (set, reload, or remove). Is it possible to add similar service calls like other on/off devices: turn_on, turn_off, and toggle?

Allow to add static payload to service call

  • If an action is selected in PI, show text-field that allows to add payload for service call
  • Validate if payload is valid JSON before saving
  • Send payload when performing service call

Mac install?

I cannot get this to install. I'm very excited to get this to work. Will this only work on a PC? I try to add the plugin and it opens but nothing changes in the stream deck.

Thanks in advance.
Rob

How to turn on two lights at the same time

I have a couple Elgato Key Light Airs. The stupid Elgato Command Center keeps getting disconnected from the key lights. However, HA has no problem turning the lights on and off!

So I want to turn the lights on with this plugin on StreamDeck. Was really simple to have it control one light. Worked like a charm!!!

However, I want it to turn both my lights on at the same time. Not sure how to do that. I'm thinking some level of JSON code in the entity payload will do the trick. But where can I find more info on what that should look like?

Title disappears on experimental button

Hello,

The new on/off icons is cool! Is it just me that the title vanishes when the icon toggles?

Off:
image

On:
image

Domain: Light
Service: Toggle

Title cleared, custom set to friendly name.

image

(Default Settings act the same)

Icons used are from material design: Bulb-Outline & Bulb-on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.