mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 02:06:42 +00:00
Fix demo dashboard (#19734)
This commit is contained in:
parent
1e35f973d6
commit
189793bff4
@ -23,6 +23,7 @@ import { mockMediaPlayer } from "./stubs/media_player";
|
|||||||
import { mockPersistentNotification } from "./stubs/persistent_notification";
|
import { mockPersistentNotification } from "./stubs/persistent_notification";
|
||||||
import { mockRecorder } from "./stubs/recorder";
|
import { mockRecorder } from "./stubs/recorder";
|
||||||
import { mockTodo } from "./stubs/todo";
|
import { mockTodo } from "./stubs/todo";
|
||||||
|
import { mockSensor } from "./stubs/sensor";
|
||||||
import { mockSystemLog } from "./stubs/system_log";
|
import { mockSystemLog } from "./stubs/system_log";
|
||||||
import { mockTemplate } from "./stubs/template";
|
import { mockTemplate } from "./stubs/template";
|
||||||
import { mockTranslations } from "./stubs/translations";
|
import { mockTranslations } from "./stubs/translations";
|
||||||
@ -50,6 +51,7 @@ export class HaDemo extends HomeAssistantAppEl {
|
|||||||
mockHistory(hass);
|
mockHistory(hass);
|
||||||
mockRecorder(hass);
|
mockRecorder(hass);
|
||||||
mockTodo(hass);
|
mockTodo(hass);
|
||||||
|
mockSensor(hass);
|
||||||
mockSystemLog(hass);
|
mockSystemLog(hass);
|
||||||
mockTemplate(hass);
|
mockTemplate(hass);
|
||||||
mockEvents(hass);
|
mockEvents(hass);
|
||||||
|
58
demo/src/stubs/sensor.ts
Normal file
58
demo/src/stubs/sensor.ts
Normal file
@ -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[],
|
] as TodoItem[],
|
||||||
}));
|
}));
|
||||||
|
hass.mockWS("todo/item/subscribe", (_msg, _hass) => () => {});
|
||||||
};
|
};
|
||||||
|
@ -40,14 +40,20 @@ class HuiInputSelectEntityRow extends LitElement implements LovelaceRow {
|
|||||||
|
|
||||||
protected updated(changedProps: PropertyValues) {
|
protected updated(changedProps: PropertyValues) {
|
||||||
super.updated(changedProps);
|
super.updated(changedProps);
|
||||||
|
if (!this._config) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (changedProps.has("hass")) {
|
if (changedProps.has("hass")) {
|
||||||
const oldHass = changedProps.get("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 (
|
if (
|
||||||
this.hass &&
|
stateObj &&
|
||||||
oldHass &&
|
stateObj.attributes.options !== oldStateObj?.attributes.options
|
||||||
this._config?.entity &&
|
|
||||||
this.hass.states[this._config.entity].attributes.options !==
|
|
||||||
oldHass.states[this._config.entity].attributes.options
|
|
||||||
) {
|
) {
|
||||||
this._haSelect.layoutOptions();
|
this._haSelect.layoutOptions();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user