Here ya go, thanks for looking at this. Please bear in mind, I’m stumbling along in the dark as far as coding.
I’ve changed the IP address for this paste.
When I place the variable into the OS command, the code does nothing. If I replace the variable with the actual number (as I’ve done in the pasted code), it works fine.
code follows:
– 11/5/19
– 11/5 put timeout feature into os.command structure
– New Check Shade
– gets position of shade, moves shade, compares position
– if position is the same, then shade didn’t move, and needs to be re-calibrated.
– At the end of the scene return shade to closed position
local shadeid = 42654
local timeout = 5
local status, result0 = luup.inet.wget(“http://xxx.xxx.xxx.xxx/api/shades/” … shadeid, timeout)
– gets original status (result0)
– print (result0)
os.execute(“curl -s -X PUT -H ‘Content-Type: application/json’ -m 5 -d ‘{"shade":{"id":42654,"positions":{"position1":7943,"posKind1":1}}}’ http://xxx.xxx.xxx.xxx/api/shades/42654”)
– moves shade to position 7943
– waits 5 seconds
local status, result1 = luup.inet.wget("http://xxx.xxx.xxx.xxx/api/shades/" .. shadeid, timeout)
– get updated status (result1)
– print (result1)
if (result1 == result0)
then
– shade did not move, run calibration
os.execute(“curl -s -X PUT -H ‘Content-Type: application/json’ -m 5 -d ‘{"shade":{"motion":"calibrate"}}’ http://xxx.xxx.xxx.xxx/api/shades/42654”)
end
– return shade counter to zero (closed position)
os.execute(“curl -s -X PUT -H ‘Content-Type: application/json’ -m 5 -d ‘{"shade":{"id":42654,"positions":{"position1":0,"posKind1":1}}}’ http://xxx.xxx.xxx.xxx/api/shades/42654”)