"Alarm" for values

Hi,
A good way to start is to run the following command from a terminal, for example “cmd”:

curl http://<sensor IP address>/data.json > sensordata.txt

You will then get a data file that looks like this (depending on the type of your sensor):

{"software_version": "NRZ-2020-133", "age":"118",
"sensordatavalues":[
{"value_type":"SDS_P1","value":"17.35"},
{"value_type":"SDS_P2","value":"9.60"},
{"value_type":"BME280_temperature","value":"7.12"},
{"value_type":"BME280_pressure","value":"103936.44"},
{"value_type":"BME280_humidity","value":"62.25"},
{"value_type":"samples","value":"5060693"},
{"value_type":"min_micro","value":"28"},
{"value_type":"max_micro","value":"20128"},
{"value_type":"interval","value":"145000"},
{"value_type":"signal","value":"-40"}
]}

This is a good start to understand the data structure of the sensor’s output. You also need this to know how the JSON file is received by Home Assistant (if you want to integrate your sensor into this domotic environment) and which data is contained in which item.
I have two different air quality sensors and they both have a different data structure for the JSON file.

In Home Assistant you can create a sensor template that organizes the collection of data for you. For those who are familiar with Home Assistant. That template looks like this:

- platform: command_line
   name: "Air Quality Aside PM10 (SDS)"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[0].value | round(1) }}"
   unit_of_measurement: "µg/m³"
- platform: command_line
   name: "Air Quality Aside PM2.5 (SDS)"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[1].value | round(1) }}"
   unit_of_measurement: "µg/m³"

- platform: command_line
   name: "Air Temperature Aside (BME280)"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[2].value | round(1) }}"
   unit_of_measurement: "°C"
- platform: command_line
   name: "Air Pressure Aside (BME280)"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[3].value | round(1) }}"
   unit_of_measurement: "Pa"
- platform: command_line
   name: "Humidity Aside (BME280)"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[4].value | round(1) }}"
   unit_of_measurement: "%"

- platform: command_line
   name: "Air Quality Aside Samples"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[5].value | round(1) }}"
   unit_of_measurement: ""
- platform: command_line
   name: "Air Quality Aside Min_Micro"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[6].value | round(1) }}"
   unit_of_measurement: ""
- platform: command_line
   name: "Air Quality Aside Max_Micro"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[7].value | round(1) }}"
   unit_of_measurement: ""
- platform: command_line
   name: "Air Quality Aside Interval"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[8].value | round(1) }}"
   unit_of_measurement: ""
- platform: command_line
   name: "Air Quality Aside WiFi Signal Strength"
   command: 'curl http://192.168.178.20/data.json'
   value_template: "{{ value_json.sensordatavalues[9].value | round(1) }}"
   unit_of_measurement: "dBm"

I find the numbering …sensordatavalues[9]… etc. a weak part of this solution.
You would rather have something like …sensordatavalues[“signal”]… etc.
I’m still looking for that.

This was assuming that you are using an environment like Home Assistant. You could also make something yourself in Python to decode the JSON file and send a message based on that. But if you like this kind of automation, Home Assistant is well worth considering.

The sensor is still sending its data to the Sensor Community site, so the data is still available there for research.

Currently I have some issues with one of my sensors. There is a posting about that on this forum as well.

2 Likes