Hi All
If I would like VL53L0X to send a webrequest on certain values I guess that should be done in Rules.
But how would a script like that be done?
It was no problems to get the VL53L0X up and running and Webrequest seems pretty easy, but Rules that's a another ballpark for me:)
VL53L0X webrequest on certain values?
Moderators: grovkillen, Stuntteam, TD-er
Re: VL53L0X webrequest on certain values?
Assuming you have already enabled the Rules option in Tools/Advanced, that could be something like this:
Instead of SendToHTTP, using a GET request, you can, when using a very recent build (not released yet), use the PostToHTTP command, with user-defined headers and a post-body, that can also contain the value.
Both SendToHTTP and PostToHTTP support user:password@host authentication, if needed, and PostToHTTP can use alternative authentications by providing the required header arguments.
Edit: Fixed small typo in the code.
Code: Select all
On Vl53l0x#Distance do
If %eventvalue1% < 100
// Too close
SendToHTTP,host,80,/url/to/send?value=%eventvalue1%&level=TooClose
Elseif %eventvalue1% < 500
// Close enough
SendToHTTP,host,80,/url/to/send?value=%eventvalue1%&level=Good
Else
// Too far away
SendToHTTP,host,80,/url/to/send?value=%eventvalue1%&level=TooFar
Endif
Endon
Both SendToHTTP and PostToHTTP support user:password@host authentication, if needed, and PostToHTTP can use alternative authentications by providing the required header arguments.
Edit: Fixed small typo in the code.
/Ton (PayPal.me)
Re: VL53L0X webrequest on certain values?
THANK YOU Ath, that worked like a charm!
Can I have a follow up question, is it possible to set a fixed value so the SendToHTTP is only triggered on for example the value 100?
//Per
Can I have a follow up question, is it possible to set a fixed value so the SendToHTTP is only triggered on for example the value 100?
//Per
Re: VL53L0X webrequest on certain values?
You're welcome
Sure, just a different value comparison:
Code: Select all
On Vl53l0x#Distance do
If %eventvalue1% = 100
// Just right
SendToHTTP,host,80,/url/to/send?value=%eventvalue1%&level=SpotOn
Endif
Endon
/Ton (PayPal.me)
Re: VL53L0X webrequest on certain values?
You are so right, I could have discovered that by my self in 5 min but I was so excited that it worked soI didn't think before i wrote, sorry, but never less a big thank you Ath for you help and I owe you a beer:)Ath wrote: ↑23 Jan 2023, 22:53
Sure, just a different value comparison:The syntax isn't very hard, please read the fine documentation & examples for Rules, so you can extend/modify the code yourselfCode: Select all
On Vl53l0x#Distance do If %eventvalue1% = 100 // Just right SendToHTTP,host,80,/url/to/send?value=%eventvalue1%&level=SpotOn Endif Endon
Who is online
Users browsing this forum: No registered users and 127 guests