mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-30 00:07:19 +00:00
Update zwave_js log subscription to handle core changes (#9262)
This commit is contained in:
parent
9fbd594f37
commit
ce3c8f264d
@ -193,6 +193,18 @@ export const getIdentifiersFromDevice = (
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ZWaveJSLogUpdate = ZWaveJSLogMessageUpdate | ZWaveJSLogConfigUpdate;
|
||||||
|
|
||||||
|
interface ZWaveJSLogMessageUpdate {
|
||||||
|
type: "log_message";
|
||||||
|
log_message: ZWaveJSLogMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ZWaveJSLogConfigUpdate {
|
||||||
|
type: "log_config";
|
||||||
|
log_config: ZWaveJSLogConfig;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ZWaveJSLogMessage {
|
export interface ZWaveJSLogMessage {
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
level: string;
|
level: string;
|
||||||
@ -203,10 +215,10 @@ export interface ZWaveJSLogMessage {
|
|||||||
export const subscribeZWaveJSLogs = (
|
export const subscribeZWaveJSLogs = (
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry_id: string,
|
entry_id: string,
|
||||||
callback: (message: ZWaveJSLogMessage) => void
|
callback: (update: ZWaveJSLogUpdate) => void
|
||||||
) =>
|
) =>
|
||||||
hass.connection.subscribeMessage<ZWaveJSLogMessage>(callback, {
|
hass.connection.subscribeMessage<ZWaveJSLogUpdate>(callback, {
|
||||||
type: "zwave_js/subscribe_logs",
|
type: "zwave_js/subscribe_log_updates",
|
||||||
entry_id,
|
entry_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,16 +33,20 @@ class ZWaveJSLogs extends SubscribeMixin(LitElement) {
|
|||||||
|
|
||||||
public hassSubscribe(): Array<UnsubscribeFunc | Promise<UnsubscribeFunc>> {
|
public hassSubscribe(): Array<UnsubscribeFunc | Promise<UnsubscribeFunc>> {
|
||||||
return [
|
return [
|
||||||
subscribeZWaveJSLogs(this.hass, this.configEntryId, (log) => {
|
subscribeZWaveJSLogs(this.hass, this.configEntryId, (update) => {
|
||||||
if (!this.hasUpdated) {
|
if (!this.hasUpdated) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Array.isArray(log.message)) {
|
if (update.type === "log_message") {
|
||||||
for (const line of log.message) {
|
if (Array.isArray(update.log_message.message)) {
|
||||||
|
for (const line of update.log_message.message) {
|
||||||
this._textarea!.value += `${line}\n`;
|
this._textarea!.value += `${line}\n`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._textarea!.value += `${log.message}\n`;
|
this._textarea!.value += `${update.log_message.message}\n`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this._logConfig = update.log_config;
|
||||||
}
|
}
|
||||||
}).then((unsub) => {
|
}).then((unsub) => {
|
||||||
this._textarea!.value += `${this.hass.localize(
|
this._textarea!.value += `${this.hass.localize(
|
||||||
@ -141,7 +145,6 @@ class ZWaveJSLogs extends SubscribeMixin(LitElement) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setZWaveJSLogLevel(this.hass!, this.configEntryId, selected);
|
setZWaveJSLogLevel(this.hass!, this.configEntryId, selected);
|
||||||
this._logConfig.level = selected;
|
|
||||||
this._textarea!.value += `${this.hass.localize(
|
this._textarea!.value += `${this.hass.localize(
|
||||||
"ui.panel.config.zwave_js.logs.log_level_changed",
|
"ui.panel.config.zwave_js.logs.log_level_changed",
|
||||||
{ level: selected.charAt(0).toUpperCase() + selected.slice(1) }
|
{ level: selected.charAt(0).toUpperCase() + selected.slice(1) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user