I've done this with my Bravia TV. I can't get the current volume for it, so I've had to make it change the volume relatively.
The only way I've found as well, is the Selector switch method. You just gotta get all the settings set before you change it to Dimmer. You can delete it from the Devices page, if need be. My main issue with it, is that the slider doesn't show up for it, on the floorplan.
As for the volume changing, I've solved it in this way:
Code: Select all
commandArray = {}
remoteScript = '/home/pi/domoticz/scripts/remote.sh'
for deviceName,deviceValue in pairs(devicechanged) do
if (deviceName=='Bravia TV') then
if (deviceValue == 'On') then
commandArray['TV'] = 'Set Level: 50 %'
else
commandArray['TV'] = 'Off'
end
end
if (deviceName=='TV') then
deviceSValue = otherdevices_svalues["TV"]
if (deviceValue == 'Off') then
if (otherdevices['Bravia TV'] ~= 'Off') then
os.execute(remoteScript..' Mute &')
commandArray['TV'] = 'Set Level: 50 %'
end
elseif (tonumber(deviceSValue) ~= 50) then
if tonumber(deviceSValue) < 50 then
times = 50 - deviceSValue
os.execute(remoteScript..' VolumeDown '..times..' &')
elseif tonumber(deviceSValue) > 50 then
times = deviceSValue - 50
os.execute(remoteScript..' VolumeUp '..times..' &')
end
commandArray['TV'] = 'Set Level: 50 %'
end
end
end
return commandArray
(Bravia TV is a pinger that pings the TV's IP. TV is the virtual switch.)
If you don't need to display on/off status, just remove the Bravia TV bits.