- Get an API key from from https://api.nasa.gov
- Download roverpics.sh, fill in the API key.
- Run the script once to download the latest pictures.
- Schedule the script to run via cron (or any utility that can run scripts on schedule).
- Install the Homebridge Camera FFmpeg plugin on Homebridge
- Add configuration to stream the latest photos (see config.json)
Last active
May 3, 2023 22:52
-
-
Save supermamon/846c1ab94e96434263459fbab0ac9a48 to your computer and use it in GitHub Desktop.
Mars Rover Camera for Homebridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"platforms": [ | |
{ | |
"platform": "Camera-ffmpeg", | |
"name": "Camera FFmpeg", | |
"cameras": [ | |
{ | |
"name": "Curiosity NAVCAM", | |
"videoConfig": { | |
"source": "-f image2 -loop 1 -s 720x480 -pix_fmt yuvj422p -i /homebridge/cams/curiosity-NAVCAM-curr.jpg" | |
} | |
}, | |
{ | |
"name": "Curiosity FHAZ", | |
"videoConfig": { | |
"source": "-f image2 -loop 1 -s 720x480 -pix_fmt yuvj422p -i /homebridge/cams/curiosity-FHAZ-curr.jpg" | |
} | |
}, | |
{ | |
"name": "Curiosity RHAZ", | |
"videoConfig": { | |
"source": "-f image2 -loop 1 -s 720x480 -pix_fmt yuvj422p -i /homebridge/cams/curiosity-RHAZ-curr.jpg" | |
} | |
} | |
] | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# get your API key from https://api.nasa.gov | |
API_KEY=nasa-api-key | |
ROVER=curiosity | |
sol=$(curl -s "https://api.nasa.gov/mars-photos/api/v1/manifests/$ROVER?api_key=$API_KEY" | jq -r '.photo_manifest.max_sol') | |
function download_rover_pic() { | |
rover=$1 | |
sol=$2 | |
cam=$3 | |
dir=$4 | |
data=$(curl -s "https://api.nasa.gov/mars-photos/api/v1/rovers/$rover/photos?sol=$sol&api_key=$API_KEY&camera=$cam") | |
pic_curr=$(echo $data | jq -r '.photos[-1].img_src') | |
curl -s $pic_curr -o "$dir/$rover-$cam-curr.jpg" | |
} | |
download_rover_pic $ROVER $sol NAVCAM /homebridge/cams | |
download_rover_pic $ROVER $sol FHAZ /homebridge/cams | |
download_rover_pic $ROVER $sol RHAZ /homebridge/cams | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment