I have just started toying around with creating an app for my hub. I just want to periodically make a web request to my server, however it seems that this isn’t working at all because no action is taken (the server isn’t receiving anything). My function is just this (with the server IP hidden):
def initialize() {
// TODO: subscribe to attributes, devices, locations, etc.
try {
while (1 == 1) {
httpGet('**.**.**.**:****/path')
pause(30000)
}
} catch (e) {
log.error "something went wrong: $e"
}
}
Any idea what is going on? Do I need special permissions to run this?
This may work once, but the initialize() call will quickly fail; your function callbacks in a smartapp (or device handler) have a limited time to perform operations (30 seconds?); your idea of having an infinite loop with requests every 30 seconds will not work.
Your best option is probably to schedule a time based event happening every minute or so (timed events are not too reliable, but timed events with intervals < 60 seconds are totally unreliable).