Пример #1
0
def ProcessRequest(key):
    oc = ObjectContainer()

    api = smartthings(username=Prefs['smUser'], password=Prefs['smPass'])
    	
#    hub = api.hub(key)
#    Log(hub)

    devices = api.hub_devices(key)
    for device in devices:
	image = ""
#	filename = ""
#	for s in device:
#	    Log(s)
#	    Log(device[s])
#	Log(device['type'])
	stateOverrides = device['stateOverrides']
	for x in stateOverrides:
	    image = x['icon']
	    Log(image)
#	    if (image == "st.switches.switch.on" or image == "st.switches.switch.off"):
#	        filename = image
#	    else:
#	        filename = image+"-icn"

#	    Log(filename)
#	    for y in x:
#	        Log(y)
#               Log(x[y])

        currentStates = device['currentStates']
        for t in currentStates:
		if (t['name'] == "temperature" or t['name'] == "battery" or t['name'] == "humidity" or t['name'] == "water"):
		    icon = Resource.ContentsOfURLWithFallback("http://dummyimage.com/512X512/fff/000.png&text="+t['value'])
		    label = t['name'].title()
		    device_summary = t['name'].title()+" is "+t['value'].title()
	        elif (t['name'] == "contact"):
		    icon = R("contact-"+t['value']+".png")
		    label = device['label'].title()
                    device_summary = device['label'].title()+" is "+t['value'].title()
                else:
		    icon = R(image+"-"+t['value']+".png")
		    label = device['label'].title()
		    device_summary = device['label'].title()+" is "+t['value'].title()
		Log(label)
		Log(icon)
		oc.add(DirectoryObject(key = device['id'], title = label, summary = device_summary, thumb = icon))
          
	        if (label == "Garage Door (overhead)"):
                     for u in t:
                         Log(u)
                         Log(t[u])

    return oc
Пример #2
0
def MainMenu():
    oc = ObjectContainer()

    api = smartthings(username=Prefs['smUser'], password=Prefs['smPass'])

    hubs = api.hubs()
#    Log(type(hubs))
    for hub in hubs:
#        Log(hub['id'])
#        Log(hub['name'])
	oc.add(DirectoryObject(key = hub['id'], title = hub['name'], thumb = R("hub-on.png")))
#	for s in hub:
#		Log(s)
#		Log(hub[s])

    return oc
Пример #3
0
def MainMenu():
    oc = ObjectContainer()

    api = smartthings(username=Prefs['smUser'], password=Prefs['smPass'])

    hubs = api.hubs()
    #    Log(type(hubs))
    for hub in hubs:
        #        Log(hub['id'])
        #        Log(hub['name'])
        oc.add(
            DirectoryObject(key=hub['id'],
                            title=hub['name'],
                            thumb=R("hub-on.png")))
#	for s in hub:
#		Log(s)
#		Log(hub[s])

    return oc
Пример #4
0
from smartthings import smartthings

if __name__ == "__main__":
    username = ""
    password = ""
    api = smartthings(username=username, password=password)
    #print api.accounts()

    account_id = ""
    print api.locations(account_id)

    #api.events(account_id, max=1):

    #print api.hubs()
    #hub_id = ""
    #print api.hub(hub_id)
    #print api.hub_events(hub_id)
    #print api.hub_devices(hub_id)

    device_id = "xxx"
    #device_events =  api.device_events(device_id,max=1,source="DEVICE")
    #for e in device_events:
    #  print e

    #print api.device_roles(device_id)

    #print api.device_types()
Пример #5
0
from smartthings import smartthings

if __name__ == "__main__":
    username = ""
    password = ""
    api = smartthings(username=username, password=password)
    # print api.accounts()

    account_id = ""
    print api.locations(account_id)

    # api.events(account_id, max=1):

    # print api.hubs()
    # hub_id = ""
    # print api.hub(hub_id)
    # print api.hub_events(hub_id)
    # print api.hub_devices(hub_id)

    device_id = "xxx"
    # device_events =  api.device_events(device_id,max=1,source="DEVICE")
    # for e in device_events:
    #  print e

    # print api.device_roles(device_id)

    # print api.device_types()
Пример #6
0
def ProcessRequest(key):
    oc = ObjectContainer()

    api = smartthings(username=Prefs['smUser'], password=Prefs['smPass'])

    #    hub = api.hub(key)
    #    Log(hub)

    devices = api.hub_devices(key)
    for device in devices:
        image = ""
        #	filename = ""
        #	for s in device:
        #	    Log(s)
        #	    Log(device[s])
        #	Log(device['type'])
        stateOverrides = device['stateOverrides']
        for x in stateOverrides:
            image = x['icon']
            Log(image)
#	    if (image == "st.switches.switch.on" or image == "st.switches.switch.off"):
#	        filename = image
#	    else:
#	        filename = image+"-icn"

#	    Log(filename)
#	    for y in x:
#	        Log(y)
#               Log(x[y])

        currentStates = device['currentStates']
        for t in currentStates:
            if (t['name'] == "temperature" or t['name'] == "battery"
                    or t['name'] == "humidity" or t['name'] == "water"):
                icon = Resource.ContentsOfURLWithFallback(
                    "http://dummyimage.com/512X512/fff/000.png&text=" +
                    t['value'])
                label = t['name'].title()
                device_summary = t['name'].title() + " is " + t['value'].title(
                )
            elif (t['name'] == "contact"):
                icon = R("contact-" + t['value'] + ".png")
                label = device['label'].title()
                device_summary = device['label'].title(
                ) + " is " + t['value'].title()
            else:
                icon = R(image + "-" + t['value'] + ".png")
                label = device['label'].title()
                device_summary = device['label'].title(
                ) + " is " + t['value'].title()
            Log(label)
            Log(icon)
            oc.add(
                DirectoryObject(key=device['id'],
                                title=label,
                                summary=device_summary,
                                thumb=icon))

            if (label == "Garage Door (overhead)"):
                for u in t:
                    Log(u)
                    Log(t[u])

    return oc