mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 15:26:36 +00:00
Trigger a scan of USB devices when loading integrations (#9860)
This commit is contained in:
parent
af9199aaff
commit
e08f691510
4
src/data/usb.ts
Normal file
4
src/data/usb.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import { HomeAssistant } from "../types";
|
||||
|
||||
export const scanUSBDevices = (hass: HomeAssistant) =>
|
||||
hass.callWS({ type: "usb/scan" });
|
@ -10,6 +10,7 @@ import {
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
import { compare } from "../common/string/compare";
|
||||
import { isComponentLoaded } from "../common/config/is_component_loaded";
|
||||
import { LocalizeFunc } from "../common/translations/localize";
|
||||
import { ConfigEntry, getConfigEntries } from "../data/config_entries";
|
||||
import {
|
||||
@ -19,6 +20,7 @@ import {
|
||||
} from "../data/config_flow";
|
||||
import { DataEntryFlowProgress } from "../data/data_entry_flow";
|
||||
import { domainToName } from "../data/integration";
|
||||
import { scanUSBDevices } from "../data/usb";
|
||||
import {
|
||||
loadConfigFlowDialog,
|
||||
showConfigFlowDialog,
|
||||
@ -134,6 +136,7 @@ class OnboardingIntegrations extends LitElement {
|
||||
|
||||
protected firstUpdated(changedProps: PropertyValues) {
|
||||
super.firstUpdated(changedProps);
|
||||
this._scanUSBDevices();
|
||||
loadConfigFlowDialog();
|
||||
this._loadConfigEntries();
|
||||
/* polyfill for paper-dropdown */
|
||||
@ -159,6 +162,13 @@ class OnboardingIntegrations extends LitElement {
|
||||
});
|
||||
}
|
||||
|
||||
private async _scanUSBDevices() {
|
||||
if (!isComponentLoaded(this.hass, "usb")) {
|
||||
return;
|
||||
}
|
||||
await scanUSBDevices(this.hass);
|
||||
}
|
||||
|
||||
private async _loadConfigEntries() {
|
||||
const entries = await getConfigEntries(this.hass!);
|
||||
// We filter out the config entry for the local weather and rpi_power.
|
||||
|
@ -26,6 +26,7 @@ import "../../../components/ha-button-menu";
|
||||
import "../../../components/ha-checkbox";
|
||||
import "../../../components/ha-fab";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
|
||||
import { ConfigEntry, getConfigEntries } from "../../../data/config_entries";
|
||||
import {
|
||||
getConfigFlowInProgressCollection,
|
||||
@ -47,6 +48,7 @@ import {
|
||||
fetchIntegrationManifests,
|
||||
IntegrationManifest,
|
||||
} from "../../../data/integration";
|
||||
import { scanUSBDevices } from "../../../data/usb";
|
||||
import { showConfigFlowDialog } from "../../../dialogs/config-flow/show-dialog-config-flow";
|
||||
import { showConfirmationDialog } from "../../../dialogs/generic/show-dialog-box";
|
||||
import "../../../layouts/hass-loading-screen";
|
||||
@ -249,6 +251,7 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
||||
if (this.route.path === "/add") {
|
||||
this._handleAdd(localizePromise);
|
||||
}
|
||||
this._scanUSBDevices();
|
||||
}
|
||||
|
||||
protected updated(changed: PropertyValues) {
|
||||
@ -500,6 +503,13 @@ class HaConfigIntegrations extends SubscribeMixin(LitElement) {
|
||||
});
|
||||
}
|
||||
|
||||
private async _scanUSBDevices() {
|
||||
if (!isComponentLoaded(this.hass, "usb")) {
|
||||
return;
|
||||
}
|
||||
await scanUSBDevices(this.hass);
|
||||
}
|
||||
|
||||
private async _fetchManifests() {
|
||||
const fetched = await fetchIntegrationManifests(this.hass);
|
||||
// Make a copy so we can keep track of previously loaded manifests
|
||||
|
Loading…
x
Reference in New Issue
Block a user