diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..f636bac --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Aktuelle Datei", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 40d5e93..1c60c87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,9 @@ FROM python:3-alpine -MAINTAINER Christian - RUN mkdir /otau WORKDIR /usr/src/app COPY ikea.py ./ -CMD [ "python", "./ikea.py" ] \ No newline at end of file +CMD [ "python", "./fw_downloads.py" ] \ No newline at end of file diff --git a/fw_downloads.py b/fw_downloads.py new file mode 100644 index 0000000..f97fa2e --- /dev/null +++ b/fw_downloads.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +""" +Snipped to download current IKEA ZLL OTA files into ~/otau +compatible with python 3. +""" + +import os, json, requests, re, time +try: + from urllib.request import urlopen, urlretrieve +except ImportError: + from urllib2 import urlopen + from urllib import urlretrieve + + +f = urlopen("http://fw.ota.homesmart.ikea.net/feed/version_info.json") +data = f.read() + +arr = json.loads(data) +""" +otapath = '%s/otau' % os.path.expanduser('~') +""" +otapath = '/otau' + +if not os.path.exists(otapath): + os.makedirs(otapath) + +for i in arr: + if 'fw_binary_url' in i: + url = i['fw_binary_url'] + ls = url.split('/') + fname = ls[len(ls) - 1] + path = '%s/%s' % (otapath, fname) + + if not os.path.isfile(path): + urlretrieve(url, path) + print(path) + else: + print('%s already exists' % fname) + + +""" +Snipped to download current OSRAM OTA files into ~/otau +compatible with python 3. +""" + +response = requests.get("https://api.update.ledvance.com/v1/zigbee/products") +response = json.loads(response.content) + +productlist = response['products'] +for x in range(len(productlist)): + time.sleep(35) + company = productlist[x].get('id').get('company') + product = productlist[x].get('id').get('product') + url = 'https://api.update.ledvance.com/v1/zigbee/firmwares/download/%s/%s/latest' % (company, product) + response = requests.get(url) + firmwarecontent = response.content + fname = response.headers['Content-Disposition'] + fname = re.findall("filename=(.+)", fname)[0] + fname = fname.split(";") + fname = fname[0] + + path = '%s/%s' % (otapath, fname) + + if not os.path.isfile(path): + file = open(path, "wb") + file.write(firmwarecontent) + file.close() + print(path) + else: + print('%s already exists' % fname) diff --git a/ligthify.py b/ligthify.py new file mode 100644 index 0000000..6d6ed58 --- /dev/null +++ b/ligthify.py @@ -0,0 +1,36 @@ +import requests +import json +import re +import time +import os + +otapath = '/otau' + +if not os.path.exists(otapath): + os.makedirs(otapath) + +response = requests.get("https://api.update.ledvance.com/v1/zigbee/products") +response = json.loads(response.content) + +productlist = response['products'] +for x in range(len(productlist)): + time.sleep(35) + company = productlist[x].get('id').get('company') + product = productlist[x].get('id').get('product') + url = 'https://api.update.ledvance.com/v1/zigbee/firmwares/download/%s/%s/latest' % (company, product) + response = requests.get(url) + firmwarecontent = response.content + fname = response.headers['Content-Disposition'] + fname = re.findall("filename=(.+)", fname)[0] + fname = fname.split(";") + fname = fname[0] + + path = '%s/%s' % (otapath, fname) + + if not os.path.isfile(path): + file = open(path, "wb") + file.write(firmwarecontent) + file.close() + print(path) + else: + print('%s already exists' % fname) \ No newline at end of file