mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 14:56:37 +00:00
Fix demo (#17438)
* Fix demo Fix energy and notification in demo * Update config_entries.ts
This commit is contained in:
parent
b154607552
commit
0ee231ee85
@ -1,11 +1,10 @@
|
|||||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||||
|
|
||||||
export const mockConfigEntries = (hass: MockHomeAssistant) => {
|
export const mockConfigEntries = (hass: MockHomeAssistant) => {
|
||||||
hass.mockWS("config_entries/get_matching", () => [
|
hass.mockWS("config_entries/get", () => ({
|
||||||
{
|
|
||||||
entry_id: "co2signal",
|
entry_id: "co2signal",
|
||||||
domain: "co2signal",
|
domain: "co2signal",
|
||||||
title: "CO2 Signal",
|
title: "Electricity Maps",
|
||||||
source: "user",
|
source: "user",
|
||||||
state: "loaded",
|
state: "loaded",
|
||||||
supports_options: false,
|
supports_options: false,
|
||||||
@ -15,6 +14,5 @@ export const mockConfigEntries = (hass: MockHomeAssistant) => {
|
|||||||
pref_disable_polling: false,
|
pref_disable_polling: false,
|
||||||
disabled_by: null,
|
disabled_by: null,
|
||||||
reason: null,
|
reason: null,
|
||||||
},
|
}));
|
||||||
]);
|
|
||||||
};
|
};
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
import { PersistentNotification } from "../../../src/data/persistent_notification";
|
import { PersistentNotificationMessage } from "../../../src/data/persistent_notification";
|
||||||
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
import { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
|
||||||
|
|
||||||
export const mockPersistentNotification = (hass: MockHomeAssistant) => {
|
export const mockPersistentNotification = (hass: MockHomeAssistant) => {
|
||||||
hass.mockWS("persistent_notification/get", () =>
|
hass.mockWS("persistent_notification/subscribe", (_msg, _hass, onChange) => {
|
||||||
Promise.resolve([
|
onChange!({
|
||||||
{
|
type: "added",
|
||||||
|
notifications: {
|
||||||
|
"demo-1": {
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
message: "There was motion detected in the backyard.",
|
message: "There was motion detected in the backyard.",
|
||||||
notification_id: "demo-1",
|
notification_id: "demo-1",
|
||||||
title: "Motion Detected!",
|
title: "Motion Detected!",
|
||||||
status: "unread",
|
status: "unread",
|
||||||
},
|
},
|
||||||
] as PersistentNotification[])
|
},
|
||||||
);
|
} as PersistentNotificationMessage);
|
||||||
|
return () => {};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
@ -72,6 +72,7 @@ const generateSumStatistics = (
|
|||||||
min: null,
|
min: null,
|
||||||
max: null,
|
max: null,
|
||||||
last_reset: 0,
|
last_reset: 0,
|
||||||
|
change: add,
|
||||||
state: initValue + sum,
|
state: initValue + sum,
|
||||||
sum,
|
sum,
|
||||||
});
|
});
|
||||||
@ -103,8 +104,8 @@ const generateCurvedStatistics = (
|
|||||||
let half = false;
|
let half = false;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
while (end > currentDate && currentDate < now) {
|
while (end > currentDate && currentDate < now) {
|
||||||
const add = Math.random() * maxDiff;
|
const add = i * (Math.random() * maxDiff);
|
||||||
sum += i * add;
|
sum += add;
|
||||||
statistics.push({
|
statistics.push({
|
||||||
start: currentDate.getTime(),
|
start: currentDate.getTime(),
|
||||||
end: currentDate.getTime(),
|
end: currentDate.getTime(),
|
||||||
@ -112,6 +113,7 @@ const generateCurvedStatistics = (
|
|||||||
min: null,
|
min: null,
|
||||||
max: null,
|
max: null,
|
||||||
last_reset: 0,
|
last_reset: 0,
|
||||||
|
change: add,
|
||||||
state: initValue + sum,
|
state: initValue + sum,
|
||||||
sum: metered ? sum : null,
|
sum: metered ? sum : null,
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user