Skip to content

Commit

Permalink
Update HA manager to support updated Storage API
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Oct 30, 2022
1 parent 0897e4e commit e4a1b7b
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions custom_components/shinobi/component/managers/home_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def load_entities(self):
server_name = f"{self.entry_title} Server"

self._load_original_stream_switch_entity(server_name)
self._load_store_debug_data_switch(server_name)

for monitor_id in self.api.monitors:
monitor = self.api.monitors.get(monitor_id)
Expand Down Expand Up @@ -442,42 +441,6 @@ def _load_original_stream_switch_entity(self, device_name: str):
ex, f"Failed to load switch for Original Stream"
)

def _load_store_debug_data_switch(self, device_name: str):
entity_name = f"{device_name} Store Debug Data"

try:
state = self.storage_api.store_debug_data

attributes = {
ATTR_FRIENDLY_NAME: entity_name
}

unique_id = EntityData.generate_unique_id(DOMAIN_SWITCH, entity_name)

icon = "mdi:file-download"

entity_description = SwitchEntityDescription(
key=unique_id,
name=entity_name,
icon=icon,
entity_category=EntityCategory.CONFIG
)

self.entity_manager.set_entity(DOMAIN_SWITCH,
self.entry_id,
state,
attributes,
device_name,
entity_description)

self.set_action(unique_id, ACTION_CORE_ENTITY_TURN_ON, self._enable_store_debug_data)
self.set_action(unique_id, ACTION_CORE_ENTITY_TURN_OFF, self._disable_store_debug_data)

except Exception as ex:
self.log_exception(
ex, f"Failed to load store debug data switch for {entity_name}"
)

async def _set_monitor_mode(self, entity: EntityData, option: str) -> None:
""" Handles ACTION_CORE_ENTITY_SELECT_OPTION. """
monitor_id = self._get_monitor_id(entity.id)
Expand Down Expand Up @@ -529,12 +492,6 @@ async def _use_default_stream(self, entity: EntityData):

await self._reload_integration()

async def _enable_store_debug_data(self, entity: EntityData):
await self.storage_api.set_store_debug_data(True)

async def _disable_store_debug_data(self, entity: EntityData):
await self.storage_api.set_store_debug_data(False)

def _get_monitor_id(self, unique_id):
entity = self.entity_manager.get(unique_id)
monitor_id = entity.details.get(ATTR_MONITOR_ID)
Expand Down

0 comments on commit e4a1b7b

Please sign in to comment.