Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello,
i am trying to get the data from my PIR motion sensor to the remote PiThing i created in the Quickstart guide.
i added this code in the PiTemplate.lua
properties.PIR = { baseType="NUMBER", pushType="ALWAYS", value=0 }
local sensorCmd = io.popen("python etc/custom/templates/11.py")
s = sensorCmd:read("*a") properties.PIR.value = s
and i tried with 2 types (with and without a loop) of python code (the code works fine if i am trying it from terminal only in the raspberry Pi, does not work in TW) that i attached.
the other sensors as in the guide work just fine, only with this one i am not getting any data, event though the remote thing sees it as a property
can anyone please help?
Solved! Go to Solution.
Managed to solve this. Apparently i was not sending anything to Lua because my Python script was composed of a void function that did not have a return statement. so i made a function that returns true when the movement is made.
What is the value 's' after you read it in? Are you seeing any errors? I would also try using a property with a STRING type since you may be getting a null character, or carriage return, or EOF put into that variable
thanks for the replay! i set the type as string but did not see any difference. no, i do not see errors and looks like 's' is having 0 as value, it sends 0 to Thingworx
does anybody know how to make this work please?
Managed to solve this. Apparently i was not sending anything to Lua because my Python script was composed of a void function that did not have a return statement. so i made a function that returns true when the movement is made.