コード例 #1
0
ファイル: nimbus.py プロジェクト: murali44/WinkNimbus
    def __init__(self, secret_file_name):
        w = wink.init(secret_file_name)

        if "cloud_clock" not in w.device_types():
            raise RuntimeError(
                "you do not have a cloud_clock associated with your account!"
            )

        # Wrap cloud_clock with Nimbus object
        c = w.cloud_clock()
        self.__class__ = type(c.__class__.__name__,
                              (self.__class__, c.__class__),
                              {})
        self.__dict__ = c.__dict__
コード例 #2
0
    def __init__(self, secret_file_name):
        w = wink.init(secret_file_name)

        if "cloud_clock" not in w.device_types():
            raise RuntimeError(
                "you do not have a cloud_clock associated with your account!"
            )

        # Wrap cloud_clock with Nimbus object
        c = w.cloud_clock()
        self.__class__ = type(c.__class__.__name__,
                              (self.__class__, c.__class__),
                              {})
        self.__dict__ = c.__dict__

        # keep locally seen ranges for scaling purposes:
        self.min_value = sys.maxint
        self.max_value = 0
コード例 #3
0
ファイル: cta_clock.py プロジェクト: harperreed/cta_clock
    def __init__(self, secret_file_name):
        super(WinkManualControl, self).__init__()



        self.w = wink.init(secret_file_name)

        if "cloud_clock" not in self.w .device_types():
            raise RuntimeError(
                "you do not have a cloud_clock associated with your account!"
            )
        c = self.w.cloud_clock()
        self.__class__ = type(c.__class__.__name__,
                              (self.__class__, c.__class__),
                              {})
        self.__dict__ = c.__dict__

        self.min_value = sys.maxint
        self.max_value = 0
        logging.basicConfig(level=logging.DEBUG)
        self.logger = logging.getLogger(__name__)
コード例 #4
0
#!/usr/bin/python
#by sarakha63
import sys
import os
os.chdir(os.path.dirname(os.path.realpath(__file__)))
porkfolio_list=[]
index=int(sys.argv[1])-1
if __name__ == "__main__":
    import wink

    w = wink.init()

    for device in w.device_list():
        if device.device_type()=='piggy_bank':
            name='Inconnu'
            porkid='Inconnu'
            serial='Inconnu'
            mac='Inconnu'
            if device.id:
                porkid=device.id
            if device.data.get("name"):
                name=device.data.get("name")
            if device.data.get("serial"):
                serial=device.data.get("serial")
            if device.data.get("mac_address"):
                mac=device.data.get("mac_address")
            porkfolio_list.append([porkid,name,serial,mac])
print '{"porkid":"'+porkfolio_list[index][0]+'","porkname":"'+porkfolio_list[index][1]+'","porkserial":"'+porkfolio_list[index][2]+'","porkmac":"'+porkfolio_list[index][3]+'"}'
コード例 #5
0
ファイル: get_info.py プロジェクト: jeedom/plugin-porkfolio
#!/usr/bin/python
#by sarakha63
import os
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__)))
if __name__ == "__main__":
    import time
    try:
        import wink
    except ImportError as e:
        import sys
        sys.path.insert(0, "..")
        import wink

    w = wink.init("config.cfg")
    c = w.piggy_banks()
    for porky in c:
        if porky.data.get("piggy_bank_id")==sys.argv[1]:
            if str(porky.data.get("balance"))=='None':
                balance='0'
            else:
                balance=str(porky.data.get("balance")/float(100))
            if str(porky.data.get("last_deposit_amount"))=='None':
                dernier='0'
            else:
                dernier=str(porky.data.get("last_deposit_amount")/float(100))
            nez=porky.data.get("nose_color")
            objectif=str(porky.data.get("savings_goal")/float(100))
            if str(porky.data.get("last_reading")["amount_updated_at"])=='None':
                datedepot='1'
            else:
コード例 #6
0
ファイル: spotter.py プロジェクト: instantchow/py-wink
if __name__ == "__main__":
    import time
    try:
        import wink
    except ImportError as e:
        import sys
        sys.path.insert(0, "..")
        import wink

    w = wink.init("../config.cfg")

    if "sensor_pod" not in w.device_types():
        raise RuntimeError(
            "you do not have a sensor_pod associated with your account!"
        )

    c = w.sensor_pod()

    print "found sensor_pod %s called %s!" % (c.id, c.data.get("name"))
    
    print "temperature of %d degrees last seen %s" % (c.get_temperature(), 
           time.ctime(c.get_temperature_updated_at()))
           
    print  "humidity of %d percent last seen %s" % (c.get_humidity(),
            time.ctime(c.get_humidity_updated_at()))
コード例 #7
0
ファイル: Wink.py プロジェクト: jwr456/alarmpi
 def __init__(self):
     self.w = wink.init("config.cfg")
コード例 #8
0
def enum(**enums):
    return type('Enum', (), enums)

Commands = enum(Turn_On='Turn_On', Turn_Off='Turn_Off', Lock='Lock', Unlock='Unlock')
Commands_Payload = enum(Turn_On='{ "desired_state" : { "brightness": "0.9", "powered": "True" }}', Turn_Off='{ "desired_state" : { "brightness": "0.1", "powered": "False" }}', Lock='{ "desired_state" : { "locked": "False" }}', Unlock='{ "desired_state" : { "locked": "False" }}')

# ID Fields for supported devices
LIGHT_BULB_ID = "light_bulb_id"
LOCK_ID = "lock_id"

# Device types:
LIGHT_BULBS = "light_bulbs"
LOCKS = "locks"

# Global API
wink_api = wink.init("config.cfg")

#Device IDs
lock_id= '33713'
light_bulb_id = '595306'

# TODO: login code for token refresh before starting to run the code (with a button)
# TODO: Add alarm change for the door lock
def _refresh_authentication():
    # reauthenticate:
    cf = persist.ConfigFile('config.cfg')
    auth_obj = cf.load()
    if wink.need_to_reauth(**auth_obj):
        wink.reauth(**auth_obj)

コード例 #9
0
#!/usr/bin/python
#by sarakha63
import sys
import os
os.chdir(os.path.dirname(os.path.realpath(__file__)))
porkfolio_list = []
index = int(sys.argv[1]) - 1
if __name__ == "__main__":
    import wink

    w = wink.init()

    for device in w.device_list():
        if device.device_type() == 'piggy_bank':
            name = 'Inconnu'
            porkid = 'Inconnu'
            serial = 'Inconnu'
            mac = 'Inconnu'
            if device.id:
                porkid = device.id
            if device.data.get("name"):
                name = device.data.get("name")
            if device.data.get("serial"):
                serial = device.data.get("serial")
            if device.data.get("mac_address"):
                mac = device.data.get("mac_address")
            porkfolio_list.append([porkid, name, serial, mac])
print '{"porkid":"' + porkfolio_list[index][
    0] + '","porkname":"' + porkfolio_list[index][
        1] + '","porkserial":"' + porkfolio_list[index][
            2] + '","porkmac":"' + porkfolio_list[index][3] + '"}'
コード例 #10
0
#!/usr/bin/python
#by sarakha63
import os
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__)))
if __name__ == "__main__":
    import time
    try:
        import wink
    except ImportError as e:
        import sys
        sys.path.insert(0, "..")
        import wink

    w = wink.init("config.cfg")
    c = w.piggy_banks()
    for porky in c:
        if porky.data.get("piggy_bank_id") == sys.argv[1]:
            if str(porky.data.get("balance")) == 'None':
                balance = '0'
            else:
                balance = str(porky.data.get("balance") / float(100))
            if str(porky.data.get("last_deposit_amount")) == 'None':
                dernier = '0'
            else:
                dernier = str(
                    porky.data.get("last_deposit_amount") / float(100))
            nez = porky.data.get("nose_color")
            objectif = str(porky.data.get("savings_goal") / float(100))
            if str(porky.data.get("last_reading")
                   ["amount_updated_at"]) == 'None':
コード例 #11
0
ファイル: Wink.py プロジェクト: jwr456/alarmpi
 def __init__(self):
     self.w = wink.init("config.cfg")
コード例 #12
0
if __name__ == "__main__":
    import time
    try:
        import wink
    except ImportError as e:
        import sys
        sys.path.insert(0, "..")
        import wink

    w = wink.init("../config.cfg")

    groups = w.group_list()
    
    print "Turn off the groups"
    for group in groups:
        group.activate(dict(desired_state=dict(powered=False)))
    
    time.sleep(1)
    print "Turn on the groups"
    for group in groups:
        group.activate(dict(desired_state=dict(powered=True)))
    
    time.sleep(1)
    print "Dimm the lights"
    for group in groups:
        group.activate(dict(desired_state=dict(brightness=0.01, powered=True)))
    
    time.sleep(1)
    print "Restore 100% brightness"
    for group in groups:
        group.activate(dict(desired_state=dict(brightness=1.0, powered=True)))