Skip to content

Commit

Permalink
Fix missing switch for monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Oct 30, 2022
1 parent 75959b2 commit 5c380a6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.0.17

- Fix missing switch for monitoring
- Non admin user INFO message that prevents interface switch to turn on / off will be logged once

## 2.0.16

- Add interface line connected binary sensor
Expand Down
12 changes: 6 additions & 6 deletions custom_components/edgeos/component/managers/home_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, hass: HomeAssistant):
self._interfaces: dict[str, EdgeOSInterfaceData] = {}
self._unknown_devices: int | None = None
self._can_load_components: bool = False
self._user_level_warning_logged: bool = False

@property
def hass(self) -> HomeAssistant:
Expand Down Expand Up @@ -184,7 +185,6 @@ async def async_initialize_data_providers(self):

async def async_stop_data_providers(self):
await self.api.terminate()
await self.ws.terminate()

async def async_update_data_providers(self):
try:
Expand Down Expand Up @@ -246,15 +246,13 @@ def load_entities(self):
for unique_id in self._interfaces:
interface_item = self._interfaces.get(unique_id)

if not interface_item.is_special:
self._load_interface_monitor_switch(interface_item)

if self._system.user_level == USER_LEVEL_ADMIN:
if self._system.user_level == USER_LEVEL_ADMIN and not interface_item.is_special:
self._load_interface_status_switch(interface_item)

else:
self._load_interface_status_binary_sensor(interface_item)

self._load_interface_monitor_switch(interface_item)
self._load_interface_connected_binary_sensor(interface_item)

self._load_interface_received_rate_sensor(interface_item)
Expand Down Expand Up @@ -424,7 +422,9 @@ def _extract_system(self, data: dict, system_info: dict):

self._system = system_data

if system_data.user_level != USER_LEVEL_ADMIN:
if system_data.user_level != USER_LEVEL_ADMIN and not self._user_level_warning_logged:
self._user_level_warning_logged = False

_LOGGER.info(
f"User {self.config_data.username} level is {self._system.user_level}, "
f"Interface status switch will not be created as it requires admin role"
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 @@ -7,6 +7,6 @@
"codeowners": ["@elad-bar"],
"requirements": ["aiohttp"],
"config_flow": true,
"version": "2.0.16",
"version": "2.0.17",
"iot_class": "local_polling"
}

0 comments on commit 5c380a6

Please sign in to comment.