mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Fixes removing audio device (#4763)
(only the supervisor doesn't support it)
This commit is contained in:
parent
aac7dbab58
commit
c7f7ef28bf
@ -128,16 +128,12 @@ class HassioAddonAudio extends LitElement {
|
|||||||
|
|
||||||
private _setInputDevice(ev): void {
|
private _setInputDevice(ev): void {
|
||||||
const device = ev.detail.item.getAttribute("device");
|
const device = ev.detail.item.getAttribute("device");
|
||||||
if (device) {
|
this._selectedInput = device || null;
|
||||||
this._selectedInput = device;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setOutputDevice(ev): void {
|
private _setOutputDevice(ev): void {
|
||||||
const device = ev.detail.item.getAttribute("device");
|
const device = ev.detail.item.getAttribute("device");
|
||||||
if (device) {
|
this._selectedOutput = device || null;
|
||||||
this._selectedOutput = device;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _addonChanged(): Promise<void> {
|
private async _addonChanged(): Promise<void> {
|
||||||
@ -147,13 +143,11 @@ class HassioAddonAudio extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const noDevice: HassioHardwareAudioDevice[] = [
|
const noDevice: HassioHardwareAudioDevice = { device: null, name: "-" };
|
||||||
{ device: undefined, name: "-" },
|
|
||||||
];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { audio } = await fetchHassioHardwareAudio(this.hass);
|
const { audio } = await fetchHassioHardwareAudio(this.hass);
|
||||||
const inupt = Object.keys(audio.input).map((key) => ({
|
const input = Object.keys(audio.input).map((key) => ({
|
||||||
device: key,
|
device: key,
|
||||||
name: audio.input[key],
|
name: audio.input[key],
|
||||||
}));
|
}));
|
||||||
@ -162,12 +156,12 @@ class HassioAddonAudio extends LitElement {
|
|||||||
name: audio.output[key],
|
name: audio.output[key],
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._inputDevices = noDevice.concat(inupt);
|
this._inputDevices = [noDevice, ...input];
|
||||||
this._outputDevices = noDevice.concat(output);
|
this._outputDevices = [noDevice, ...output];
|
||||||
} catch {
|
} catch {
|
||||||
this._error = "Failed to fetch audio hardware";
|
this._error = "Failed to fetch audio hardware";
|
||||||
this._inputDevices = noDevice;
|
this._inputDevices = [noDevice];
|
||||||
this._outputDevices = noDevice;
|
this._outputDevices = [noDevice];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,15 @@ import { HomeAssistant } from "../../types";
|
|||||||
import { HassioResponse, hassioApiResultExtractor } from "./common";
|
import { HassioResponse, hassioApiResultExtractor } from "./common";
|
||||||
|
|
||||||
export interface HassioHardwareAudioDevice {
|
export interface HassioHardwareAudioDevice {
|
||||||
device?: string;
|
device?: string | null;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface HassioHardwareAudioList {
|
interface HassioHardwareAudioList {
|
||||||
audio: { input: any; output: any };
|
audio: {
|
||||||
|
input: { [key: string]: string };
|
||||||
|
output: { [key: string]: string };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HassioHardwareInfo {
|
export interface HassioHardwareInfo {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user