This page last changed on May 16, 2014 by craigham.

Hi,

I am using a service called push.co to send notifications to my iPhone. To send a notification, a http post just has to be sent to their service. I have this working using a command with the http protocol.

However, I would like to parameterize this so I can send different messages within the notifications. I currently send the notification within rules, with this: execute.command("push-send-notification");

Does anyone have a suggestion on how I could parameterize this, so I could send a notification like "Garage Door Open Extended Amount of Time", or "Security Alarm Tripped" depending on context?

thanks,
craig

Replace the message to send in your command with {param}.
Now you can use execute.command("push-send-notification", "message") and the placeholder {param} will be replaced with "message".

Posted by mredeker at May 17, 2014 21:43

I tried what you suggested, but that didn't seem to work.

I changed the workload for the http command to be:

message={param}&api_key=xxxxxx&api_secret=yyyyyyy

I ran it in the debugger, and this line:
org.openremote.controller.command.Command cmd = commandFactory.getCommand(commandElement);

Returns the http command, with the workload still having

{param}
in it...there was no substitution.

Am I doing something incorrectly?

thanks,
craig

ps. you can ignore that unknown macro message, I just can't figure out how to leave the parentheses in my posting.

Posted by craigham at May 18, 2014 01:59

Figured it out...I need the

${param}
, not just param

thanks,
craig

Posted by craigham at May 18, 2014 02:23

Hello Craig,

I got interested in push.co after reading your thread. But unlike yourself I can not get it working. Could you please let me know what you entered (exactly) as url, workload in the http(s) post command and in the rule (to replace the parameterplaceholder)? Of course I need to enter my own api-key and api-secret.

Regards,
Nico

Posted by nicokluin at May 24, 2014 21:02

Hi Nico,

I am out of town until Tuesday. I will post the info when I get back.

Craig

Posted by craigham at May 25, 2014 02:34

Ok, here is how I did it:

protocol: http
for url: https://api.push.co/1.0/push
method: post
workload: message=${param}&api_key=aaaa&api_secret=xxxx

that's it.

craig

Posted by craigham at May 28, 2014 22:56

Is there a way to post messages with the dollar sign/parenthesis? ie a /code tag or something?

Nico, my message is confusing because the forum software is treating part of my text as a macro. Just ignore that Unknown macro: stuff. The workload starts with message and goes right through on 1 line including the api_secret info.

craig

Posted by craigham at May 29, 2014 21:17

Please put into {code} tag otherwise wiki markup is messing up the post.

Posted by mredeker at May 29, 2014 21:17

Thanks Marcus,

I have now fixed my original post.

Posted by craigham at May 29, 2014 21:33

Craig,

Thank you! Because of the unknown macro stuff, I could not figure it out. Now it is readable and I can test the setup tomorrow.

Posted by nicokluin at May 30, 2014 18:51

Craig,

No message is sent... I tried with a fixed message like this: message="test"&api_key=aaaa&api_secret=xxxx. Should the message and/or the api_key/api_secret be enclosed in "? Or should it just be text? And do I fill in the user/password or is it blanc? In the logfile it seems that it states that the response says 'forbidden'. That would indicate I need to add something for authentication. Would you know what to do?

Posted by nicokluin at Jun 01, 2014 12:43

Hi Nico,

I would first get it working with just test as you have attempted...but remove the quotes. No quotes at all in the workload field.

Do not set the user/pass. I would expect that works for basic type http authentication, but for the push.co service, the authentication is instead part of the Post body.

Keep watching the logs, when it does start working you will get a message successfully added or queue response from push.co.

Double check your key and secret values, and make sure there are no spaces in the workload.

If that fails, you can try emailing push.co's email support. That is what I did. They helped me substitute the ampersand for spaces in the workload. They took awhile to respond the first time, but did get back to me.

Hope that helps. It does work well for me now, I can send contextual messages to my phone no problem now.

craig

Posted by craigham at Jun 01, 2014 17:40
Document generated by Confluence on Jun 05, 2016 09:37