Sonos Device type and LIFX


(Rakote) #1

So I have been pouring over the sonos connect smart app as well as the hue connect app in hopes of creating a LIFX bulb device type and even a smart app that works the same as those two connect apps. I have a smart app started that talks to the lifx-http SDK found here (running on a local server) that finds my lights and tries to create new devices but they don’t create.

I then thought well maybe the device type needs to exist so I created a simple one for testing that would turn on or off my lights. however when I send the off command via this command in the device type code:

sendHubCommand(new physicalgraph.device.HubAction("""GET /lights/label:${encodedName}/off?_method=put HTTP/1.1\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))

i get an error:

No signature of method: script13961045224712093808485.sendHubCommand() is applicable for argument types: (physicalgraph.device.HubAction) values: [GET /lights/label:Living%20Room%20Couch/off?_method=put HTTP/1.1 HOST: 10.0.1.161:56780

My assumption is that the hub action does not work in a device type which doesn’t make sense as sonos as far as I know can only be controlled when you are on the same wifi network. I would assume that ST is using similar code that they have in the connect and control apps but It appears that the sonos device type is some secret hidden device within smart things. as the code to create the sonos in its control appears to be this:

def addSonos() {
	def players = getVerifiedSonosPlayer()
	selectedSonos.each { dni ->
		def d = getChildDevice(dni)
		if(!d) {
			def newPlayer = players.find { (it.value.ip + ":" + it.value.port) == dni }
			log.debug "newPlayer = $newPlayer"
			log.debug "dni = $dni"
			d = addChildDevice("smartthings", "Sonos Player", dni, newPlayer?.value.hub, ["label":newPlayer?.value.name])
			log.debug "created ${d.displayName} with id $dni"

			d.setModel(newPlayer?.value.model)
			log.debug "setModel to ${newPlayer?.value.model}"

			subscribeAll() //run once to update devices

		} else {
			log.debug "found ${d.displayName} with id $dni already exists"
		}
	}
}

How does one control something over the local LAN from a device type? Is it possible?


(Jaydenaphillips) #2

Do you have the lab firmware?


(Rakote) #3

@jaydenphillips I do. I have successfully communicated with my bulbs via a smart app, but I am trying to get a device type to work as well. As best I can tell both the hue bulb device type, and the sonos player device type are some hidden devices in the ST environment. There is no code that is exposed to us users that define the interaction and the GUI for those devices anywhere that I can find. I know that sonos can only be controlled in a local LAN environment but I can’t seem to figure out the correct calls in my device type to make that a reality with a LIFX bulb. I have more then a few bulbs and wanted to create a smart app like the sonos and the hue connect apps that auto discover and add the bulbs to my account. and then be able to control the bulbs like a hue bulb.