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)
# use the file path rather than just relative, because the script can be called from a different working directory inputConfigFile = os.path.dirname(os.path.abspath(__file__)) + "/base.cfg" outputConfigFile = os.path.dirname(os.path.abspath(__file__)) + "/device.cfg" 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)
if (messageList): for message in messageList: # Do work with message here! # Make sure to acknowledge messages with priority >= 2 if (message.priority >= 2): if (message.acked != 1): client.acknowledgeEmergency(message.receipt) # Make sure you delete messages that you recieve! client.deleteMessages(messageList[-1].id) # Setups with a device configuration client = Client("example_device.cfg") # Get any messages sent before the client has started messageList = client.getOutstandingMessages() # Do work with outstanding messages # Make sure you delete messages that you recieve! if (messageList): client.deleteMessages(messageList[-1].id) # Pass our function as a parameter, this will run 'forever' client.getWebSocketMessages(messageCallback) # Can optionally continue doing other work here without the need # to poll the websocket
""" 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")