Example for volume control of Sonos

Moderators: marc, Nico, Koen, Maarten

Post Reply
Message
Author
User avatar
Koen
Site Admin
Posts: 101
Joined: Wed Aug 29, 2018 1:26 pm
Location: Belgium
Contact:

Example for volume control of Sonos

#1 Post by Koen » Mon Sep 23, 2019 8:25 pm

In this topic we can share rules files. Let me start with sharing a rule to control the volume of your sonos speaker with the buttons on your Qbus installation.

Sonos_VolUP and SonosVolDn are 2 bistabiele outputs.

Code: Select all

rule "VolumeDN"
when
    Item Sonos_VolDN received update
then
    logWarn("myLog", "Rule VolDN executed")
    if (Sonos_VolDN.state==ON){
        Sonos_VolDN.state=OFF
        var Number V = Sonos_Volume.state as DecimalType
        var Number H = V - 10
        logWarn("myLog", "Volume: " + H)
        Sonos_Volume.sendCommand(H)
    }
end

rule "VolumeUP"
when
    Item Sonos_VolUP received update
then
    if (Sonos_VolUP.state==ON){
        Sonos_VolUP.state=OFF
        var Number V = Sonos_Volume.state as DecimalType
        var Number H = V + 10
        if (H>65) H = 65
        Sonos_Volume.sendCommand(H)
    }
end

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests