I’ve been playing with the idea of using an actual z-wave or lightwaveRF dimmer wall switch as a volume control for my Sonos. Currently I’m testing against an installed Fibaro dimmer switch (which is annoying the misses), but the hope is that I will be able to run another dimmer in isolation,so not connected to a light (this is still to be confirmed)
Looking at the dimmer levels of th light, they go from 0-100 (off to full on) and can be set to specific levels through a scene or code, but they only go up in 10s if clicking the UI device or the wall switch.
So to make this work via the wall switch, I’ll look at having the increases and decreases being in increments of 10s.
The Sonos volume control from the vera plugin also seems to work from 0-100 (off to full on) and can be set to specific levels too, but I would not want to take that up to 100%
So my light level to volume mapping is currently looking as follows, the dimmer has a GetLoadalevelStatus option which I think checks the value set and the Sonos has a SetVolume & NewVolume option.
I ideally would liked to have done this via the Scenes/Automation UI, but I am unable to set a trigger based on a Dimmer value, it’s only if it is on or off.
Any help on how to create a piece of code to do the above would be hugely appreciated.
There’s the luup.variable_watch() function which you could use to call a function every time the LoadLevelStatus variable changes. I’ve never used it outside of a full-fledged plugin, I don’t know if you can just stick it on a scene’s Luup code or the global startup Lua but oTi@ reports that it works. Give it a try. There are a few examples of luup.variable_watch() that you can read: the Home Care plugin is a simple example, and dataMine is a complex example.
If you don’t mind creating eleven Combination Switches and eleven scenes, you could do it without code entirely…
Conversely, I have a number of Luup-only scenes (that should be turned into a plug-in) registering for a watch. The scenes get started in the start-up Lua.
Please excuse the following, it is my first attempt at some code, so be gentle.
—the watch part to see if the dimmer level has changed.
local lul_argument {}
local value = luup.variable_watch(“urn:upnp-org:serviceId:Dimming1”, “LoadLevelTarget”, 22)
lul_argument [“loadLevelTarget”] = 20
—if it has reached 20, set Sonos Volume to 20
—not sure how to set it, so that if 20 then go and set volume.
I have a similar setup, but instead of a Sonos I am using VLC with a media server.
VLC has the great feature of having an HTTP remote interface, so I am wondering if we could trigger specific http requests when the user pushes the paddle up or down on a dimmer with no load (ca600)
Alas I did not progress very far with this, although in theory it should work if you map the dimmer levels to the volume levels.
The Luup.variable.watch is the key here, where you would set a dimmer ‘load level’ to trigger a volume level.
As for how you wire such a thing in, that is where is got to and stopped, so instead as I have the rtxrfx433 Vera add on I’ve been playing with an old x10 wall switch and just using that to control the up and down of the volume.
If you decide to have play, let me know how you get on.
Did you ever finish this ? I could not find a way to set the sonos volume without sending it a command for it to play something.
If you finish please let us know what your LUA code looks like.