Skip to content

Commit

Permalink
Removed support for firmware v1
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Aug 23, 2021
1 parent 503ee70 commit d73c88f
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ log.txt

venv/

test_consts.py
local_consts.py
edgeos.key
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v1.1.4
- Prevent the component to get installed or run with EdgeOS Firmware v1

## v1.1.3

- Fixed monitored_devices appear as disconnected [\#32](https://github.com/elad-bar/ha-edgeos/pull/32) by [@shlomki](https://github.com/shlomki)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Provides an integration between EdgeOS (Ubiquiti) routers to Home Assistant.
Look for "Integration with EdgeOS (Ubiquiti)" and install

#### Requirements
* EdgeRouter with version 1.10 at least
* EdgeRouter with at least firmware version 2.0
* EdgeRouter User with 'Operator' level access or higher
* Traffic Analysis set to 'Enabled' (both `dpi` and `export` enabled under `system/traffic-analysis`)

Expand All @@ -35,7 +35,7 @@ General authentication error (when failed to get valid response from device) |
Could not retrieve device data from EdgeOS Router |
Export (traffic-analysis) configuration is disabled, please enable |
Deep Packet Inspection (traffic-analysis) configuration is disabled, please enable |
Incompatible version (Required at least v1.10)
Unsupported firmware version|

###### Encryption key got corrupted
If a persistent notification popped up with the following message:
Expand Down
2 changes: 1 addition & 1 deletion __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from custom_components.edgeos.managers.version_check import VersionCheck
from custom_components.edgeos.models.config_data import ConfigData
from homeassistant.core import HomeAssistant
from test_consts import *
from local_consts import *

logging.basicConfig(filename="log.txt", filemode="a", level="DEBUG")

Expand Down
1 change: 1 addition & 0 deletions custom_components/edgeos/helpers/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
SERVICE_LOG_EVENTS_SCHEMA = vol.Schema({vol.Required(ATTR_ENABLED): cv.boolean})

HTTP_ERRORS = {
400: "incompatible_version",
404: "not_found",
403: "invalid_credentials",
500: "incompatible_version",
Expand Down
13 changes: 13 additions & 0 deletions custom_components/edgeos/managers/config_flow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,19 @@ async def _valid_login(self):
)
errors = {"base": "invalid_export_configuration"}

system_info_data = await api.get_general_data(SYS_INFO_KEY)

if system_info_data is not None:
firmware_version = system_info_data.get("fw-latest", {})
version = firmware_version.get("version")

if version[:2] == "v1":
_LOGGER.error(
f"Unsupported firmware version ({version})"
)

errors = {"base": "incompatible_version"}

else:
_LOGGER.warning(f"Failed to login {name}")

Expand Down
18 changes: 15 additions & 3 deletions custom_components/edgeos/managers/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ async def _initialize(self, post_login_action=None):
cookies = self._api.cookies_data
session_id = self._api.session_id

_LOGGER.debug(f"Initializing WS using session: {session_id}")
await self._ws.initialize(cookies, session_id)
if self.version[:2] == "v1":
_LOGGER.error(
f"Unsupported firmware version ({self.version})"
)

await self.terminate()

else:
_LOGGER.debug(f"Initializing WS using session: {session_id}")
await self._ws.initialize(cookies, session_id)

except SessionTerminatedException as stex:
_LOGGER.info(f"Session terminated ({stex})")

Expand Down Expand Up @@ -364,8 +373,11 @@ def load_system_data(self, devices_data, system_info_data):
return

system_data = devices_data.get("system", {})
firmware_version = system_info_data.get("fw-latest", {})
version = firmware_version.get("version")

self.hostname = system_data.get("host-name", self.hostname)
self.version = system_info_data.get("sw_ver", "N/A")
self.version = version

def handle_interfaces(self, data):
try:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/edgeos/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"codeowners": ["@elad-bar"],
"requirements": ["aiohttp"],
"config_flow": true,
"version": "1.1.3",
"version": "1.1.4",
"iot_class": "local_polling"
}
4 changes: 2 additions & 2 deletions custom_components/edgeos/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"invalid_dpi_configuration": "Deep Packet Inspection (traffic-analysis) configuration is disabled, please enable",
"empty_device_data": "Could not retrieve device data from EdgeOS Router",
"already_configured": "EdgeOS integration already configured with the name",
"incompatible_version": "Incompatible version (Required at least v1.10)"
"incompatible_version": "Unsupported firmware version"
}
},
"options": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"invalid_dpi_configuration": "Deep Packet Inspection (traffic-analysis) configuration is disabled, please enable",
"empty_device_data": "Could not retrieve device data from EdgeOS Router",
"already_configured": "EdgeOS integration already configured with the name",
"incompatible_version": "Incompatible version (Required at least v1.10)"
"incompatible_version": "Unsupported firmware version"
}
}
}
4 changes: 2 additions & 2 deletions custom_components/edgeos/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"invalid_dpi_configuration": "Deep Packet Inspection (traffic-analysis) configuration is disabled, please enable",
"empty_device_data": "Could not retrieve device data from EdgeOS Router",
"already_configured": "EdgeOS integration already configured with the name",
"incompatible_version": "Incompatible version (Required at least v1.10)"
"incompatible_version": "Unsupported firmware version"
}
},
"options": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"invalid_dpi_configuration": "Deep Packet Inspection (traffic-analysis) configuration is disabled, please enable",
"empty_device_data": "Could not retrieve device data from EdgeOS Router",
"already_configured": "EdgeOS integration already configured with the name",
"incompatible_version": "Incompatible version (Required at least v1.10)"
"incompatible_version": "Unsupported firmware version"
}
}
}
4 changes: 2 additions & 2 deletions custom_components/edgeos/translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"invalid_dpi_configuration": "Konfigurasjon av dyp pakkeinspeksjon (trafikkanalyse) er deaktivert, vennligst aktiver",
"empty_device_data": "Kunne ikke hente enhetsdata fra EdgeOS Router",
"already_configured": "EdgeOS-integrasjon allerede konfigurert med navnet",
"incompatible_version": "Inkompatibel versjon (påkrevd minst v1.10)"
"incompatible_version": "Inkompatibel versjon (påkrevd minst v2.0)"
}
},
"options": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"invalid_dpi_configuration": "Konfigurasjon av dyp pakkeinspeksjon (trafikkanalyse) er deaktivert, vennligst aktiver",
"empty_device_data": "Kunne ikke hente enhetsdata fra EdgeOS Router",
"already_configured": "EdgeOS-integrasjon allerede konfigurert med navnet",
"incompatible_version": "Inkompatibel versjon (påkrevd minst v1.10)"
"incompatible_version": "Inkompatibel versjon (påkrevd minst v2.0)"
}
}
}
4 changes: 2 additions & 2 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Provides an integration between EdgeOS (Ubiquiti) routers to Home Assistant.
Look for "Integration with EdgeOS (Ubiquiti)" and install

#### Requirements
* EdgeRouter with version 1.10 at least
* EdgeRouter with at least firmware version 2.0
* EdgeRouter User with 'Operator' level access or higher
* Traffic Analysis set to 'Enabled' (both `dpi` and `export` enabled under `system/traffic-analysis`)

Expand All @@ -35,7 +35,7 @@ General authentication error (when failed to get valid response from device) |
Could not retrieve device data from EdgeOS Router |
Export (traffic-analysis) configuration is disabled, please enable |
Deep Packet Inspection (traffic-analysis) configuration is disabled, please enable |
Incompatible version (Required at least v1.10)
Unsupported firmware version|

###### Encryption key got corrupted
If a persistent notification popped up with the following message:
Expand Down

0 comments on commit d73c88f

Please sign in to comment.