Exemple #1
0
def deviceSetup(deviceName, config):
    # Setup with a base config containing email and password
    client = Client(config)

    # Logs into Pushover's servers based on config
    client.login()

    # Registers a new device using the supplied device name
    client.registerDevice(deviceName)

    # Save the new device to a new config so registration
    # can be bypassed in the future
    client.writeConfig(config)
with open(inputConfigFile, 'r') as inputConfig:
    jsonConfig = json.load(inputConfig)

domoticzAddress = jsonConfig["domoticzAddress"]
domoticzUser = jsonConfig["domoticzUser"]
domoticzPassword = jsonConfig["domoticzPassword"]


#Setup with a base config containing email and password
client = Client(inputConfigFile)

#Logs into Pushover's servers based on config
client.login()

#Registers a new device using the supplied device name
client.registerDevice("IFTTTDomoticz")

#Save the new device to a new config so registration
#can be bypassed in the future
client.writeConfig(outputConfigFile)

# Read the output Config file
with open(outputConfigFile, 'r') as outputConfig:
    jsonConfig = json.load(outputConfig)

# Write back to the json the Domoticz values
jsonConfig["domoticzAddress"] = domoticzAddress
jsonConfig["domoticzUser"] = domoticzUser
jsonConfig["domoticzPassword"] = domoticzPassword

# now write back to the output file with all Data
"""
In this example we register a new device to the account provided
in the configuration file.

Please note that if you do not own a Pushover Desktop License for this 
account, after 5 days of registering a new device you will need to 
purchase one. After purchasing you have unlimited access to new desktop
devices. Visit .... for more information.
"""
from pushover_open_client import Client

#Setup with a base config containing email and password
client = Client("example_base.cfg")

#Logs into Pushover's servers based on config
client.login()

#Registers a new device using the supplied device name
client.registerDevice("DeviceName")

#Save the new device to a new config so registration
#can be bypassed in the future
client.writeConfig("example_device.cfg")