cgiesche / streamdeck-homeassistant

Control your Home Assistant devices from StreamDeck
MIT License
772 stars 38 forks source link

Streamdeck Plus #117

Closed rklueber closed 8 months ago

rklueber commented 1 year ago

Hello,

this plugin is my favourite for my streamdeck setup. Recently got hands on the new streamdeck plus. Any plans to support the dials for say "diming a light" in Home Assistant?

If testers are needed ... I am here.

Best Regards. Ralf

cgiesche commented 1 year ago

After a quick look at the Stream Deck API, it doesn't seem hard to implement. The hardest part is finding the time. I'll try.

SergeantPup commented 1 year ago

Hello,

I came here to ask the same thing. I just got one with the knobs and I'd love to turn some of them into light/fan dimmer switches and sonos volume knobs

jelmerkk commented 1 year ago

+1. lousy developer, willing tester

Jerberus commented 1 year ago

+1. Have a Streamdeck Plus, willing tester, willing tinkerer

jer78 commented 1 year ago

I would also love this functionality. I don't have the SD+ yet and the biggest reason holding me back from upgrading is the lack of Home Assistant support for the knobs. Will follow the progress on this and if you need more testers, I would be happy to buy one to help.

cgiesche commented 1 year ago

Hello everyone,

I can understand your interest in extending the plugin and would also have the motivation to tackle the challenge, however without having a StreamDeck+ on site it is hard to do. Considering how often I type around on my existing streamdeck while watching the debug console in parallel, it's clear to me that without that capability (despite your support) it would either take forever or not work at all.

I'm considering buying a StreamDeck+, though it may take a little while. I will keep you guys updated here.

rklueber commented 1 year ago

Give me your paypal via PM and I will sponsor 1/4th of a streamdeck plus for you.

jelmerkk commented 1 year ago

I'm also chipping in.

cgiesche commented 1 year ago

First of all, thank you for your support!

It was not my intention to beg for funding for a StreamDeck+. The development of the plugin is done in my spare time. Free time is the critical point, not so much money. Therefore, I can't guarantee when something will be finished. Getting donations before the plugin has been extended would put pressure on me to deliver a result in a timely manner. I would just suggest that I buy the SD+, and when the plugin is ready and you are happy with it, you may donate me a coffee or two :)

My paypal link is on the right side of the main page of this GitHub project. Click it whenever you want, but please don't put any expectations on it. :)

tioan commented 1 year ago

@cgiesche Since we are both from Germany I can gladly send you my Steamdeck Plus on loan for e.g. 6-12 months for support development. I would then only like to have it back as soon as the model is supported ;-) as long as I'll probably stay with the Steamdeck XL + pedal for now anyway

cgiesche commented 1 year ago

Hi tioan,

thank you for the offer, however, wit generous support from friendly users, I have already purchased an SD+ in the meantime. I will post a short update:

cgiesche commented 1 year ago

Update on work in progress:

I got the dial working (experimental mode, far from finshed) but it is currently kind of a (very) disappointing experience. The Problem is, that the rotation of the dial results in many small method calls, each informing me about a "+-1 tick"-change. If i send each of those small increases to Home-Assistant, the expectation is a nice and smooth "light dimming" experience. In reality, Home-Assistant seems to struggle these many messages and the lights behave weird. I tried to collect rotation ticks within a short period of time (for example 1 second) and then send a single update to Home Assistant, but this feels not good yet and still might to be too fast for HA.

Jerberus commented 1 year ago

Thanks for sharing the latest with us.

Your comment got me thinking about how this might be accomplished with existing HA calls. I know home assistant abstracts a lot of light implementations with its service call. For those that support it, possibly interpreting a number of dial turns into a ‘velocity’ for brightness/dimness would work and then send an update to home assistant with a fade up / fade down. Just playing with it on my HA via an automation, multiple clicks on a call to the light service with a 1 second transition time allowed for some smooth light fading with amount of brightness changes (velocity) updates every second.

Something like:

service: light.turn_on
data:
   transition: 1
   brightness: 30 (aka velocity)

I’m looking at Hue lights controlled via HA, so I’m not sure how globally that type of implementation might work, but it would reduce the number of calls to home assistant while generating light change between home assistant calls (feedback while someone’s turning the dial).

For me, the first thing I do with dials is configure them from changing 1 value per notch of the dial to changing 5 as moving 1 value at a time is a slog and often doesn’t give a perceivable change.

Side note: I just used the Streamdeck + Hue dial control (first party Streamdeck + integration) and it’s super laggy, so I’m not sure how they’re implementing the dials, but I think they’re adding a delay versus giving real-time feedback — and/or my HA <-> Hue Hub connection is laggy. I think giving the user feedback of brightness change while they’re turning the dial should be the primary goal and the number provided on the Streamdeck + panel gives a target end brightness to the user as they’re turning the dial with likely some sort of boomerang leap once you stop turning (depending on how correct the velocity estimate is).

diothar commented 1 year ago

I’m about to buy a Stream Deck. The plus looks nice, but is it working ok now? Or is it a much better experience to buy the older generation? I don’t need anything fancy, but I love the idea of 8-15 or so buttons to just do stuff from my desk.

cgiesche commented 1 year ago

I have a Plus and a normal XL and personally prefer the XL, because I not (yet?) use the Dials from the Plus and I like the amount of buttons and Displays on the XL.

Regarding my plugin, it currently does not support the Dials, but it may in future. I am working (slowly as always) on it 😊.

As always: It depends 😁

diothar commented 1 year ago

Thank you so much for providing such a clear answer to me (I know you don't want to make any promises). Does the Stream Deck MK.2 also perform very well with the plugin? That's the one I'm considering.

eric-keur commented 1 year ago

Thanks for working on the support for the dials on the Stream Deck Plus! I am looking forward to see those in action :)

groto27 commented 1 year ago

Yes thank you for working on this! I’m hoping it will be supported soon 😁

pdawg17 commented 1 year ago

Thank you here as well :)

Willis1776 commented 1 year ago

Update on work in progress:

I got the dial working (experimental mode, far from finshed) but it is currently kind of a (very) disappointing experience. The Problem is, that the rotation of the dial results in many small method calls, each informing me about a "+-1 tick"-change. If i send each of those small increases to Home-Assistant, the expectation is a nice and smooth "light dimming" experience. In reality, Home-Assistant seems to struggle these many messages and the lights behave weird. I tried to collect rotation ticks within a short period of time (for example 1 second) and then send a single update to Home Assistant, but this feels not good yet and still might to be too fast for HA.

Do you have a branch where you're working on it? I've been getting into the development side of stream deck and would love to see if I can contribute at all to the development for Streamdeck plus. Thanks!

MagicMicky commented 11 months ago

Hello! I'm interested to see how this develops! I'm going to try to share how I saw other plugins working and solving the problems you described regarding the disappointing experience.

I've been a user of ControllerX for quite some time. It's very different in how it works, but allows to use zigbee rotary devices to control lights and music.

The way it seems to be working is that the rotary device sends a first zigbee signal with the rotation direction (ie: ROTATING_RIGHT), and sends a new signal on the last event (ie: ROTATION_STOPPED) (there's a time window configurable to detect the last event I believe), and ControllerX on the server side will gradually change the volume / light through a specific rate (10% per second for example). This allows to not have any issues in terms of overflowing the api calls as well as having a smooth change of light / volume. It has downsides which is that the speed of which you turn the device doesn't impact the volume / light, and it's statically defined in the configuration.

I'm not sure if this can help simplify implementation and makes the user experience better but i thought it might be interesting.

Additional docs might be useful: https://xaviml.github.io/controllerx/start/configuration/#parameters I think the explanation over the yaml of the parameters (action_delta, action_delay) might be useful

EDIT: I'm trying to lookup additional strategies for dimming a light without sending 1000s of events a second, a strategy similar to a push-to-dim would probably work as well? A bit similar to what I described above

andrey-kk commented 10 months ago

+1 It would be great if dials are supported. I am looking forward to control fan speed with the dials.

cgiesche commented 9 months ago

I am alive and (again) working on this feature (winter is coming). Thanks so far for all your input! The last days i spent cleaning up the code and reworking a lot of code because I did a major update to the underlying framework.

First (visible) results: grafik

For everyone waiting, i will try to create a public pre-release as soon as possible.

cgiesche commented 8 months ago

Early, unfinished, maybe unstable preview release. It should keep existing settings and work well with non-plus streamdecks, but i can not guarantee! Use at your own risk.

https://github.com/cgiesche/streamdeck-homeassistant/releases/tag/2.3.5

For the dial rotation, you have to configure service data similar to as shown above ("ticks" is the number of ticks, the dial has been rotated).

Please share your thougts.

jelmerkk commented 8 months ago

Works well, 1 remarks based on 1 test: optional entity_id seems mandatory, it did not pick up the "main" entity for me.

SergeantPup commented 8 months ago

Hello,

Thank you so much for working on this; I got it loaded and working.

Screen tap works Dial short/long press work Dial rotation works but I have the ticks set to * 10 just like you and I would expect the brightness to step in 10% increments; however, when I watch it in Home Assistant in real time, the ticks are only equating to 3% each. It does it consistently every time. Am I misunderstanding how it's supposed to step? Here's validation of my ticks setting: 2023-10-18 20_01_30-Stream Deck

nnmalex commented 8 months ago

Hello,

Thank you so much for working on this; I got it loaded and working.

Screen tap works Dial short/long press work Dial rotation works but I have the ticks set to * 10 just like you and I would expect the brightness to step in 10% increments; however, when I watch it in Home Assistant in real time, the ticks are only equating to 3% each. It does it consistently every time. Am I misunderstanding how it's supposed to step? Here's validation of my ticks setting: 2023-10-18 20_01_30-Stream Deck

brightnrss_step works on the scale from 0 to 255. You need brightness_pct for per cent.

cgiesche commented 8 months ago

Works well, 1 remarks based on 1 test: optional entity_id seems mandatory, it did not pick up the "main" entity for me.

Yep. "Optional" is slightly missleading in this case. There are services that do not require an entity to be set... I will remove this hint.

pdawg17 commented 8 months ago

Somehow I'm still not getting the rotation service data right for dimming/brightening a light. It seems I'm supposed to use brightness_pct but can't figure out how to use it for what I want.

SergeantPup commented 8 months ago

Hello, Thank you so much for working on this; I got it loaded and working. Screen tap works Dial short/long press work Dial rotation works but I have the ticks set to * 10 just like you and I would expect the brightness to step in 10% increments; however, when I watch it in Home Assistant in real time, the ticks are only equating to 3% each. It does it consistently every time. Am I misunderstanding how it's supposed to step? Here's validation of my ticks setting: 2023-10-18 20_01_30-Stream Deck

brightnrss_step works on the scale from 0 to 255. You need brightness_pct for per cent.

Thank you for this advice. I plugged it in and it DOES increase in increments of 10.

While testing the rotation, I noticed a behavior that I didn't expect. While I don't have the specifics of the problem mentioned here:

Somehow I'm still not getting the rotation service data right for dimming/brightening a light. It seems I'm supposed to use brightness_pct but can't figure out how to use it for what I want.

I can report my observations.

When testing the rotation, I observed the following behavior: (recall my settings are {"brightness_pct": {{ticks * 10}}, "transition": 0}) When I rotate the knob 1 tick to the right indicating an increase, the light goes to 10% (expected behavior) Through various testing I could get the light to go higher but I couldn't get the light to decrease by 10% Then I realized the actual behavior. You want the light to be at 50%? rotate right 5 ticks. Want it to go to 60% from there? you need to rotate the knob right 6 times. You want it to go to 20%? rotate the knob 2 clicks to the right Why it seemed like the light kept dimming? because every time I only rotated the knob 1-2 ticks it was going to 10%-20% Backwards rotation on the knob (decreasing the value) doesn't work. To dim the lights, rotate the knob to the right, fewer times than it was last turned. Once I understood how it works, it works correctly every time.

So from here I would need clarification to understand if it's working correctly. Does turning the knob to the left do anything? because I haven't observed mine react to that.

I recall the dev being open to suggestions on how to handle this and I'm far from being an expert but what if the starting position was always 0 so then the increase or decrease (ticks turned right or left) from that position adds to/subtracts from the current brightness value?

As a user, if I wanted to set the lights to 80%, I'd just use a voice assistant to do that. For this use case, the ability to just increase/decrease the volume/brightness from it's current position is more valuable to me. It's too dark in here (I don't care what the lights are currently set at), I just want to increase them a little. The knob increasing by the corresponding number of ticks is more important than me knowing to turn it right 8 ticks to get to 80%. Oh, I increased it too much? let me just turn it two ticks to the left to decrease by 20%.

Outstanding work on this integration and it's the first time I've started using my stream deck since I purchased it a year ago. Thank you so much.

pdawg17 commented 8 months ago

Hello, Thank you so much for working on this; I got it loaded and working. Screen tap works Dial short/long press work Dial rotation works but I have the ticks set to * 10 just like you and I would expect the brightness to step in 10% increments; however, when I watch it in Home Assistant in real time, the ticks are only equating to 3% each. It does it consistently every time. Am I misunderstanding how it's supposed to step? Here's validation of my ticks setting: 2023-10-18 20_01_30-Stream Deck

brightnrss_step works on the scale from 0 to 255. You need brightness_pct for per cent.

Thank you for this advice. I plugged it in and it DOES increase in increments of 10.

While testing the rotation, I noticed a behavior that I didn't expect. While I don't have the specifics of the problem mentioned here:

Somehow I'm still not getting the rotation service data right for dimming/brightening a light. It seems I'm supposed to use brightness_pct but can't figure out how to use it for what I want.

I can report my observations.

When testing the rotation, I observed the following behavior: (recall my settings are {"brightness_pct": {{ticks * 10}}, "transition": 0}) When I rotate the knob 1 tick to the right indicating an increase, the light goes to 10% (expected behavior) Through various testing I could get the light to go higher but I couldn't get the light to decrease by 10% Then I realized the actual behavior. You want the light to be at 50%? rotate right 5 ticks. Want it to go to 60% from there? you need to rotate the knob right 6 times. You want it to go to 20%? rotate the knob 2 clicks to the right Why it seemed like the light kept dimming? because every time I only rotated the knob 1-2 ticks it was going to 10%-20% Backwards rotation on the knob (decreasing the value) doesn't work. To dim the lights, rotate the knob to the right, fewer times than it was last turned. Once I understood how it works, it works correctly every time.

So from here I would need clarification to understand if it's working correctly. Does turning the knob to the left do anything? because I haven't observed mine react to that.

I recall the dev being open to suggestions on how to handle this and I'm far from being an expert but what if the starting position was always 0 so then the increase or decrease (ticks turned right or left) from that position adds to/subtracts from the current brightness value?

As a user, if I wanted to set the lights to 80%, I'd just use a voice assistant to do that. For this use case, the ability to just increase/decrease the volume/brightness from it's current position is more valuable to me. It's too dark in here (I don't care what the lights are currently set at), I just want to increase them a little. The knob increasing by the corresponding number of ticks is more important than me knowing to turn it right 8 ticks to get to 80%. Oh, I increased it too much? let me just turn it two ticks to the left to decrease by 20%.

Outstanding work on this integration and it's the first time I've started using my stream deck since I purchased it a year ago. Thank you so much.

You figured it out quicker than I did! (I posted above you) Yes same response for me as well.

cgiesche commented 8 months ago

Thanks for your wall of text :D

The "ticks" contains no absolute value (0-255) but only the number of ticks. Left turn = negative value, right turn = positive value. Those values are summed up for a specific time bucket (~300ms) and then sent to your service config:

Example (quick rotation): 4 Ticks to the left = -4 8 Ticks to the right = 8 7 Ticks to the lieft = -7 After 300ms service is called with ticks = -3

That means, the "ticks" variable is only a difference (step) and no absolute value. Because of that, my example uses brightness_step and not simply brightness or brightness_pct which expect absolute values.

I will add another variable that will contain an absolute value between 0 and 255 (and maybe another containing a "relative" value 0-100) to be more flexible. A downside of those absolute values is, that if you turn them to 255 an then change the brigness level of an entity from another source (like home assistant gui or alexa or whatever), this value would stay unchanged. So if you have your ligth is (externally) turned down to 2 and you then turn the button to the left by 1 tick, it would change the brigtness to 254 instead of (maybe) expected 1.

SergeantPup commented 8 months ago

Example (quick rotation): 4 Ticks to the left = -4 8 Ticks to the right = 8 7 Ticks to the lieft = -7 After 300ms service is called with ticks = -3

This would indicate that left turns are working.

I went back and tested again to make sure I'm not missing something and I can't get the left turn to do anything. Only ticks to the right are working for me.

cgiesche commented 8 months ago

This setting does work left and right: grafik

brightness or brightness_pct do not work with negative values.

only brightness_step_pct or brightness_step work (yet)

SergeantPup commented 8 months ago

This was the part I was missing. I have confirmed it's working as described for lights.

Moving onto Media and volume, I think I'm missing something because I can confirm all the pieces work individually but I can't get it to work together.

For example: Turn up volume - With no options, increases the volume 2%/tick. Increases the volume regardless of direction Turn down volume - With no options, decreases the volume 2%/tick. Decreases the volume regardless of direction Set volume - with these options: {"volume_level": {{ ticks * ".10" }}} while turning the knob right 1 tick goes to 10% and 2 ticks goes to 20% and so forth. This is heading in the right direction but turning the knob left doesn't appear to do anything. So while I can set the volume or multiply the volume setting by number of ticks, I can't reduce it.

With the 3 volume services that are available, I've not been able to get a volume up/down in the same knob. Can you tell me if I'm doing something wrong or if there's another service that I should be using?

There's a lot of other media player services available that are useful and I'm eager to get configured, I just got stuck on the volume knob.

cgiesche commented 8 months ago

Set volume - with these options: {"volume_level": {{ ticks * ".10" }}} while turning the knob right 1 tick goes to 10% and 2 ticks goes to 20% and so forth. This is heading in the right direction but turning the knob left doesn't appear to do anything. So while I can set the volume or multiply the volume setting by number of ticks, I can't reduce it.

You are not doing anything wrong. Turn up volume and Turn down volume do what they should do. Those services would work with buttons, not (as expected) with the dial. Set volume would be the right service for the dial, but does only support values between 0 and 100. This is currently not possible with the plugin. As stated in one of my last comments, i will add specific variables for those kind of options. (in addition to ticks something like dial_percentage (0-100) and dial_absolute (0-255)). With those variables you will be able to use services that need percentage or absolute values.

cgiesche commented 8 months ago

New Pre-Release

Caveats:

grafik

SergeantPup commented 8 months ago

Beautiful work, thank you. The rotationAbsolute works perfectly for my needs and it's smooth as butter every time.

Just trying to be a good tester, I tried the rotationPercent with and without your math and while it works, it consistently taps out at 39% (I can't make the lights any brighter). It's not a function that I personally need but I wanted to report unexpected behavior.

cgiesche commented 8 months ago

Final changes are done and new (official) release will be published to the elgato store soon. Thanks for all your input and feedback so far!

Latest additions:

grafik

christorepl commented 1 month ago

Would it be possible to get some basic documentation on how to implement volume or brightness knobs? I still have a couple things to try for my volume knob, but, what I've tried so far hasn't worked.

Thanks for all the work you do!