From 400a8e9833367eb1778dfc317d9095222382e27a Mon Sep 17 00:00:00 2001 From: Aaron Shaw Date: Mon, 26 Jun 2023 21:49:46 +0100 Subject: [PATCH 1/2] feat: add check for nebra fleets add check for nebra fleets --- hm_pyhelper/sbc.py | 83 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-) diff --git a/hm_pyhelper/sbc.py b/hm_pyhelper/sbc.py index fe3d4cc..6186bba 100644 --- a/hm_pyhelper/sbc.py +++ b/hm_pyhelper/sbc.py @@ -42,9 +42,9 @@ class DeviceVendorID(Enum): } COMMERCIAL_FLEETS = [ - 156, # Bobcat + 156, # Bobcat PX30 56, # Controllino - 106, # COTX, + 106, # COTX 53, # Finestra 31, # Nebra Indoor 868MHz 40, # Nebra Indoor RockPi 868MHz @@ -69,9 +69,9 @@ class DeviceVendorID(Enum): 90, # Syncrobit 126, # Syncrobit RKCM3 98, # Nebra Indoor Testing - 158, # Bobcat Testing + 158, # Bobcat PX30 Testing 127, # Controllino Testing - 87, # COTX Testing, + 87, # COTX Testing 76, # Finestra Testing 132, # Linxdot Testing 84, # Linxdot RKCM3 Testing @@ -90,6 +90,67 @@ class DeviceVendorID(Enum): 2061340, # Rob Testing ] +NON_COMMERCIAL_FLEETS = [ + 67, # dev-1 + 54, # dev-2 + 74, # dev-3 + 25, # devnet-01 + 26, # devnet-02 + 150, # devnet-03 + 153, # dev-sensorhub + 121, # Bobcat PX30 + 105, # Controllino + 136, # COTX + 99, # Disputed + 118, # Finestra + 109, # Indoor 470 + 39, # Indoor 868 + 134, # Indoor 868 RockPi + 91, # Indoor 915 + 122, # Indoor 915 RockPi + 46, # Linxdot + 68, # Linxdot RKCM3 + 138, # Midas + 3, # Indoor1 + 27, # Indoor2 + 28, # Outdoor1 + 29, # Outdoor2 + 104, # OG + 79, # Outdoor 470 + 63, # Outdoor 868 + 133, # Outdoor 915 + 94, # Outdoor 915 RockPi + 32, # Panther X1 + 71, # Pisces + 83, # Pycom + 78, # RAK + 85, # RisingHF + 101, # Sensecap + 130, # Syncrobit + 69, # Syncrobit RKCM3 + 123, # Testnet + 157, # Bobcat PX30 Testnet + 102, # Controllino Testnet + 86, # COTX Testnet + 77, # Finestra Testnet + 117, # Linxdot Testnet + 110, # Linxdot RKCM3 Testnet + 139, # Midas Testnet + 70, # OG Testnet + 129, # Panther X1 Testnet + 125, # Pisces Testnet + 131, # Pycom Testnet + 36, # RAK Testnet + 55, # Rising HF Testnet + 95, # RockPi Testnet + 75, # Sensecap Testnet + 97, # Syncrobit Testnet + 37, # Syncrobit RKCM3 Testnet + 22, # Indoor2 Testnet +] + +NEBRA_API_URL = "https://api.cloud.nebra.com" + def device_model(): with open('/proc/device-tree/model', 'r') as f: return f.readline().strip() @@ -136,5 +197,17 @@ def is_commercial_fleet() -> bool: if not fleet_name.endswith('-c') or fleet_id not in COMMERCIAL_FLEETS: return False + return True + + +def is_nebra_fleet() -> bool: + ''' + Return true if the device is in a Nebra Cloud fleet. Otherwise return false. + ''' + api_url = os.environ.get('BALENA_API_URL') + fleet_id = int(os.environ.get('BALENA_APP_ID')) + + if api_url is not NEBRA_API_URL or fleet_id not in COMMERCIAL_FLEETS or fleet_id not in NON_COMMERCIAL_FLEETS: + return False + return True - From 7a48f785e2d7d45e5b0e2b1573fe14f4c9b97f2b Mon Sep 17 00:00:00 2001 From: Aaron Shaw Date: Mon, 26 Jun 2023 21:50:20 +0100 Subject: [PATCH 2/2] Bump version Bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index facad80..dd36dfb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "hm_pyhelper" -version = "0.14.16" +version = "0.14.17" description = "Helium Python Helper" authors = ["Nebra Ltd "] readme = "README.md"