Page 1 of 1
API/JSON URL to set options for a Counter Sensor
Posted: Monday 07 November 2016 17:40
by BakSeeDaa
Hi there.
I can create a counter device using the following URL:
Code: Select all
json.htm?type=createvirtualsensor&idx=999999&sensorname=MyCounter&sensortype=113
Then I can set further properties for that device using the following URL:
Code: Select all
json.htm?type=setused&idx=421&name=MyCounter&description=Some description&switchtype=3&addjvalue=0&used=true&options=VmFsdWVRdWFudGl0eSUzQUNvdW50JTNCVmFsdWVVbml0cyUzQSUzQg==
But I have no idea what that string is following "&options=" and how I can construct one. I'd like to set the values for "Value Quantity (e.g. Weight)" to "Time "and "Value Units (e.g. Kg)" to "h" by using a script.
If You think You can help me, I'd appreciate it a lot. Thanks

Re: API/JSON URL to set options for a Counter Sensor
Posted: Monday 07 November 2016 20:37
by stlaha2007
I'm wandering; where did you get that info from? Just looked at the wiki JSON-API at counter, however i dont see other values being specified... It looks interresting. Have some devices which i also want to get into and updated in Domoticz by scripts.
Sent from my K00C using Tapatalk
Re: API/JSON URL to set options for a Counter Sensor
Posted: Tuesday 08 November 2016 7:21
by BakSeeDaa
stlaha2007 wrote:I'm wandering; where did you get that info from? Just looked at the wiki JSON-API at counter, however i dont see other values being specified... It looks interresting. Have some devices which i also want to get into and updated in Domoticz by scripts.
Sent from my K00C using Tapatalk
While performing the task You like to find the JSON command for in the browser, use the "Inspect element' feature of your browser (right mouse click an area), choose the "Network" tab. Doing that, You may find out which Json command is being sent.
Re: API/JSON URL to set options for a Counter Sensor
Posted: Tuesday 08 November 2016 7:36
by stlaha2007
Using FireFox mostly and getting used to the Inspect option.
The way you figured out does me think of tryin to create the counter from hardware or even better the custom sensor and fill in some 'know parameters' like electricity/gas/temp(-hum-baro). Perhaps thats what gonna explain in more detail how these have to look like...
I kind of hoped that Gizmocuz replied already with some details. As i can imagine that it needs some formatting-logic behind the scenes.
Sent from my K00C using Tapatalk
Re: API/JSON URL to set options for a Counter Sensor
Posted: Tuesday 08 November 2016 7:47
by BakSeeDaa
stlaha2007 wrote:Using FireFox mostly and getting used to the Inspect option.
The way you figured out does me think of tryin to create the counter from hardware or even better the custom sensor and fill in some 'know parameters' like electricity/gas/temp(-hum-baro). Perhaps thats what gonna explain in more detail how these have to look like...
I kind of hoped that Gizmocuz replied already with some details. As i can imagine that it needs some formatting-logic behind the scenes.
Sent from my K00C using Tapatalk
I guess I might have a look in the source code trying to figure out what the
VmFsdWVRdWFudGl0eSUzQUNvdW50JTNCVmFsdWVVbml0cyUzQSUzQg== string is.
Re: API/JSON URL to set options for a Counter Sensor
Posted: Tuesday 08 November 2016 8:05
by BakSeeDaa
The answer to my question was in the source code.
Code: Select all
'&options=' + btoa(encodeURIComponent(devOptionsParam.join('')))
It's a ASCII string that has been URL encoded and Base64 encoded
VmFsdWVRdWFudGl0eSUzQUNvdW50JTNCVmFsdWVVbml0cyUzQSUzQg== decodes as (using ASCII character set)
Code: Select all
ValueQuantity%3ATime%3BValueUnits%3Ah%3B
which can be url decoded and read as:
Cheers!
Re: API/JSON URL to set options for a Counter Sensor
Posted: Tuesday 08 November 2016 9:17
by stlaha2007
Nice decoding... Kinda solved by yourself...
This makes me curious what kind of sensor your trying to build... Does it have todo with your previous question about which sensor to choose?
Sent from my K00C using Tapatalk
Re: API/JSON URL to set options for a Counter Sensor
Posted: Tuesday 08 November 2016 9:22
by BakSeeDaa
stlaha2007 wrote:Nice decoding... Kinda solved by yourself...
This makes me curious what kind of sensor your trying to build... Does it have todo with your previous question about which sensor to choose?
Sent from my K00C using Tapatalk
Yes it does. It's for my project
Domoticz RPC for NIBE Uplink 
Re: RE: Re: API/JSON URL to set options for a Counter Sensor
Posted: Tuesday 08 November 2016 9:35
by stlaha2007
BakSeeDaa wrote:stlaha2007 wrote: Does it have todo with your previous question about which sensor to choose?
Yes it does. It's for my project
Domoticz RPC for NIBE Uplink 
Very Nice !!!
Sent from my K00C using Tapatalk