i know but it's a pleasure for me, so as you want
Many thanks for your help !
after some test, seems that all is working. just a smal issue, i don't know why but when amp is Off, the script send a volume=0 to the amp, not a real problem because when the amp is off it ignore the command.
So i share m'y 2 scripts that are running (i've 2 zone to control)
zone Main (Called zone 1 for me) :
Code: Select all
local scriptVar = 'Yamaha'
return {
on = {
timer =
{
'every minute' -- just an example to trigger the request
},
devices =
{
'Ampli - Zone 1',
},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
local maxVolume = 161
local volume = dz.devices('Ampli - Zone 1') -- switch (dimmer)
local input = dz.devices('Ampli Input') -- selector switch with all possible input strings as levels
if item.isTimer then
dz.openURL({
url = 'http://192.168.200.67/YamahaExtendedControl/v1/main/getStatus',
callback = scriptVar,
})
elseif item.isDevice then
dz.openURL('http://192.168.200.67/YamahaExtendedControl/v1/main/setVolume?volume=' .. (math.floor( item.level * maxVolume / 100) ))
elseif item.isHTTPResponse and item.json and item.json.power == 'on' then
dz.log('or another here ?', dz.LOG_DEBUG)
volume.dimTo(math.floor(item.json.volume / maxVolume * 100)).silent()
input.switchSelector(item.json.input).silent()
end
if item.isHTTPResponse and item.json and item.json.power == 'standby' then
volume.quietOff()
end
end
}
Code: Select all
local scriptVar = 'Yamaha2'
return {
on = {
timer =
{
'every minute' -- just an example to trigger the request
},
devices =
{
'Ampli - Zone 2',
},
httpResponses =
{
scriptVar,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
local maxVolume = 161
local volume2 = dz.devices('Ampli - Zone 2') -- switch (dimmer)
local input = dz.devices('Ampli Input') -- selector switch with all possible input strings as levels
if item.isTimer then
dz.openURL({
url = 'http://192.168.200.67/YamahaExtendedControl/v1/zone2/getStatus',
callback = scriptVar,
})
elseif item.isDevice then
dz.openURL('http://192.168.200.67/YamahaExtendedControl/v1/zone2/setVolume?volume=' .. (math.floor( item.level * maxVolume / 100) ))
elseif item.isHTTPResponse and item.json and item.json.power == 'on' then
dz.log('or another here ?', dz.LOG_DEBUG)
volume2.dimTo(math.floor(item.json.volume / maxVolume * 100)).silent()
input.switchSelector(item.json.input).silent()
end
if item.isHTTPResponse and item.json and item.json.power == 'standby' then
volume2.quietOff()
end
end
}