Volume control by dimmer

Moderator: leecollings

Post Reply
VHK17
Posts: 11
Joined: Tuesday 31 January 2017 9:10
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Volume control by dimmer

Post by VHK17 »

How to change the volume of the amixer With a virtual dimmer.

I can change the volume by comment line amixer sset PCM,0 90%

What is the best way to do this ; amixer sset PCM,0 virtual dimmer%
Pjedr
Posts: 38
Joined: Friday 27 December 2013 3:13
Target OS: Linux
Domoticz version: Beta
Location: Friesland
Contact:

Re: Volume control by dimmer

Post by Pjedr »

Maybe my script can help, it looks for changed device with a specific name, and if the value contains the word 'level' it extracts it and calculates a level for the soundlevel between 0 and max of 70

Code: Select all

function round(num, idp) local mult = 10^(idp or 0) --Round number to identent point
 if num >= 0 then return math.floor(num * mult + 0.5) / mult else return math.ceil(num * mult - 0.5) / mult end
end

--for i,v in pairs(devicechanged) do print('Changed: device='..i..', value='..v) end
for i,v in pairs(devicechanged) do if (#device==0 or #i < #device) then device=i end end
if LogLvl >= 4 then print('Getriggerd door ___'..device..' now '..otherdevices[device]..'___') end

if device=='LF Ûntfanger Onkyo Lûdknop' then --1
 if string.match(otherdevices['LF Ûntfanger Onkyo Lûdknop'], "Level") then print('We hebben een Onkyo Set Level match') --2
  sOnkyoVolumeProcents=tonumber(otherdevices['LF Ûntfanger Onkyo Lûdknop']:match("(%d+)"))
  sOnkyoVolumeCalc=round(70/100*sOnkyoVolumeProcents)
  --print('Onkyo = '..sOnkyoVolumeProcents..' procent, calculated value = '..sOnkyoVolumeCalc)
  --print('nohup '..sScriptsDir..'/OnkyoVolumeSet.sh '..sOnkyoVolumeCalc)
  os.execute('nohup '..sScriptsDir..'/OnkyoVolumeSet.sh '..sOnkyoVolumeCalc..' 2>/dev/null &')
  return commandArray
end end --2 --1
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest