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.

Denon Home 150 and Yamaha Musicast 20 Speakers
#6
First of all don't run this script with 0 sleep time, it will consume all CPU resources of the system. To write data to objects use grp.checkwrite(address, value). Make sure that you have created objects beforehand and that they have matching datatypes for the data that will be stored there (string, boolean, number).
Code:
if res then
  data = json.pdecode(table.concat(respbody))
  if type(data) == 'table' then
    grp.checkwrite('1/1/1', data.input)
    grp.checkwrite('1/1/2', data.mute)
  end
else
  log('request failed', res, code)
end

For control you will need to create an event script for each action and send HTTP requests to the speakers. You should use different objects for control and status otherwise it's possible to make an infinite loop which will also overload the system.
Example for volume control (use 1 byte scale object):
Code:
value = event.getvalue()

ip = '192.168.1.169'

http = require('socket.http')

res, code, hdrs = http.request({
  url = 'http://' .. ip .. '/YamahaExtendedControl/v1/main/setVolume?volume=' .. value,
  headers = {
    ['X-AppName'] = 'MusicCast/1.0',
    ['X-AppPort'] = '41100',    
  }
})
Reply


Messages In This Thread
RE: Denon Home 150 and Yamaha Musicast 20 Speakers - by admin - 31.03.2021, 09:23

Forum Jump: