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