26.10.2016, 13:42
(This post was last modified: 26.10.2016, 15:55 by Jørn.
Edit Reason: Additions
)
(25.10.2016, 21:38)Erwin van der Zwart Wrote: Hi Jørn,
Use this:
BR,
Erwin
Thanks, i had to hack it somewhat to make it to work, resulted in this;
Code:
value = event.getvalue()
previousvalue = storage.get ('outside_temp') -- name 'previous_value' must be unique in each script
if previousvalue >= 2.01 and value <= 2 then
-- put here your push command one
require("user.pushover")
--Set title for message
title = 'Notification'
--Set message to be send (current time and date will be added automaticly)
message = 'Near Freezing'
--Set sound to be played on device
--pushover(default), bike, bugle, cashregister, classical, cosmic, falling, gamelan, incoming, intermission, magic, mechanical, pianobar, siren, spacealarm, tugboat, alien, climb, persistent, echo, updown, none
sound = 'updown'
--Set priority (-2 = no notification only badge and message in app, -1 = notification without sound or vibration, 0 = default, 1 = bypass user quiet hours (set in App not iOS), 2 = bypass user quiet hours (set in App not iOS) + acknowledge required
priority = -1
--Seconds to retry when not acknowledged, minimum = 30 (only used with priority 2)
retry = 60
--Seconds to expire retry when not acknowledged, maximum = 86400 (24 hrs, only used with priority 2)
expire = 5400
--Activate Pushover with parameters above
pushover(title, message, sound, priority, retry, expire)
end
storage.set ('outside_temp', value) -- name 'previous_value' must be unique in each script
In this instant used to alert when temperature outside gets close to freezing. Maybe a little messy, but it does the job
I was not able to save the script with "end" after storage.set , but it seems to be working.'
Edit; To make it work, i have to run a script first with only getvalue and storage.set, to make it write a value to storage. If not, the script get stopped before getting to store the value (error; attempt to compare number with nil). Workarounds to avoid this`?
Best regards, Jørn.