Giter Club home page Giter Club logo

Comments (2)

jer78 avatar jer78 commented on July 19, 2024 1

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:

  1. Create an input_number helper with a min value of -100 and a max value of 100.

  2. 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}}
}
  1. 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

from streamdeck-homeassistant.

cgiesche avatar cgiesche commented on July 19, 2024

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...

from streamdeck-homeassistant.

Related Issues (20)

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.