Control Sonos outside your home using HomeKit
Applying the same concept as the Aeotec Dimmer for Homekit control, we can also use the Domoticz virtual dimmer to control the Sonos using node-sonos-http-api.
Homekit > Domoticz Virtual Dimmer (LUA) > node-sonos-http-api > Sonos
I'm starting to derive a shorter version of the LUA script for easier maintenance and using the base On and Off action commands on Virtual Device configuration page. Replace the IP address with the raspberry pi running node-sonos-htttp-api.
Virtual Device Name SonosOne_Volume
Action On Command: http://192.168.1.XX:5005/Sonos%20One/play
Action Off Command: http://192.168.1.XX:5005/Sonos%20One/pause
LUA script
/home/pi/domoticz/scripts/lua/script_device_SonosOne_Volume.lua
commandArray = {}
DEV='SonosOne_Volume'
if otherdevices[DEV] == 'Off' then
os.execute('curl "http://192.168.1.XX:5005/Sonos%20One/pause"')
else
Level = otherdevices_svalues[DEV]
os.execute('curl "http://192.168.1.XX:5005/Sonos%20One/volume/"'..Level)
end
return commandArray
Homekit > Domoticz Virtual Dimmer (LUA) > node-sonos-http-api > Sonos
I'm starting to derive a shorter version of the LUA script for easier maintenance and using the base On and Off action commands on Virtual Device configuration page. Replace the IP address with the raspberry pi running node-sonos-htttp-api.
Virtual Device Name SonosOne_Volume
Action On Command: http://192.168.1.XX:5005/Sonos%20One/play
Action Off Command: http://192.168.1.XX:5005/Sonos%20One/pause
LUA script
/home/pi/domoticz/scripts/lua/script_device_SonosOne_Volume.lua
commandArray = {}
DEV='SonosOne_Volume'
if otherdevices[DEV] == 'Off' then
os.execute('curl "http://192.168.1.XX:5005/Sonos%20One/pause"')
else
Level = otherdevices_svalues[DEV]
os.execute('curl "http://192.168.1.XX:5005/Sonos%20One/volume/"'..Level)
end
return commandArray
Comments