Use Philips Hue Tap Dial Switch to Control Sonos Volume

Hi everyone,

I just signed up because I’m so happy my automation works and therfore I share it, maybe it helps you as well.

alias: Contrôler le volume du salon avec Dial
description: >-
  Contrôle le volume de Sonos Salon en fonction de la direction de la
  rotation et la vitesse du Tap Dial Switch
trigger:
  - platform: mqtt
    topic: zigbee2mqtt/Dial/action
action:
  - variables:
      current_volume: "{{ state_attr('media_player.salon', 'volume_level') | float }}"
      volume_change: |-
        {% if trigger.payload == "dial_rotate_left_step" %}
          -0.01
        {% elif trigger.payload == "dial_rotate_left_slow" %}
          -0.05
        {% elif trigger.payload == "dial_rotate_left_fast" %}
          -0.10
        {% elif trigger.payload == "dial_rotate_right_step" %}
          0.01
        {% elif trigger.payload == "dial_rotate_right_slow" %}
          0.05
        {% elif trigger.payload == "dial_rotate_right_fast" %}
          0.10
        {% else %}
          0.0
        {% endif %}
  - variables:
      new_volume: "{{ max(0, min(current_volume + (volume_change | float), 1)) }}"
  - service: media_player.volume_set
    data:
      volume_level: "{{ new_volume }}"
    target:
      entity_id: media_player.salon
mode: queued
max_exceeded: silent
max: 100

Regards
Patrick

1 Like

Hey that’s cool! Thanks for sharing. Looks like I’m off to buy a Hue Tap Dial Switch next!