How to get temperature from via JSON call from Domoticz?
Moderators: leecollings, remb0
-
kimhav
- Posts: 154
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
How to get temperature from via JSON call from Domoticz?
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?
-
kimhav
- Posts: 154
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
Re: How to get temperature from via JSON call from Domoticz?
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 
-
ben53252642
- Posts: 543
- 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?
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
The above in my case displays only the temperature number: 20.6 in the terminal.
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 }Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
-
kimhav
- Posts: 154
- Joined: Tuesday 01 October 2013 8:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: Sweden
- Contact:
Re: How to get temperature from via JSON call from Domoticz?
Thank you, I'll continue with the above to pick out what I need; that really helps out.
-
ben53252642
- Posts: 543
- 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?
Note that the raw output from the JSON was: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.
"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.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
-
elmortero
- Posts: 248
- Joined: Sunday 29 November 2015 20:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: How to get temperature from via JSON call from Domoticz?
Or you use dzVents.
Then you could do something like:
local temperature = domoticz.devices('NAMEOFTHESENSOR').temperature

Then you could do something like:
local temperature = domoticz.devices('NAMEOFTHESENSOR').temperature
-
ben53252642
- Posts: 543
- 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?
Depends what you are trying to do.elmortero wrote: Monday 06 August 2018 18:46 Or you use dzVents.
Then you could do something like:
local temperature = domoticz.devices('NAMEOFTHESENSOR').temperature
![]()
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
-
u01pei
Re: How to get temperature from via JSON call from Domoticz?
[/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.
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: 234
- Joined: Sunday 27 August 2017 18:00
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Spain
- Contact:
Re: How to get temperature from via JSON call from Domoticz?
in linux is posible but is posible in a web browser?. Obtain only the temperature?. this was very usseful for other purpose (ifttt)
Who is online
Users browsing this forum: Google [Bot] and 1 guest