def __init__( self, client: "Client", state: dict, log_config: LogConfigDataType ) -> None: """Initialize driver.""" super().__init__() self.client = client self.controller = Controller(client, state) self.log_config = LogConfig.from_dict(log_config)
async def websocket_update_log_config(hass: HomeAssistant, connection: ActiveConnection, msg: dict) -> None: """Update the driver log config.""" entry_id = msg[ENTRY_ID] client = hass.data[DOMAIN][entry_id][DATA_CLIENT] await client.driver.async_update_log_config(LogConfig(**msg[CONFIG])) connection.send_result(msg[ID], )
async def websocket_update_log_config( hass: HomeAssistant, connection: ActiveConnection, msg: dict, entry: ConfigEntry, client: Client, ) -> None: """Update the driver log config.""" await client.driver.async_update_log_config(LogConfig(**msg[CONFIG])) connection.send_result(msg[ID], )
async def async_get_log_config(self) -> LogConfig: """Return current log config for driver.""" result = await self.client.async_send_command( {"command": "get_log_config"}) return LogConfig.from_dict(result["config"])
async def async_update_log_config(self, log_config: LogConfig) -> None: """Update log config for driver.""" await self.client.async_send_command({ "command": "update_log_config", "config": log_config.to_dict(), })
async def async_get_log_config(self) -> LogConfig: """Return current log config for driver.""" result = await self._async_send_command("get_log_config", require_schema=4) return LogConfig.from_dict(result["config"])
async def async_update_log_config(self, log_config: LogConfig) -> None: """Update log config for driver.""" await self._async_send_command( "update_log_config", config=log_config.to_dict(), require_schema=4 )
def handle_log_config_updated(self, event: Event) -> None: """Process a driver log config updated event.""" event.data["log_config"] = self.log_config = LogConfig.from_dict( event.data["config"] )