mirror of
https://github.com/danieldemus/deconz_fw_downloader.git
synced 2025-01-10 07:02:03 +01:00
Include Osram ligthify fw downloads
This commit is contained in:
parent
0dfba9d413
commit
a598b7cebe
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
FROM python:3-alpine
|
||||
|
||||
MAINTAINER Christian
|
||||
|
||||
RUN mkdir /otau
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY ikea.py ./
|
||||
|
||||
CMD [ "python", "./ikea.py" ]
|
||||
CMD [ "python", "./fw_downloads.py" ]
|
70
fw_downloads.py
Normal file
70
fw_downloads.py
Normal file
@ -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)
|
36
ligthify.py
Normal file
36
ligthify.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user