Add left/right action to dial
Closed this issue · 2 comments
Would it be possible to add different service calls to the left and right rotation?'
I want to use the rotation to for instance send an IR signal for volume up with the right rotation and volume down with the left one
Here's a workaround I use for controlling my Sonos volume. The trick is to create a helper input_number to use as your entity for Stream Deck and then do the automation in Home Assistant. For me, I want to add or subtract the number of "ticks" to the current volume. In your case, you'd probably use a slightly different method, such as choose if the number is positive, send one IR code, and negative send a different IR code. Either way, it's a good idea to reset your input_number after each automation so that when you turn the dial a second time, HA knows it's a different value. Here's my code for you to modify. If you need help, let me know what your automation is for each IR code and I'll try to help with something more specific. Anyways, here's what I use:
-
Create an input_number helper with a min value of -100 and a max value of 100.
-
From the Stream Deck config, go to the Encoder actions and under Rotation, select your input_number, use the "Set" service and the Service Data contains the following:
{
"value":{{ticks}}
}
- From Home Assistant, create an automation that reads the current value of your speaker volume, adds the increment (negative values will subtract) from the input_number, waits a few milliseconds then resets to 0. For example, here's what I have for my Sonos speaker. In your case, instead of :
alias: Media Stream Deck Volume Dial Sonos
description: ""
trigger:
- platform: state
entity_id:
- input_number.stream_deck_sonos_volume
condition:
- condition: not
conditions:
- condition: state
entity_id: input_number.stream_deck_sonos_volume
state: "0"
action:
- service: media_player.volume_set
data:
volume_level: >-
{% set increment = states('input_number.stream_deck_sonos_volume') |
float / 100 | round(2) %} {% set current =
state_attr('media_player.sonos_flex_room', 'volume_level') %} {{current
+ increment}}
target:
entity_id: media_player.sonos_flex_room
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 10
- service: input_number.set_value
data:
value: 0
target:
entity_id: input_number.stream_deck_sonos_volume
mode: single
Thanks for your "workaround" (wich is in fact it is a valid approach to the problem).
@zeekens Of course it would be possible to add different service configurations for left/right rotations. The problem is, that the configuration is getting more and more complex. I am not yet sure, if and how i want to add this feature...