This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SONOS
#4
please is very easy to help me because I am a beginner with them
the ip ip from wiser is 192.168.1.50
my sonos ip is 192.168.1.7 and 192.168.1.8
thank you in advance.
-- Load modules
require('json')
require('socket.http')

-- Set timout
socket.http.TIMEOUT = 5

-- Read IP address from controller
data = io.readproc('if-json')
data = json.decode(data)
ip = data.eth0.inetaddr

-- Set SONOS name
Sonos_Player_Name = 'dining'  

-- Get event value
value = event.getvalue()

-- Set stepsize volume
Volume_Step = 10

-- Set Action
if value == 101 then
    Sonos_Action = 'play'
elseif value == 102 then
    Sonos_Action = 'stop'
elseif value == 103 then
    Sonos_Action = 'next'
elseif value == 104 then
    Sonos_Action = 'previous'
elseif value == 105 then
    Sonos_Action = 'mute'
elseif value == 106 then
    Sonos_Action = 'unmute'
elseif value == 107 then
    Sonos_Action = 'setvolumeup'
 Volume_Step = Volume_Step or 10
elseif value == 108 then
 Sonos_Action = 'setvolumedown'
 Volume_Step = Volume_Step or 10
else
 action = 'none'
end

-- Execute action on value 0 to 100
if value >= 0 and value <= 100 then
 local reply = socket.http.request('http://'192.168.1.50'/apps/data/sonos/sonos.lp?action=setvolume&name=' .. dining.. '&volume=' .. value .. '')
end

-- Execute action on value 101 to 106
if value >= 101 and value <= 106 then
    local reply = socket.http.request('http://'192.168.1.50'/apps/data/sonos/sonos.lp?action=' .. Sonos_Action .. '&name=' ..dining.. '')
end

-- Execute action on value 107 to 108
if value >= 107 and value <= 108 then
    local reply = socket.http.request('http://'192.168.1.50'/apps/data/sonos/sonos.lp?action=' .. Sonos_Action .. '&name=' ..dining .. '&step=' .. Volume_Step .. '')
end

-- Execute action on value 255 (Feedback)
if value == 255 then
    local reply = socket.http.request('http://'192.168.1.50'/apps/data/sonos/sonos.lp?action=getextendedstate&name=' ..dining.. '&createbaseimg=true')
 reply = json.pdecode(reply)
 if reply then
     local current_volume = reply[1].volume
     local current_mutestate = reply[2].mute
   local current_crossfadestate = reply[3].crossfade
   local current_playmode = reply[4].playmode
   local current_transportmode = reply[5].transport
   local current_duration = reply[7].duration
   local current_playingtime = reply[8].playingtime
   local current_title = reply[9].tracktitle
   local current_artist = reply[10].creator
   local current_album = reply[11].album
   local current_albumart = reply[12].albumart
   local current_mediatype = reply[11].mediatype
 end
end
Reply


Messages In This Thread
SONOS - by balatis - 23.03.2018, 14:37
RE: SONOS - by balatis - 26.03.2018, 13:45
RE: SONOS - by Erwin van der Zwart - 26.03.2018, 17:20
RE: SONOS - by balatis - 26.03.2018, 19:12
RE: SONOS - by Erwin van der Zwart - 26.03.2018, 21:36
RE: SONOS - by balatis - 27.03.2018, 10:22
RE: SONOS - by admin - 27.03.2018, 11:30
RE: SONOS - by Erwin van der Zwart - 27.03.2018, 11:35
RE: SONOS - by balatis - 27.03.2018, 12:01
RE: SONOS - by admin - 27.03.2018, 12:14
RE: SONOS - by balatis - 27.03.2018, 12:18
RE: SONOS - by admin - 27.03.2018, 12:21
RE: SONOS - by balatis - 27.03.2018, 12:27
RE: SONOS - by admin - 27.03.2018, 12:37
RE: SONOS - by balatis - 27.03.2018, 12:44
RE: SONOS - by admin - 27.03.2018, 13:03
RE: SONOS - by Daniel - 27.03.2018, 13:06
RE: SONOS - by Erwin van der Zwart - 27.03.2018, 13:24
RE: SONOS - by thomasoppida - 15.04.2018, 21:15
RE: SONOS - by Erwin van der Zwart - 16.04.2018, 04:04
RE: SONOS - by thomasoppida - 16.04.2018, 06:32
RE: SONOS - by balatis - 27.03.2018, 13:14

Forum Jump: