Problem reading JSON value

Begonnen von paj, 21 Dezember 2016, 16:16:23

Vorheriges Thema - Nächstes Thema

paj

I am querying a remote server that returns a json string including the values

{"whereami":"Home"}

My HTTPMOD looks like this


define PAJ_status HTTPMOD https://myurl 15
attr PAJ_status getHeader1 Content-Type: application/json
attr PAJ_status getHeader2 Accept: */*
attr PAJ_status userattr get01JSON get01Name getHeader1 getHeader2 getURL
attr PAJ_status get01Name PAJ_whereami
attr PAJ_status get01JSON whereami


I then want to act on the value of PAJ_whereami using notify


define PAJ_moves_home notify PAJ_status {\
Log 3, "PAJ_status: ".Value("PAJ_status");;\
if (Value("PAJ_status") eq "Home"){\
fhem("set rr_P home");;\
}else{\
fhem("set rr_P absent");;\
}\
}


I can see the reading is correct in PAJ_status :

PAJ_whereami Home 2016-12-21 15:27:32

But the log file for PAJ_status: ".Value("PAJ_status");; is empty and I see the error PAJ_status: Read response to update didn't match any Reading in the log.

UPDATE

I was missing the stateFormat attrib

attr PAJ_status stateFormat {ReadingsVal($name,"PAJ_whereami",0)}

Now it works as I expected.