Page 1 of 1
How to get temperature from via JSON call from Domoticz?
Posted: Sunday 05 August 2018 23:13
by kimhav
Been looking at the
Domoticz API/JSON and it seems that it's not possible to get the temperature from one specific sensor or did I miss something which isn't clear or documented?
Re: How to get temperature from via JSON call from Domoticz?
Posted: Sunday 05 August 2018 23:21
by elmortero
like this?

- temp.JPG (29.2 KiB) Viewed 6526 times
Re: How to get temperature from via JSON call from Domoticz?
Posted: Monday 06 August 2018 17:30
by kimhav
Well, Okay, let me rephrase, what I was looking for was to only get the temperature and nothing else from a sensor just to simplify the integration. The initial question was based on that I was playing around with IFTTT which currently doesn't support this kind of specific request. So in this case less is more

Re: How to get temperature from via JSON call from Domoticz?
Posted: Monday 06 August 2018 18:12
by ben53252642
JSON is a format that you need to learn how to navigate. For example this linux bash command gets only the temperature.
Make sure you have jq installed: apt-get install jq
Code: Select all
curl -s 'http://username:password@ipaddress/json.htm?type=devices&rid=778' | jq .result[0].Data | sed 's/\"//g' | awk '{ print $1 }
The above in my case displays only the temperature number: 20.6 in the terminal.

- example142.JPG (15.49 KiB) Viewed 6490 times
Re: How to get temperature from via JSON call from Domoticz?
Posted: Monday 06 August 2018 18:37
by kimhav
Thank you, I'll continue with the above to pick out what I need; that really helps out.
Re: How to get temperature from via JSON call from Domoticz?
Posted: Monday 06 August 2018 18:42
by ben53252642
kimhav wrote: Monday 06 August 2018 18:37
Thank you, I'll continue with the above to pick out what I need; that really helps out.
Note that the raw output from the JSON was:
"20.6 C"
This removes the quotes: | sed 's/\"//g'
This part on the end displays only the first part of the string: | awk '{ print $1 }'
Get's 20.6
If you only wanted to get C and not the number you would use | awk '{ print $2 }'
Re: How to get temperature from via JSON call from Domoticz?
Posted: Monday 06 August 2018 18:46
by elmortero
Or you use dzVents.
Then you could do something like:
local temperature = domoticz.devices('NAMEOFTHESENSOR').temperature

Re: How to get temperature from via JSON call from Domoticz?
Posted: Monday 06 August 2018 18:49
by ben53252642
elmortero wrote: Monday 06 August 2018 18:46
Or you use dzVents.
Then you could do something like:
local temperature = domoticz.devices('NAMEOFTHESENSOR').temperature
Depends what you are trying to do.

Re: How to get temperature from via JSON call from Domoticz?
Posted: Monday 06 August 2018 19:49
by u01pei
[/quote]
Note that the raw output from the JSON was:
"20.6 C"
This removes the quotes: | sed 's/\"//g'
[/quote]
If you use jq -r the result is also without quotes. saves you the trouble of writing/performing the sed.

Re: How to get temperature from via JSON call from Domoticz?
Posted: Thursday 30 August 2018 11:51
by DAVIZINHO
in linux is posible but is posible in a web browser?. Obtain only the temperature?. this was very usseful for other purpose (ifttt)