{"time": "2019-08-04 10:44:53", "CPM": "19", "ACPM": "18.22", "uSv": "0.12"}
The AppleScript I've been using is:
- Code: Select all
tell application "IndigoServer"
--retrieve from GMC Map
set TheCommand to "curl -m 5 --request GET http://www.gmcmap.com/historyData-plain.asp?Param_ID=68108722812"
try
set myResult to do shell script TheCommand
--extract Geiger reading
set AppleScript's text item delimiters to ","
set theArray to every text item of myResult
set radLevelText to item 2 of theArray
-- extract value from text string
set radLevel to word 2 of radLevelText
set value of variable "Radiation_Basement" to radLevel
on error
log "Error executing curl to retrieve from gmcmap.com"
end try
end tell
Based on examples in the Indigo forums, I tried this Python code:
- Code: Select all
import requests
import simplejson
# output from gmcmap.com looks like this:
# {"time": "2019-08-04 10:44:53", "CPM": "19", "ACPM": "18.22", "uSv": "0.12"}
result = requests.get("http://www.gmcmap.com/historyData-plain.asp?Param_ID=68108722812")
response = simplejson.loads(result)
indigo.variable.updateValue(385534937, response["CPM"])
But I get this error:
Script Error GMC Map.py: expected string or buffer
Script Error Exception Traceback (most recent call shown last):
GMC Map.py, line 8, at top level
File "/Library/Application Support/Perceptive Automation/Indigo 7.3/IndigoPluginHost.app/Contents/Resources/PlugIns/simplejson/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/Library/Application Support/Perceptive Automation/Indigo 7.3/IndigoPluginHost.app/Contents/Resources/PlugIns/simplejson/decoder.py", line 335, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
I'm not sure what to do now. Thanks for your help. It is greatly appreciated!