Extraction of equivalent elements from JSON-call's response

Moderator: leecollings

Post Reply
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Extraction of equivalent elements from JSON-call's response

Post by Toulon7559 »

With a json-cal including RID you get a response for that specific device.
With a json-call mentioning type of device you get a selective response over a range of devices.
With /json.htm?type=devices&filter=all&used=true&order=Name
you get a response in one big file which combines the latest information on all devices.

It means that for the latter 2 cases in a response-file you have multiple occurrence of Temp, Humidity or Utility.
Is there an easy&simple way to extract e.g. all Temp-values, all Humidity-values or all Utility-values from such response-file in a such way that you can recognize from which device they originated?
Last edited by Toulon7559 on Sunday 27 November 2016 8:22, edited 1 time in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Extraction of equivalent elements from JSON-call's response

Post by Egregius »

The type and subtype is in the json array.
Or create roomplans to group your devices.
For example: I use a roomplan that holds 60 devices wich are shown on my floorplan. Because I only pull the devices I need the response time and data transfer is only 1/3 compared to all used devices.
Another example: camera with motion detection, that one only needs the status of 3 switches. Why would I pull all?
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Extraction of equivalent elements from JSON-call's response

Post by Toulon7559 »

@Egregius

;-) This is a case in which a solution triggers a next question.
With this thread I created a 'chain' between Domoticz and my website from a 'simple' JSON-call to one RID till display at my website.

;-) But if you can deal with one RID, the challenge comes how to deal with a series of JSON-calls without simply repeating the process at the 'transmitting side'. Such simple repetition could e.g. be a cronjob calling a series of equivalent scripts.
Regardless how you setup such cronjob, there must be more clever ways to make the 'extraction' of a collection of values for application at the website.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Extraction of equivalent elements from JSON-call's response

Post by Egregius »

You're putting the data from domoticz on your webserver to show it there?
Why not pull it directly in your page so you have realtime data?
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Extraction of equivalent elements from JSON-call's response

Post by Toulon7559 »

@ Egregius

The 'pull' you mention is exactly the critical aspect: it requires calling from the internet to my LAN.
I do not want access from the internet to my LAN.
Instead I am looking for a 'pushing' solution, with controlled upload to the webserver.

Perhaps MQTT is the solution, but I have absolutely no experience with that function/application:
;-) a good example may be useful ........
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Extraction of equivalent elements from JSON-call's response

Post by Egregius »

My domoticz isn't available on the internet, only my webserver ;)
Guess it depends on weither you use server side or client side language. Another advantage of PHP then?

To push: Maybe my pass2php can be altered easily.
Basically it encodes the complete LUA tables and posts them to a PHP page.
If you capture them theire to store them in memcached or anything like that you would have realtime data without opening your lan.
Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: mixed
Location: Hengelo(Ov)/NL
Contact:

Re: Extraction of equivalent elements from JSON-call's response

Post by Toulon7559 »

;-) For the upcoming winter-evenings perhaps some time to be spent for study of PHP and MQTT (besides Python-scripts and Javascripts).
Somebody a good hint for literature for Dummies on the subjects PHP and MQTT?
In which 'literature' may also mean an online quick course or instruction.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: Extraction of equivalent elements from JSON-call's response

Post by Egregius »

Google is your best friend.
Everything I did/do in shell,Python,PHP,... I learned from Google.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest