Now that the live image availability data is published as an MQTT topic that can be subscribed to, here's a script that combined this data with the ISS position:
# http://open-notify.org/Open-Notify-API/ISS-Location-Now/
import urllib2
import json
import paho.mqtt.client as mqtt
import time
def on_message(client, userdata, message):
try:
available = message.payload
req = urllib2.Request("http://api.open-notify.org/iss-now.json")
response = urllib2.urlopen(req)
obj = json.loads(response.read())
timestamp = obj['timestamp']
lat = obj['iss_position']['latitude']
lon = obj['iss_position']['longitude']
print("{},{},{},{}".format(timestamp,lat,lon,available))
except URLError:
pass
client = mqtt.Client("issclient")
client.on_message = on_message
client.connect("test.mosquitto.org", 1883)
client.subscribe("iss-hdev-availability/available-bool")
client.loop_start()
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
break
client.loop_stop()
I've got a modified version of this running which will will self-terminate after 24 hours, to draw an availability map.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.