How to get temperature from via JSON call from Domoticz?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
Post Reply
kimhav
Posts: 109
Joined: Tuesday 01 October 2013 8:31
Target OS: Raspberry Pi
Domoticz version: 4.10215
Location: Malmo, Sweden
Contact:

How to get temperature from via JSON call from Domoticz?

Post by kimhav » Sunday 05 August 2018 23:13

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?
Member of Domoticz Sweden Telegram Group

elmortero
Posts: 241
Joined: Sunday 29 November 2015 21:46
Target OS: Raspberry Pi
Domoticz version: 3.9639
Location: Spain
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by elmortero » Sunday 05 August 2018 23:21

like this?
temp.JPG
temp.JPG (29.2 KiB) Viewed 711 times

kimhav
Posts: 109
Joined: Tuesday 01 October 2013 8:31
Target OS: Raspberry Pi
Domoticz version: 4.10215
Location: Malmo, Sweden
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by kimhav » Monday 06 August 2018 17:30

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 :mrgreen:
Member of Domoticz Sweden Telegram Group

ben53252642
Posts: 538
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by ben53252642 » Monday 06 August 2018 18:12

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
example142.JPG (15.49 KiB) Viewed 675 times

kimhav
Posts: 109
Joined: Tuesday 01 October 2013 8:31
Target OS: Raspberry Pi
Domoticz version: 4.10215
Location: Malmo, Sweden
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by kimhav » Monday 06 August 2018 18:37

Thank you, I'll continue with the above to pick out what I need; that really helps out.
Member of Domoticz Sweden Telegram Group

ben53252642
Posts: 538
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by ben53252642 » Monday 06 August 2018 18:42

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 }'
Last edited by ben53252642 on Monday 06 August 2018 18:49, edited 1 time in total.

elmortero
Posts: 241
Joined: Sunday 29 November 2015 21:46
Target OS: Raspberry Pi
Domoticz version: 3.9639
Location: Spain
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by elmortero » Monday 06 August 2018 18:46

Or you use dzVents.
Then you could do something like:
local temperature = domoticz.devices('NAMEOFTHESENSOR').temperature

:-D

ben53252642
Posts: 538
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by ben53252642 » Monday 06 August 2018 18:49

elmortero wrote:
Monday 06 August 2018 18:46
Or you use dzVents.
Then you could do something like:
local temperature = domoticz.devices('NAMEOFTHESENSOR').temperature

:-D
Depends what you are trying to do. 8-)

u01pei
Posts: 54
Joined: Sunday 04 January 2015 17:17
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by u01pei » Monday 06 August 2018 19:49

[/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. ;)

DAVIZINHO
Posts: 206
Joined: Sunday 27 August 2017 18:00
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Spain
Contact:

Re: How to get temperature from via JSON call from Domoticz?

Post by DAVIZINHO » Thursday 30 August 2018 11:51

in linux is posible but is posible in a web browser?. Obtain only the temperature?. this was very usseful for other purpose (ifttt)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests