February 2, 2017 at 2:32 pm #45346
Hi, i’m using OS DC Firmware 2.1.7 Hardware 2.3 and having some problems with a HTTP GET command.
I want to use a special station to send a HTTP GET command to a device in my home network. This link is used to start the water on my balcony next to the normal stations i use for the springlers. The problem is that this device is secured with a password.
The link i want to use looks like this: “http://user:[email protected]:80/preset?switch=1&value=0” as example for switching it off (value=1 for on). This link is working when i use it in a browser and also is used in a homebridge project using a Pi … So, in OS i used the server name field for “http://user:[email protected]” the port is “80” and on command is “preset?switch=1&value=1”. But this isn’t working. I’ve tried several other combinations but nothing is working.
Do you know what i’m doing wrong?February 4, 2017 at 8:27 am #45354
I don’t think there is a way to setup authentication parameters via the UI. OS expects the contents of the server field in the UI to be either a simple server name or ip address, i.e. 192.168.1.210. It does not have code to parse the user:pass elements. I had a hand in writing this bit of the code so apologies for not making it more extensible to authentication.
If you are comfortable changing the firmware code and rebuilding then there may be a way to hardcode the user:pass details into the firmware by modifying a line in function switch_httpstation() in file OpenSprinkler.cpp ((line 1172 in current version):
From: ether.browseUrlRamHost(PSTR(“/”), cmd, server, httpget_callback);
To: ether.browseUrlRamHost(PSTR(“/”), cmd, server, PSTR(“Accept: text/html\r\nAuthorization: Basic dXNlcjpwYXNz”), httpget_callback);
Where dXNlcjpwYXNz is the base64 encoding of user:pass string which you can get via one of the online converters (google “base64 encode” – https://www.base64encode.org/)
Unfortunately, I can’t test this (I dont have an http station requiring authentication) but it “may” work. Obviously, it is somewhat limited if you have multiple http stations with different usernames/passwords. Ray may have a better answer but I am curious if this works 8)June 7, 2019 at 8:50 am #60878
Realize this is an old thread but I am up against the same issue – the relay board I am using requires basic authentication in the form of user:[email protected]<ip address> and I’ve been unable to make this work, as stated above.
Have there been any updates? Would it be possible to include such an ability in a future firmware? simply tacking a string on before the IP or changing how the IP field is parsed would satisfy the requirement.
Thanks!June 9, 2019 at 4:20 am #60934
As Peter described, user authentication for HTTP station is currently not supported by the firmware because it requires additional parsing and modifications to the switch_httpstation function. I am curious what kind of ‘relay board’ that you are using requires authentication?
An alternative (albeit a bit ugly) way to achieve this is to use a local server to do the translation, basically, have OpenSprinkler send a command to the server, with user name, password encoded in its On/Off command, and the server will translate it to the appropriate HTTP command and send it out. This server can be done using a raspberry Pi or any Linux box, and you can write the script in Python, nodejs etc.June 9, 2019 at 7:18 am #60940
good morning, thank you for the reply!
I’m using this relay board: https://www.ebay.com/itm/8-Ch-Relay-Network-IP-Relay-Web-Relay-Dual-Control-Ethernet-RJ45-interface-US/173093192868 It takes http commands in the following format: http://admin:[email protected]/relay_en.cgi?relayon2=on with no way (that I’ve found) in the firmware to disable authentication. I use the boards in conjunction with OpenHAB to handle contact closures and misc tasks around the property – they are rough around the edges but for the price not found a better solution.
I realize supporting such would require modification, as it would be a very simple one figured i’d ask. I can set up a translation script as you mentioned but if a more elegant solution could be added into the OSP codebase i’d be thrilled!June 10, 2019 at 3:09 am #60972
OK, I will look into how to enable authentication.June 10, 2019 at 1:34 pm #60985
Thanks!! While this is being reviewed would it be possible to expand the update to send HTTP PUT as well? It’d be neat to be able to call REST API’s on station trigger.
You must be logged in to reply to this topic.