Fix demo dashboard (#19734)
parent
1e35f973d6
commit
189793bff4
|
@ -23,6 +23,7 @@ import { mockMediaPlayer } from "./stubs/media_player";
|
|||
import { mockPersistentNotification } from "./stubs/persistent_notification";
|
||||
import { mockRecorder } from "./stubs/recorder";
|
||||
import { mockTodo } from "./stubs/todo";
|
||||
import { mockSensor } from "./stubs/sensor";
|
||||
import { mockSystemLog } from "./stubs/system_log";
|
||||
import { mockTemplate } from "./stubs/template";
|
||||
import { mockTranslations } from "./stubs/translations";
|
||||
|
@ -50,6 +51,7 @@ export class HaDemo extends HomeAssistantAppEl {
|
|||
mockHistory(hass);
|
||||
mockRecorder(hass);
|
||||
mockTodo(hass);
|
||||
mockSensor(hass);
|
||||
mockSystemLog(hass);
|
||||
mockTemplate(hass);
|
||||
mockEvents(hass);
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||
|
||||
export const mockSensor = (hass: MockHomeAssistant) => {
|
||||
hass.mockWS("sensor/numeric_device_classes", () => [
|
||||
{
|
||||
numeric_device_classes: [
|
||||
"volume_storage",
|
||||
"gas",
|
||||
"data_size",
|
||||
"irradiance",
|
||||
"wind_speed",
|
||||
"volatile_organic_compounds",
|
||||
"volatile_organic_compounds_parts",
|
||||
"voltage",
|
||||
"frequency",
|
||||
"precipitation_intensity",
|
||||
"volume",
|
||||
"precipitation",
|
||||
"battery",
|
||||
"nitrogen_dioxide",
|
||||
"speed",
|
||||
"signal_strength",
|
||||
"pm1",
|
||||
"nitrous_oxide",
|
||||
"atmospheric_pressure",
|
||||
"data_rate",
|
||||
"temperature",
|
||||
"power_factor",
|
||||
"aqi",
|
||||
"current",
|
||||
"volume_flow_rate",
|
||||
"humidity",
|
||||
"duration",
|
||||
"ozone",
|
||||
"distance",
|
||||
"pressure",
|
||||
"pm25",
|
||||
"weight",
|
||||
"energy",
|
||||
"carbon_monoxide",
|
||||
"apparent_power",
|
||||
"illuminance",
|
||||
"energy_storage",
|
||||
"moisture",
|
||||
"power",
|
||||
"water",
|
||||
"carbon_dioxide",
|
||||
"ph",
|
||||
"reactive_power",
|
||||
"monetary",
|
||||
"nitrogen_monoxide",
|
||||
"pm10",
|
||||
"sound_pressure",
|
||||
"sulphur_dioxide",
|
||||
],
|
||||
},
|
||||
]);
|
||||
};
|
|
@ -21,4 +21,5 @@ export const mockTodo = (hass: MockHomeAssistant) => {
|
|||
},
|
||||
] as TodoItem[],
|
||||
}));
|
||||
hass.mockWS("todo/item/subscribe", (_msg, _hass) => () => {});
|
||||
};
|
||||
|
|
|
@ -40,14 +40,20 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||
|
||||
protected updated(changedProps: PropertyValues) {
|
||||
super.updated(changedProps);
|
||||
if (!this._config) {
|
||||
return;
|
||||
}
|
||||
if (changedProps.has("hass")) {
|
||||
const oldHass = changedProps.get("hass");
|
||||
const stateObj = this.hass?.states[this._config.entity] as
|
||||
| InputSelectEntity
|
||||
| undefined;
|
||||
const oldStateObj = oldHass?.states[this._config.entity] as
|
||||
| InputSelectEntity
|
||||
| undefined;
|
||||
if (
|
||||
this.hass &&
|
||||
oldHass &&
|
||||
this._config?.entity &&
|
||||
this.hass.states[this._config.entity].attributes.options !==
|
||||
oldHass.states[this._config.entity].attributes.options
|
||||
stateObj &&
|
||||
stateObj.attributes.options !== oldStateObj?.attributes.options
|
||||
) {
|
||||
this._haSelect.layoutOptions();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue