Files
addons/deconz/data/ledvance-otau-dl.sh
olijouve 6847f767cd deconz: Add LEDVANCE / OSRAM otau firmware downloader (#983)
* Update config.json

* Create ledvance-otau-dl.sh

* Update run.sh

* Update Dockerfile

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update ledvance-otau-dl.sh

Fix lint issues:
  https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word splitt...
  https://www.shellcheck.net/wiki/SC2003 -- expr is antiquated. Consider rewr...

* Update ledvance-otau-dl.sh

Fix lint issue:
  https://www.shellcheck.net/wiki/SC2004 -- $/${} is unnecessary on arithmeti...

* Update Dockerfile

Adressing @pvizeli comment : The script have the correct permission of a+x?

Add CMD to set a+x permission on ledvance-otau-dl.sh script

* Update Dockerfile

* Add exec permissions

* revert oups bad multiple cmdlines in CMD[]

* revert oups bad multiple cmdlines in CMD[]

* dummy commit

* Update Dockerfile

remove dummy comment

* Update ledvance-otau-dl.sh

remove dummy comment

* fix bug

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
2020-01-11 13:26:36 +01:00

43 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
URL_OSRAM="https://api.update.ledvance.com/v1/zigbee/firmwares"
while true
do
# fetch data
if ! OSRAM_DATA="$(curl -sL ${URL_OSRAM})"; then
echo "[Info] Can't fetch data from osram!"
sleep 18000
continue
fi
OSRAM_DATA_SIZE="$(echo "${OSRAM_DATA}" | jq --raw-output '.firmwares | length')"
DL_DONE=0
for (( i=0; i < "${OSRAM_DATA_SIZE}"; i++ )); do
OSRAM_COMPANY=$( echo "${OSRAM_DATA}" | jq --raw-output ".firmwares[$i].identity.company // empty" 2>/dev/null)
OSRAM_PRODUCT=$( echo "${OSRAM_DATA}" | jq --raw-output ".firmwares[$i].identity.product // empty" 2>/dev/null)
OTAU_FILENAME=$( echo "${OSRAM_DATA}" | jq --raw-output ".firmwares[$i].name // empty" 2>/dev/null)
OTAU_URL="$URL_OSRAM/download/${OSRAM_COMPANY}/${OSRAM_PRODUCT}/latest"
if [ -z "${OTAU_URL}" ]; then
continue
fi
OTAU_FILE="/data/otau/${OTAU_FILENAME}"
if [ -f "${OTAU_FILE}" ] && [[ $(file --mime-type -b "${OTAU_FILE}") == "application/octet-stream" ]] ; then
continue
fi
curl -s -L -o "${OTAU_FILE}" "${OTAU_URL}"
((DL_DONE++))
if [ "$((DL_DONE % 10))" == "0" ]; then
# LEDVANCE/OSRAM API RateLimits : The rate limit 10 calls per 60 seconds or quota 100 MB per month.
DL_DONE=0
sleep 65
fi
done
sleep 259200
done