Skip to content

Commit

Permalink
Merge pull request #149 from elad-bar/fix-update-interface-action
Browse files Browse the repository at this point in the history
fix update interface state
  • Loading branch information
elad-bar authored May 14, 2024
2 parents a31e5b8 + e8d8ef3 commit 2de043b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.6

- Fix update interface state [#145](https://github.com/elad-bar/ha-edgeos/issues/145)

## 2.1.5

- Handling undefined interface types [#137](https://github.com/elad-bar/ha-edgeos/issues/137)
Expand Down
8 changes: 4 additions & 4 deletions custom_components/edgeos/managers/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ def _get_post_headers(self):

return headers

async def _async_post(self, endpoint, data):
async def _async_post(self, endpoint, data, action: str | None = None):
result = None

try:
url = self._build_endpoint(endpoint)
url = self._build_endpoint(endpoint, action=action)

if self._session is not None:
headers = self._get_post_headers()
Expand Down Expand Up @@ -506,15 +506,15 @@ async def set_interface_state(
_LOGGER.info(f"Set state of interface {interface.name} to {is_enabled}")

modified = False
endpoint = API_DELETE if is_enabled else API_SET
action = API_DELETE if is_enabled else API_SET

data = {
API_DATA_INTERFACES: {
interface.interface_type: {interface.name: {SYSTEM_DATA_DISABLE: None}}
}
}

result_json = await self._async_post(endpoint, data)
result_json = await self._async_post(API_URL_DATA, data, action=action)

if result_json is not None:
set_response = result_json.get(API_DATA_SAVE.upper(), {})
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 @@ -8,5 +8,5 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/elad-bar/ha-edgeos/issues",
"requirements": ["aiohttp"],
"version": "2.1.5"
"version": "2.1.6"
}

0 comments on commit 2de043b

Please sign in to comment.