I have been searching for a solution for my question but didn't find a or better said I did not get it with what I found.
My problem is:
I am using a Smart Home Control Software on a Raspberry Pi.
Using pilight-receive,
I can capture the data from my outdoor temperature sensor.
The output of pilight-receive looks like that:
{
"message": {
"id": 4095,
"temperature": 409.5
},
"origin": "receiver",
"protocol": "alecto_wsd17",
"uuid": "0000-b8-27-eb-0f3db7",
"repeats": 3
}
{
"message": {
"id": 1490,
"temperature": 25.1,
"humidity": 40.0,
"battery": 1
},
"origin": "receiver",
"protocol": "alecto_ws1700",
"uuid": "0000-b8-27-eb-0f3db7",
"repeats": 3
}
{
"message": {
"id": 2039,
"temperature": 409.5
},
"origin": "receiver",
"protocol": "alecto_wsd17",
"uuid": "0000-b8-27-eb-0f3db7",
"repeats": 4
}
Now my question is:
How the can I extract the temperature and humidity from messages where the id is 1490?
And how would you recommend me to do check this frequently?
By a cron job that runs every 10 minutes, creates an output of the pilight-receive,
extracts the data of the output and pushes it to the Smart Home Control API?
awkandsedprovided the JSON output retains the formatting shown here, which it need not - whitespace doesn't matter for JSON. For example, thisawkcommand:awk '/temperature|humidity/ {print $2}'is close.ksh93json parsing is builtin toread.