Read actual sensor value using API

Moderator: leecollings

Post Reply
eiaro
Posts: 12
Joined: Monday 22 May 2017 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norway
Contact:

Read actual sensor value using API

Post by eiaro »

I've read and searched, but haven't been able to find a way to get the current last reading of a sensor using the API.

Any suggestions before I start changing source code?
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Read actual sensor value using API

Post by Egregius »

Did you even look at the API wiki page? It's full of explanation.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Read actual sensor value using API

Post by Egregius »

Did you even look at the API wiki page? It's full of explanation.
eiaro
Posts: 12
Joined: Monday 22 May 2017 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Norway
Contact:

Re: Read actual sensor value using API

Post by eiaro »

Of course I did. :)

I *can* use /json.htm?type=devices&rid=IDX, but it return a lot of data I dont need.
User avatar
Egregius
Posts: 2582
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Read actual sensor value using API

Post by Egregius »

Just use the ones you need and skip the rest.
stlaha2007
Posts: 370
Joined: Monday 05 October 2015 10:16
Target OS: -
Domoticz version:
Contact:

Re: Read actual sensor value using API

Post by stlaha2007 »

Look at the python, lua examples for a way to filter the exact value...

In bash {cli} i do simular thing like: curl 'domosite:8080/json.htm.....' | grep 'value' | awk {}


Sent from my D6603 using Tapatalk
tvurce
Posts: 30
Joined: Saturday 27 October 2018 19:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read actual sensor value using API

Post by tvurce »

Anybody hawe a good solution to read value fron Json returned String on Arduino (C++)? No problem to get info from Domoticz with

Code: Select all

  int httpCode = http.GET();
    if (httpCode > 0) {
      if (httpCode == 200) {
        String payload = http.getString();
        Serial.println("Domoticz response "); 
        Serial.println(payload);
      }
    }   
  http.end();
But what now with that string? A lot of stuff there...
tvurce
Posts: 30
Joined: Saturday 27 October 2018 19:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read actual sensor value using API

Post by tvurce »

Probably need to transform from string to char a than use ArduinoJson.h
tvurce
Posts: 30
Joined: Saturday 27 October 2018 19:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Read actual sensor value using API

Post by tvurce »

Oh god, its so stupid. In JASON API output are values not in number format, but in text with kWh word.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest