This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Pushover notification scripting
#1
Hi everybody, i need some help with the Pushover script. Everything is set up and working great, but my issue is that the script runs regardless of the value of the KNX object. I would i.e. like it to run only when the object is set to "1" or "0", and possibly when over or under a certain value (if for example a temperature climbs below or over a set point).
It's easy to make this happen with logic functions on my KNX devices, but i would rather keep it all in the LM5.
My lua programming skills are equal to zero  Confused

Best regards, Jørn.
Reply
#2
Hi,


Use this in your event based script:

value = event.getvalue()
if value == true  then -- or use =< 21

-- put here your push command

elseif value == false then -- or use => 22

-- put here your action / command

end

BR,

Erwin
Reply
#3
(18.09.2016, 11:37)Erwin van der Zwart Wrote: Hi,


Use this in your event based script:

value = event.getvalue()
if value == true  then -- or use =< 21

-- put here your push command

elseif value == false then -- or use => 22

-- put here your action / command

end

BR,

Erwin

Wow, thanks alot Erwin, i've spent hours on this. And now i see i tried to overcomplicate it. Works as inteded now  Smile

Best regards

Best regards, Jørn.
Reply
#4
(18.09.2016, 11:37)Erwin van der Zwart Wrote: Hi,


Use this in your event based script:

value = event.getvalue()
if value == true  then -- or use =< 21

-- put here your push command

elseif value == false then -- or use => 22

-- put here your action / command

end

BR,

Erwin

Hi again Erwin, another problem arose when i started using this for real. I get an alert every time the bus get's updated with a lower value than set. What would i need to add in the script to make it check previous value, and not to run the script if previous value already led it to run the script`?

BR,
Jørn

Best regards, Jørn.
Reply
#5
Hi Jørn,

Use this:

Code:
value = event.getvalue()

previousvalue = storage.get('previous_value') -- name 'previous_value' must be unique in each script

if value ~= previousvalue then

 if value == true then -- or use =< 21

 -- put here your push command

 elseif value == false then -- or use => 22

 -- put here your action / command

 end
 
 storage.set('previous_value', value) -- name 'previous_value' must be unique in each script

end

BR,

Erwin
Reply
#6
(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  Wink

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.
Reply
#7
Hi, I have set up and used the pushover script according to the example given by Erwin (thank you for this), but I cannot see how I can select which device the message should be delivered to. So far I have downloaded and registered the mobile app in my phone and my wife's phone, but the messages are broadcasted to both phones. In the pushover website, you can choose to send a test notification by choosing a specific registered device or all the registered devices (broadcast). Is there another script that allows to select to which device the notification is send to?
Thank you in advance.

EDIT: I have seen in pushover API documentation that I can include in the sending url another optional field called "device" which is what I was looking for, so I will try this to see. I propose for Erwin to edit his original example in order to include this field as I found it very useful.
Reply
#8
And there is also a possibility to create specific groups and use their token instead the user token.

Pushover Groups API
Reply
#9
(28.12.2016, 21:59)buuuudzik Wrote: And there is also a possibility to create specific groups and use their token instead the user token.

Pushover Groups API

thank you buuuudzik!
Reply
#10
You're welcomeWink
Reply
#11
I have played around a bit with Pushovers Glances API for the Apple Watch. It´s currently in Beta.

They specifically ask you not to send more than 1 update to the Glances API every 20 minutes, because of the way that Apple handles battery efficiency on the Apple Watch. It seems to work reliably though, except if you do not open the main app on your iPhone every 2 days. I suppose this is because of the lack of background tasking in iOS.

Create a new user library, user.glances :

Code:
require 'ssl.https'

local glances_url = 'https://api.pushover.net/1/glances.json'
local token = 'INSER APPLICATION TOKEN' -- Your application token, at least 1 app must be created at pushover.net to get the application token
local user = 'INSERT USER TOKEN' -- Your user token, retrieve from settings inside pushover application for ios

function glances(title, text, subtext, count, percent)
 local data_str = 'user=' .. user .. '&text=' .. text .. '&subtext=' .. subtext .. '&token=' .. token .. '&title=' .. title  .. ''
 local res, code, headers, status = ssl.https.request(glances_url, data_str)
end

This script handles info sent to the Glances API, specified by you:

Code:
--Glances-script
--Some glances support 3 lines of text, some only support percentage or count, etc
--Set title for glance
title = 'TITLE GOES HERE'
--Set 1st textfield
text = 'TEXT'
--Set 2nd textfield
subtext = 'SUBTEXT'
count = ''
percent = ''
--Calls the user.glances user library
glances(title, text, subtext, count, percent)


I´m sure this code can be cleaned up some, but just wanted to post it so other people can try it out.
Reply


Forum Jump: