Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Marantz NR1604 Auto PowerOff
AVReciever = require('marantz-avr')
mdns = require('mdns')
CronJob = require('cron').CronJob
clients = []
new CronJob '0 0 0 * * *', ->
for key, val of clients
for ip in val
reciever = new AVReciever(ip)
reciever.sendCommand("PutZone_OnOff/OFF")
, null, true, 'Asia/Tokyo'
ad = mdns.createAdvertisement(mdns.tcp('http'), 4321)
ad.start()
browser = mdns.createBrowser(mdns.tcp('raop')) # All Airplay Devices
browser.on 'serviceUp', (service)->
if service.name.match /Marantz/
clients[service.name] = service.addresses
browser.on 'serviceDown', (service)->
if service.name.match /Marantz/ && clients[service.name]?
delete clients[service.name]
browser.start()
all = mdns.browseThemAll()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment