Move data_entry_flow_progressed event subscriber (#7700)

This commit is contained in:
Joakim Sørensen
2020-11-17 15:12:45 +01:00
committed by GitHub
parent af1518e924
commit 8fd1f35c59
3 changed files with 19 additions and 39 deletions

View File

@@ -22,7 +22,10 @@ import {
AreaRegistryEntry,
subscribeAreaRegistry,
} from "../../data/area_registry";
import type { DataEntryFlowStep } from "../../data/data_entry_flow";
import type {
DataEntryFlowProgressedEvent,
DataEntryFlowStep,
} from "../../data/data_entry_flow";
import {
DeviceRegistryEntry,
subscribeDeviceRegistry,
@@ -224,6 +227,19 @@ class DataEntryFlowDialog extends LitElement {
protected firstUpdated(changedProps: PropertyValues) {
super.firstUpdated(changedProps);
this.hass.connection.subscribeEvents<DataEntryFlowProgressedEvent>(
async (ev) => {
if (ev.data.flow_id !== this._step?.flow_id) {
return;
}
const step = await this._params!.flowConfig.fetchFlow(
this.hass,
this._step?.flow_id
);
this._processStep(step);
},
"data_entry_flow_progressed"
);
this.addEventListener("flow-update", (ev) => {
const { step, stepPromise } = (ev as any).detail;
this._processStep(step || stepPromise);