Skip to content

Commit

Permalink
Merge 9d7848f into d47fc8b
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminiuga committed Sep 3, 2021
2 parents d47fc8b + 9d7848f commit 2462ad6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
18 changes: 14 additions & 4 deletions tests/test_ota_provider.py
Expand Up @@ -655,7 +655,12 @@ async def test_ledvance_refresh_list(
"identity": {
"company": 4489,
"product": 25,
"version": {"major": 1, "minor": 2, "build": 428},
"version": {
"major": 1,
"minor": 2,
"build": 428,
"revision": 40,
},
},
"releaseNotes": "",
"shA256": sha_1,
Expand All @@ -672,7 +677,12 @@ async def test_ledvance_refresh_list(
"identity": {
"company": 4489,
"product": 13,
"version": {"major": 1, "minor": 2, "build": 428},
"version": {
"major": 1,
"minor": 2,
"build": 428,
"revision": 40,
},
},
"releaseNotes": "",
"shA256": sha_2,
Expand All @@ -699,11 +709,11 @@ async def test_ledvance_refresh_list(
cached_1 = ledvance_prov._cache[img1.key]
assert cached_1.image_type == img1.image_type
base = "https://api.update.ledvance.com/v1/zigbee/firmwares/download"
assert cached_1.url == base + "?Company=4489&Product=25&Version=1.2.428"
assert cached_1.url == base + "?Company=4489&Product=25&Version=1.2.428.40"

cached_2 = ledvance_prov._cache[img2.key]
assert cached_2.image_type == img2.image_type
assert cached_2.url == base + "?Company=4489&Product=13&Version=1.2.428"
assert cached_2.url == base + "?Company=4489&Product=13&Version=1.2.428.40"

assert not ledvance_prov.expired

Expand Down
2 changes: 1 addition & 1 deletion zigpy/__init__.py
@@ -1,6 +1,6 @@
# coding: utf-8
MAJOR_VERSION = 0
MINOR_VERSION = 37
PATCH_VERSION = "1"
PATCH_VERSION = "2"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
22 changes: 15 additions & 7 deletions zigpy/ota/provider.py
Expand Up @@ -7,6 +7,7 @@
import os
import os.path
from typing import Dict, Optional
import urllib.parse

import aiohttp
import attr
Expand Down Expand Up @@ -195,17 +196,24 @@ class LedvanceImage:

@classmethod
def new(cls, data):
ident = data["identity"]
company, product, ver = (ident["company"], ident["product"], ident["version"])
major, minor, build = (ver["major"], ver["minor"], ver["build"])
identity = data["identity"]
ver = identity["version"]

res = cls(company, product)
res = cls(manufacturer_id=identity["company"], image_type=identity["product"])
res.file_version = int(data["fullName"].split("/")[1], 16)
res.image_size = data["length"]

res.url = (
f"https://api.update.ledvance.com/v1/zigbee/firmwares/download"
f"?Company={company}&Product={product}&Version={major}.{minor}.{build}"
"https://api.update.ledvance.com/v1/zigbee/firmwares/download?"
+ urllib.parse.urlencode(
{
"Company": identity["company"],
"Product": identity["product"],
"Version": (
f"{ver['major']}.{ver['minor']}"
f".{ver['build']}.{ver['revision']}"
),
}
)
)

return res
Expand Down

0 comments on commit 2462ad6

Please sign in to comment.