• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling URL on event
#1
Hello!

First of all, great project! Its been loads of fun playing around with this!

So, my question: is it possible for pilight to call a URL when a device is switched?

I've set up a few 433 Mhz devices on a Pi, and its working, pilight sniffs the commands of the transmitters and I can send commands to my lights.

However, I also want to send a message to the webserver on my Pi (and control other stuff that way) when I push a button on my 433 Mhz remote. Is that possible?

Thanks alot!
 
Reply
#2
Not within pilight itself, but this is what the API is for Smile

Have a look at the manual, it describes how you can use the API to communicate with the pilight-daemon. You can then write your own script which will listen for switching actions in pilight and call the URL once a certain device is switched.
 
Reply
#3
If you are using the pilight 6 or 7 development version, you may find my webswitch protocol useful. It is one my pilight addons in this Github repository.
 
Reply
#4
Thank you both for your suggestions!

(04-16-2016, 08:13 AM)pilino1234 Wrote: Not within pilight itself, but this is what the API is for Smile

Have a look at the manual, it describes how you can use the API to communicate with the pilight-daemon. You can then write your own script which will listen for switching actions in pilight and call the URL once a certain device is switched.

Actually I tried an approach like that, using a nodejs json parser to read pilight-receive. But for some reason it all became very unresponsive after pushing alot of 433mhz buttons, or after pushing one button for a long time. Not sure if the CPU of the raspberry was taxed too much and it throws off the timings of the pulses or something like that?
Also, there seemed to be a delay between pushing buttons and pilight-receive response.
I added the ATTiny pre-filter, hoping it would smooth things out, but it didnt.

After that I tried setting up pilight to have buttons of one brand control lights of another. It seems to work a bit better (after pushing buttons for a long time, it becomes unresponsive again, though).

(04-16-2016, 11:36 AM)Niek Wrote: If you are using the pilight 6 or 7 development version, you may find my webswitch protocol useful. It is one my pilight addons in this Github repository.

That looks interesting, and it also made me realize that there is a 'program' protocol, maybe i could use it to call a bash script on the Pi directly..?
 
Reply
#5
Yes, if you just need to call some uri and don't need to use detailed response data within pilight, you can use the program protocol to simply fire a bash- (or python) script.
 
Reply
#6
The webswitch protocol I created is very useful to control remote services via http(s), because the state of the switch is representing the actual state of the remote service. In case one just needs to call a service that doesn't have a state, or if that state is irrelevant, or if the url or the parameters are depending on device values (like switch states, dimlevels etc.) an action that can be invoked by a rule is a better solution.

So I additionaly created an http action (for pilight V7) that can be used in pilight rules to send HTTP(S) POST or GET requests, either with or without parameters. The result of the request can optionally be stored in a generic label and can then be displayed in the gui, and/or can be used in other rules.

General format:
Code:
IF ... THEN http GET|POST <url> [PARAM <parameters>] [RESULT <label device>]

GET or POST and url are mandatory, PARAM and RESULT are optional.
Url and parameters can be strings or device values or combinations of both.

For more details and code see this repository
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Always trigger event on any device state Phil 8 2,143 03-22-2017, 07:30 PM
Last Post: Phil
  datetime event again wupperpi 5 2,359 02-26-2017, 10:11 PM
Last Post: wo_rasp
  event at randomized time after another event Emiks5 3 1,506 05-07-2016, 09:10 AM
Last Post: Thunder84
  tfa sensors - event if no data were received oeiber 6 2,022 02-21-2016, 11:07 PM
Last Post: oeiber
  datetime event kreg 4 2,707 06-24-2015, 05:36 PM
Last Post: kreg
  Event action sipcal to make a voip phonecall pieterd 7 4,185 05-15-2015, 05:47 PM
Last Post: koos147

Forum Jump:


Browsing: 1 Guest(s)