Simple LMS LUA volume dimmer

Moderator: leecollings

Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Simple LMS LUA volume dimmer

Post by Nautilus »

simon_rb wrote:Working working working

THANK YOU!

Same issue here with the 1% out with Siri, and the slider within the native home app will always jump back down 1% when you release. I have noticed a couple of times when I have turn my 'Lounge Touch V' it has gone to 99% That could be a problem. I noticed you haven't used the uservariables in your scripts. Have you noticed this behaviour?
I use Eve, not the native home app (except the widget) but I can check at some point. In Eve I don't see this behavior (jump back to 1% nor 99%), though if I move the slider, it will send multiple values (move slider from 20->50, around 15 values are sent) and as it reacts both ways (changes in Domoticz as well), the slider moves quite slowly, it takes couple of seconds as it goes through each step. In Domoticz web UI or e.g. iPhone Pilot app this does not happen, must be homekit / homebridge related thing.

I Don't need the uservariable as when the terrace player turn on, I always set it to 60% volume (which will be sent to the dimmer as well) so there is no need to store the volume level for turning the player back On (after it has been Off).
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Simple LMS LUA volume dimmer

Post by simon_rb »

Nautilus wrote:I Don't need the uservariable as when the terrace player turn on, I always set it to 60% volume (which will be sent to the dimmer as well) so there is no need to store the volume level for turning the player back On (after it has been Off).
Is that done within domoticz or is there an option on the s side that sets player to 60%. Might be an idea for me to do the same :D

I only use the widget from the quick slide up fav thing.
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Simple LMS LUA volume dimmer

Post by Nautilus »

I'm using Domoticz for, not sure if there is something on the LMS side.

Code: Select all

if ((devicechanged['Musiikki terassi'] == 'On' or devicechanged['Musiikki terassi'] == 'Playing') and uservariables['SBTerassiStatus'] == 'Off') then
    commandArray[#commandArray+1]={['Variable:SBTerassiStatus'] = 'On'}
    commandArray[#commandArray+1]={['Musiikki terassi']='Set Volume 60'}
end
Here I use the uservariable 'SBTerassiStatus' to avoid the volume setting happening if the status changes for some reason between 'On' and 'Playing' but not needed necessarily.
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Simple LMS LUA volume dimmer

Post by simon_rb »

Do you add that script above as a new script or add it to the existing one?
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Simple LMS LUA volume dimmer

Post by Nautilus »

simon_rb wrote:Do you add that script above as a new script or add it to the existing one?
It is on my device script, here's the whole thing in current form:

Code: Select all

commandArray = {}
if ((devicechanged['Musiikki terassi'] == 'On' or devicechanged['Musiikki terassi'] == 'Playing') and uservariables['SBTerassiStatus'] == 'Off') then
    commandArray[#commandArray+1]={['Variable:SBTerassiStatus'] = 'On'}
    commandArray[#commandArray+1]={['Musiikki terassi']='Set Volume 60'}
    os.execute('curl -s "http://url/json.htm?type=command&param=switchlight&idx=314&switchcmd=Set%20Level&level=61" &')
elseif (devicechanged['Musiikki terassi'] == 'Off' or devicechanged['Musiikki terassi'] == 'Stopped' or devicechanged['Musiikki terassi'] == 'Disconnected') then
    if otherdevices['Terassin äänenvoimakkuus'] ~= 'Off' then
        commandArray[#commandArray+1]={['Terassin äänenvoimakkuus'] = 'Off'}
    end
    commandArray[#commandArray+1]={['Variable:SBTerassiStatus'] = 'Off'}
end

if devicechanged['Terassin äänenvoimakkuus'] ~= 'Off' and devicechanged['Terassin äänenvoimakkuus'] ~= nil then
    if tonumber(otherdevices_svalues['Terassin äänenvoimakkuus']) > 0 then
        volume = otherdevices_svalues['Terassin äänenvoimakkuus']
        commandArray['Musiikki terassi']='Set Volume '..volume
    end
end
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Simple LMS LUA volume dimmer

Post by simon_rb »

Working like a dream.. Hopefully we are all sorted! Thank you for helping me bring an idea to life lol!

Cheers
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Simple LMS LUA volume dimmer

Post by simon_rb »

My issue with the dimmers going to 100% when turned on has been fixed thanks to TheRamon, think it was the way edomoticz cached the values from domoticz. Excellent!
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Simple LMS LUA volume dimmer

Post by simon_rb »

Is there a way to send http://192.168.1.26:8080/json.htm?type= ... l&level=50 for example without the witch sending an on command? Should be able to work around it but each time it fires an On command doesn't show up in the log though..

For the time being I'm running a Lua script that if it detects the change then it'll run the bash script that used to run when the amp turned on...
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Simple LMS LUA volume dimmer

Post by G3rard »

Here is my LUA code for the Sonos volume dimmer (as promised in an earlier post).

I am using https://github.com/gerard33/sonos for controlling the Sonos. So the LUA code is depending on that.
So if you don't use that, you have to find another way to update and read the volume on the Sonos.

Sonos kantoor volume = the volume dimmer

Device script

Code: Select all

commandArray = {}

if devicechanged['Sonos kantoor volume'] then
    targetvolume = otherdevices_svalues['Sonos kantoor volume']
    --divide by 2, math.ceil(number) and math.floor(number) rounds up and down respectively
    --targetvolume = math.ceil(targetvolume / 5)
    targetvolume = math.floor((targetvolume / 5) + 0.5) --volume on silder 20 => becomes 4 on Sonos
    --print(targetvolume)
    local vol_kantoor = 'curl --url "http://127.0.0.1/fp/sonos/index.php?zone=115&action=Setvol&volume=' .. targetvolume .. '" &'
    os.execute(vol_kantoor)
end

return commandArray
Time script

Code: Select all

commandArray = {}

--compare volume Sonos kantoor and update it in Domoticz without triggering to avoid loop
--this is done by using commandArray['UpdateDevice']
if otherdevices['Sonos kantoor'] == 'On' then
    local domo_volume = otherdevices_svalues['Sonos kantoor volume']
    local actual_volume = execute('curl --url "http://127.0.0.1/fp/sonos/index.php?zone=115&action=GetVolume" &')
    local idx_sonos_kantoor_volume = '409'
    --remove spaces and zero
    actual_volume = actual_volume:gsub("%s+", "")
    actual_volume = actual_volume:gsub("0", "")
    --print(actual_volume)
    if tonumber(actual_volume) ~= nill then --if volume is 0 then php gives '0 0' but both nulls are replace with ""
        --do volume times 5 so slider is more logical
        actual_volume = tonumber(actual_volume) * 5
    end
    --print('volume domo: ' .. domo_volume)
    --print('volume sonos: ' .. actual_volume)
    --update volume if sonos is on and volume differs
    if (tonumber(domo_volume) ~= tonumber(actual_volume)) then
        commandArray['UpdateDevice'] = otherdevices_idx['Sonos kantoor volume'] ..'|2|' .. actual_volume
    end
end
Not using Domoticz anymore
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Simple LMS LUA volume dimmer

Post by pvklink »

Is there a way to put the ip-adress in a parameter like
IP=''127.0.0.1'
and change the below rule to use the IP parameter ?


<part of a script>
local vol_kantoor = 'curl --url "http://127.0.0.1/fp/sonos/index.php?zon ... ol&volume=' .. targetvolume .. '" &'
os.execute(vol_kantoor)
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
User avatar
jvdz
Posts: 2335
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Simple LMS LUA volume dimmer

Post by jvdz »

You mean like this?:

Code: Select all

IP='127.0.0.1'
local vol_kantoor = 'curl --url "http://'..IP..'/fp/sonos/index.php?zone=115&action=Setvol&volume=' .. targetvolume .. '" &'
os.execute(vol_kantoor)
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Simple LMS LUA volume dimmer

Post by pvklink »

Works great!
1) When i put the receiver on, this script default sets the receiver to RADIO
2) I also have a switch Mode with options like CD, RADIO etc.

I want the switch MODE set to RADIO so that this switch values matches with the settings that i mentioned at 1)

I tried this but i doesnt work:
commandArray['Denon mode'] = "fmradio" (this is one of the options in this selector switch)




commandArray = {}

IP = '192.168.178.176' --IP of denon
DEV='Denon aanuit'
MAXLEVEL=50
-- default zender lukt niet en switch waarde default zetten

if devicechanged[DEV] == 'On' then
local play = 'curl --url "http://' .. IP .. '/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON" &' --aan
os.execute(play)
local play = 'curl --url "http://' .. IP .. '/MainZone/index.put.asp?cmd0=PutZone_InputFunction/TUNER" &' --radio aan
os.execute(play)
commandArray['Denon mode'] = "fmradio"
elseif devicechanged[DEV] == 'Off' then
local play = 'curl --url "http://' .. IP .. '/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FOFF" &' --uit
--local play = 'curl --url "http://' .. IP .. '/MainZone/index.put.asp?cmd0=PutVolumeMute%2Fon" &' --mute
os.execute(play)
end

if devicechanged[DEV] then
NewLevel = otherdevices_svalues[DEV]
if NewLevel ~= "Off" and NewLevel ~= "0" then
if tonumber(NewLevel) > MAXLEVEL then --volume maxlevel
NewLevel = MAXLEVEL
end
SendLevel = NewLevel - 80 --79.5
os.execute ("curl http://" .. (IP) .. "/MainZone/index.put.asp?cmd0=PutMasterVolumeSet/" .. (SendLevel))
end
end

return commandArray
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
simon_rb
Posts: 612
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Simple LMS LUA volume dimmer

Post by simon_rb »

Instead of ['Denon mode'] = "fmradio" try the percentage it is.. like Level 10 or level 20 so on and so on..


Sent from my iPhone using Tapatalk
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Simple LMS LUA volume dimmer

Post by pvklink »

Works great!

commandArray = {}

IP = '192.168.178.176' --IP of denon
IPTV = '192.168.178.13' --IP of tv
DEV='Denon aanuit'
MAXLEVEL=50

if devicechanged[DEV] == 'On' then
local play = 'curl --url "http://' .. IP .. '/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FON" &'
os.execute(play)
ping_success=os.execute('ping -c1 192.168.178.13')
if ping_success then
otherdevices_svalues['Denon mode'] = "20"
else
otherdevices_svalues['Denon mode'] = "10"
end

elseif devicechanged[DEV] == 'Off' then
local play = 'curl --url "http://' .. IP .. '/MainZone/index.put.asp?cmd0=PutZone_OnOff%2FOFF" &' -- oud local play = 'curl --url "http://' .. IP .. '/MainZone/index.put.asp?cmd0=PutVolumeMute%2Fon" &' --mute
os.execute(play)
end

if devicechanged[DEV] then
NewLevel = otherdevices_svalues[DEV]
if NewLevel ~= "Off" and NewLevel ~= "0" then
if tonumber(NewLevel) > MAXLEVEL then --volume maxlevel
NewLevel = MAXLEVEL
end
SendLevel = NewLevel - 80 --79.5
os.execute ("curl http://" .. (IP) .. "/MainZone/index.put.asp?cmd0=PutMasterVolumeSet/" .. (SendLevel))
end
end

return commandArray
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
zwaffie
Posts: 6
Joined: Sunday 10 January 2016 21:40
Target OS: -
Domoticz version:
Contact:

Re: Simple LMS LUA volume dimmer

Post by zwaffie »

I'am confused.

Can someone give me a step by step description for how to use this?
I don't get any results with the many scripts in this thread.

I got 6 divices

AmmoBox (LMS speaker)
BoomZero (LMS speaker)
Woonkamer (LMS speaker)

VolumeAmmoBox (dimmer)
VolumeBoomzero (dimmer)
VolumeWoonkamer (dimmer)

Let we start with one.
How can I control the volume of my AmmoBox lms speaker?
Which scripts will be the correct one?

I hope someone will help me.

gr,
Sven
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest