Hi,
Thanks for your fast responds, I was a little busy at the time being.
I already installed the plugin that you suggested but I forgot to mention that in my question. See the attached images.
Did I do something wrong maybe?
Hi,
Thanks for your fast responds, I was a little busy at the time being.
I already installed the plugin that you suggested but I forgot to mention that in my question. See the attached images.
Did I do something wrong maybe?
Are you using an “admin” account?
As Frank just mentioned in this thread, you probably will need to use the controller’s admin account in order to write to a global variable.
You can use his work around to perform the variable writes in a scene & then have Home Remote trigger the scene.
Although, that might not work for you. For the HC3, I’m pretty certain you need the “admin” account to execute a scene too. You may have no choice but to use the “admin” account.
Yes I’m using an admin account.
Installed it.
When the button is clicked I get an error ‘code 400 bad request’
Try adding a “.toString()” in the PUT request:
Did that, error still there.
I’m not exactly sure how a variable write is performed on the HC3. Maybe send this question to the Fibaro support staff or raise it in the Fibaro forum.
How to write to Global Variable with CURL?
See you can figure out how to do this with CURL. Then test it on your PC to prove it actually works. Once that’s done then show me the CURL & I can make whatever changes I need to make in that plugin script.
All Windows 10 machines already have CURL installed. You can also download it here.
https://curl.haxx.se/
I managed to set a GlobalVariable with Windows 10 curl.
U MUST use the admin user, otherwise it will NOT work.
Here is my curl command I tested it with:
The name of the GlobalVariable is: VentilatieRestTijd
curl -v -X PUT -u admin:password -d “{“name”: “VentilatieRestTijd”, “value”: “123”}” http://192.168.178.4/api/globalVariables/VentilatieRestTijd
(The syntax is a bit different in Windows than it is in linux.)
Make sure to also include the variable name in the url otherwise you get a: 400 Bad Request.
Great! Now can you test writing to that with the plugin & see if it works? Please test both the original & version 2.
The only thing it’s doing differently is its also setting the “readOnly” & “isEnum” properties as well. Those shouldn’t make a difference but we can try removing them if it’s not working.
Not sure what you mean with Version 2.
I tested is with the version I downloaded last weekend from the HomeRemote website.
I got it working by changing the following:
In the “OnChangedRequest” function I removed: , headers: { ‘content-type’: ‘application/x-www-form-urlencoded’ } and that did the trick.
http.put(baseURL + “/globalVariables/” + device.Id, { name: device.Id, value: value, readOnly: false, isEnum: false }, { auth: credentials });
I also tested removing readOnly and isEnum and that also worked.
Almost forgot.
Is there a way to rewrite the script to use a basic authentication header like:
Basic ZnJhbms6d2Vpam5uZQ==
In that case the admin password is no longer visible in the project.
Thanks. I went ahead & removed that from that plugin code.
Yes. Here’s a plugin that removes the credentials & hard-codes the Basic header.
Hi guys, thanks for the help so far.
Maybe it is me, reinstalled the plugin, set a new trigger, tried some things you suggested, still get an error (400 bad request ). I’m using the admin account for the connection, so I don’t see a problem there. Reading the variable value is going fine. Writing to it gets me an error.
Can you see if I did something wrong?
It could be that this changed between versions HC2 & HC3.
@Frank_Weijnen what version of controller are you running?
I recommend doing what Frank did. Experiment with CURL. Verify you can get it working with that. I don’t know that the request Frank showed earlier will work with CURL on Windows 10. You need to escape quotes on Windows. So your request will look something like this. Just open up the Windows command prompt & send this command.
curl -v -X PUT -u admin:password -d "{\"name\": \"VentilatieRestTijd\", \"value\": \"123\"}" http://192.168.178.4/api/globalVariables/VentilatieRestTijd
I am running HC2 on version 4.590.
I just downloaded and installed the new GlobalVariabels script and it works fine for me.
@bill I also tried your version with basic authentication but that one throws an error:
I also tried changing the script file with the proper data but still the same popup.
Regarding the curl request: The curl command in my reply was changed during the past command I guess. (Windows handles the quotes differently than linux.)
The one that you are showing in your reply works on Windows 10, I just tested it.
The option: -v is not required, it just gives you feedback on the command.
I’m not sure why the plugin I posted that manually sets the Authorization header isn’t working. I just stepped through it & all looks good.
I will do some testing this weekend to see if I get it working.
@bill, I had a look at the Basic authentication issue I had.
Looks like a quote was deleted when I changed the basic authentication code.
So your example worked ok.
So for me, using HC2 with version 4.590, writing GlobalVariables works.