first push

This commit is contained in:
jhartworks committed 2026-11-09 10:37:41 +01:00
commit 2a81b4a502
845 files changed
+356635

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
// generated by tools/make_showcase_types.mjs
window.BASIC_TYPES = [{"id":"lights","name":{"de":"Leuchten","en":"Lights"},"items":[{"type":"lamp_ceiling","size":[0.4,0.4,0.08],"name":{"de":"Deckenleuchte","en":"Ceiling light"}},{"type":"lamp_downlight","size":[0.1,0.1,0.02],"name":{"de":"Einbauspot","en":"Downlight"}},{"type":"lamp_spot","size":[0.1,0.1,0.14],"name":{"de":"Aufbau-Spot","en":"Surface spot"}},{"type":"lamp_panel","size":[0.6,0.6,0.03],"name":{"de":"LED-Panel","en":"LED panel"}},{"type":"lamp_pendant","size":[0.4,0.4,0.8],"name":{"de":"Pendelleuchte","en":"Pendant light"}},{"type":"lamp_floor","size":[0.4,0.4,1.7],"name":{"de":"Stehlampe","en":"Floor lamp"}},{"type":"lamp_uplight","size":[0.35,0.35,1.8],"name":{"de":"Deckenfluter","en":"Floor uplight"}},{"type":"lamp_table","size":[0.28,0.28,0.45],"name":{"de":"Tischlampe","en":"Table lamp"}},{"type":"lamp_wall","size":[0.22,0.12,0.2],"name":{"de":"Wandleuchte","en":"Wall light"}},{"type":"led_strip","size":[2,0.04,0.03],"name":{"de":"LED-Streifen","en":"LED strip"}},{"type":"lamp_bollard","size":[0.16,0.16,0.8],"name":{"de":"Wegleuchte","en":"Path light"}},{"type":"lamp_garden","size":[0.12,0.12,0.3],"name":{"de":"Garten-Spot","en":"Garden spot"}}]},{"id":"living","name":{"de":"Wohnen","en":"Living"},"items":[{"type":"sofa","size":[2.2,0.9,0.82],"name":{"de":"Sofa","en":"Sofa"}},{"type":"armchair","size":[0.85,0.85,0.8],"name":{"de":"Sessel","en":"Armchair"}},{"type":"stool","size":[0.55,0.55,0.42],"name":{"de":"Hocker","en":"Stool"}},{"type":"coffee_table","size":[1.1,0.6,0.42],"name":{"de":"Couchtisch","en":"Coffee table"}},{"type":"tv_board","size":[1.8,0.42,0.5],"name":{"de":"TV-Board","en":"TV board"}},{"type":"tv_wall","size":[1.3,0.08,0.75],"name":{"de":"Fernseher (Wand)","en":"TV (wall)"}},{"type":"sideboard","size":[1.6,0.45,0.8],"name":{"de":"Sideboard","en":"Sideboard"}},{"type":"shelf","size":[0.9,0.35,1.9],"name":{"de":"Regal","en":"Shelf"}},{"type":"plant","size":[0.45,0.45,1.1],"name":{"de":"Pflanze","en":"Plant"}},{"type":"rug","size":[2,1.4,0.01],"name":{"de":"Teppich","en":"Rug"}}]},{"id":"dining","name":{"de":"Essen","en":"Dining"},"items":[{"type":"table","size":[1.6,0.9,0.75],"name":{"de":"Tisch","en":"Table"}},{"type":"table_round","size":[1.1,1.1,0.75],"name":{"de":"Runder Tisch","en":"Round table"}},{"type":"chair","size":[0.46,0.5,0.9],"name":{"de":"Stuhl","en":"Chair"}},{"type":"bench","size":[1.4,0.45,0.85],"name":{"de":"Sitzbank","en":"Bench"}},{"type":"corner_bench","size":[2,1.6,0.9],"name":{"de":"Eckbank","en":"Corner bench"}},{"type":"bar_stool","size":[0.42,0.42,0.75],"name":{"de":"Barhocker","en":"Bar stool"}}]},{"id":"kitchen","name":{"de":"Küche","en":"Kitchen"},"items":[{"type":"kitchen","size":[2.4,0.62,0.92],"name":{"de":"Küchenzeile","en":"Kitchen unit"}},{"type":"kitchen_wall","size":[0.8,0.35,0.7],"name":{"de":"Oberschrank","en":"Wall cabinet"}},{"type":"kitchen_tall","size":[0.6,0.62,2.1],"name":{"de":"Hochschrank mit Backofen","en":"Tall unit with oven"}},{"type":"island","size":[1.8,0.9,0.92],"name":{"de":"Kochinsel","en":"Kitchen island"}},{"type":"worktop","size":[1.2,0.62,0.91],"name":{"de":"Arbeitsplatte","en":"Worktop"}},{"type":"sink","size":[0.9,0.62,0.92],"name":{"de":"Spüle","en":"Sink"}},{"type":"stove","size":[0.6,0.62,0.92],"name":{"de":"Herd","en":"Stove"}},{"type":"dishwasher","size":[0.6,0.62,0.92],"name":{"de":"Spülmaschine","en":"Dishwasher"}},{"type":"fridge","size":[0.6,0.65,1.8],"name":{"de":"Kühlschrank","en":"Fridge"}}]},{"id":"sleeping","name":{"de":"Schlafen","en":"Sleeping"},"items":[{"type":"bed","size":[1.6,2.05,0.9],"name":{"de":"Bett","en":"Bed"}},{"type":"bunk_bed","size":[1,2.05,1.65],"name":{"de":"Etagenbett","en":"Bunk bed"}},{"type":"nightstand","size":[0.45,0.4,0.5],"name":{"de":"Nachttisch","en":"Nightstand"}},{"type":"wardrobe","size":[1.8,0.6,2.1],"name":{"de":"Schrank","en":"Wardrobe"}},{"type":"dresser","size":[1,0.5,0.9],"name":{"de":"Kommode","en":"Chest of drawers"}}]},{"id":"bath","name":{"de":"Bad & Hauswirtschaft","en":"Bath & laundry"},"items":[{"type":"bathtub","size":[1.7,0.75,0.58],"name":{"de":"Badewanne","en":"Bathtub"}},{"type":"shower","size":[0.9,0.9,2],"name":{"de":"Dusche","en":"Shower"}},{"type":"wc","size":[0.38,0.6,0.8],"name":{"de":"WC","en":"WC"}},{"type":"washbasin","size":[0.6,0.46,0.85],"name":{"de":"Waschtisch","en":"Washbasin"}},{"type":"washer","size":[0.6,0.6,0.85],"name":{"de":"Waschmaschine","en":"Washing machine"}},{"type":"dryer","size":[0.6,0.6,0.85],"name":{"de":"Trockner","en":"Dryer"}}]},{"id":"work","name":{"de":"Arbeiten & Sonstiges","en":"Work & other"},"items":[{"type":"desk","size":[1.4,0.7,0.75],"name":{"de":"Schreibtisch","en":"Desk"}},{"type":"worktop","size":[1.2,0.62,0.91],"name":{"de":"Arbeitsplatte","en":"Worktop"}},{"type":"office_chair","size":[0.65,0.65,1.1],"name":{"de":"Bürostuhl","en":"Office chair"}},{"type":"tall_cabinet","size":[0.6,0.6,2.1],"name":{"de":"Hochschrank","en":"Tall cabinet"}},{"type":"coat_rack","size":[1,0.35,1.9],"name":{"deLine truncated
+519
View File
@@ -0,0 +1,519 @@
// Invented demo home for the preview page (not anyone's real floor plan).
const rect = (id, name, area_id, x0, z0, x1, z1, floor_material = "wood") => ({
id,
name,
area_id,
points: [
[x0, z0],
[x1, z0],
[x1, z1],
[x0, z1],
],
floor_material,
});
const floor = (id, name, elevation, rooms) => ({
id,
name,
elevation,
height: 2.5,
cut_height: 1.15,
rooms,
openings: [],
furniture: [],
placements: [],
background: null,
});
export const DEMO_FLOORS = {
keller: { floor_id: "keller", name: "Keller", level: -1 },
erdgeschoss: { floor_id: "erdgeschoss", name: "Erdgeschoss", level: 0 },
obergeschoss: { floor_id: "obergeschoss", name: "Obergeschoss", level: 1 },
dachgeschoss: { floor_id: "dachgeschoss", name: "Dachgeschoss", level: 2 },
};
export const DEMO_AREAS = {
wohnzimmer: { area_id: "wohnzimmer", name: "Wohnzimmer", floor_id: "erdgeschoss" },
kueche: { area_id: "kueche", name: "Küche", floor_id: "erdgeschoss" },
schlafzimmer: { area_id: "schlafzimmer", name: "Schlafzimmer", floor_id: "erdgeschoss" },
bad: { area_id: "bad", name: "Bad", floor_id: "erdgeschoss" },
flur: { area_id: "flur", name: "Flur", floor_id: "erdgeschoss" },
kinderzimmer: { area_id: "kinderzimmer", name: "Kinderzimmer", floor_id: "obergeschoss" },
arbeitszimmer: { area_id: "arbeitszimmer", name: "Arbeitszimmer", floor_id: "obergeschoss" },
garage: { area_id: "garage", name: "Garage", floor_id: "erdgeschoss" },
waschkueche: { area_id: "waschkueche", name: "Waschküche", floor_id: "keller" },
heizung: { area_id: "heizung", name: "Heizungsraum", floor_id: "keller" },
vorrat: { area_id: "vorrat", name: "Vorratsraum", floor_id: "keller" },
hobby: { area_id: "hobby", name: "Hobbyraum", floor_id: "keller" },
};
export const DEMO_BUILDING = {
version: 1,
settings: { wall_exterior: 0.24, wall_interior: 0.12, grid: 0.05 },
floors: [
floor("eg", "Erdgeschoss", 0, [
rect("wohnen", "Wohnzimmer", "wohnzimmer", 0, 0, 6, 4.6),
rect("kueche", "Küche", "kueche", 6, 0, 10, 4.6, "tiles"),
rect("schlafen", "Schlafzimmer", "schlafzimmer", 0, 4.6, 4.4, 8, "carpet"),
rect("bad", "Bad", "bad", 4.4, 4.6, 6.8, 8, "tiles"),
{
id: "flur",
name: "Flur",
area_id: "flur",
points: [
[6.8, 4.6],
[10, 4.6],
[10, 8],
[8.4, 8],
[8.4, 9.2],
[6.8, 9.2],
],
floor_material: "oak",
},
rect("garage", "Garage", "garage", 10, 0, 13.6, 5.2, "concrete"),
]),
floor("og", "Obergeschoss", 2.75, [
{ ...rect("kind", "Kinderzimmer", "kinderzimmer", 0, 0, 4.4, 4.2, "carpet"), wall_thickness: [0.365, null, null, null] },
rect("arbeit", "Arbeitszimmer", "arbeitszimmer", 4.4, 0, 10, 4.2, "oak"),
rect("badog", "Bad oben", null, 0, 4.2, 3.4, 8, "tiles"),
rect("gast", "Gästezimmer", null, 3.4, 4.2, 10, 8),
]),
],
};
// Invented pictures (no real logos or photos): a cover for the TV and a camera still.
const svgPicture = (body) => `data:image/svg+xml;base64,${btoa(body)}`;
const COVER = svgPicture(
'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180"><defs><linearGradient id="g" x1="0" x2="1" y1="0" y2="1"><stop offset="0" stop-color="#2b0a3d"/><stop offset="1" stop-color="#b3122e"/></linearGradient></defs><rect width="320" height="180" fill="url(#g)"/><circle cx="240" cy="70" r="38" fill="#ffb547" opacity="0.85"/><path d="M0 150 L90 95 L150 130 L230 80 L320 140 L320 180 L0 180 Z" fill="#12061c"/><text x="24" y="52" font-family="sans-serif" font-size="30" font-weight="700" fill="#fff">Serie</text></svg>',
);
// a stored picture for a screen rule (shown on the TV while Netflix runs)
export const DEMO_PICTURES = {
pic_demo: svgPicture(
'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180"><rect width="320" height="180" fill="#101010"/><text x="160" y="105" text-anchor="middle" font-family="sans-serif" font-size="56" font-weight="900" fill="#e50914">LOGO</text></svg>',
),
};
const CAMERA_STILL = svgPicture(
'<svg xmlns="http://www.w3.org/2000/svg" width="320" height="180"><rect width="320" height="180" fill="#1b2230"/><rect x="0" y="120" width="320" height="60" fill="#2a3444"/><rect x="40" y="60" width="90" height="70" fill="#3b4a60"/><rect x="190" y="40" width="80" height="90" fill="#324055"/><text x="12" y="20" font-family="monospace" font-size="12" fill="#cfd8e6">KAMERA 1 12:04:31</text></svg>',
);
// Invented devices: registry entries, states and placements for the preview.
const light = (id, name, area, on, extra = {}) => ({
entry: { entity_id: `light.${id}`, area_id: area },
state: {
entity_id: `light.${id}`,
state: on ? "on" : "off",
attributes: {
friendly_name: name,
supported_color_modes: ["color_temp", "hs"],
color_mode: "color_temp",
min_color_temp_kelvin: 2200,
max_color_temp_kelvin: 6500,
...(on ? { brightness: 180, color_temp_kelvin: 2700 } : {}),
...extra,
},
},
});
const entity = (entity_id, area, state, attributes) => ({ entry: { entity_id, area_id: area }, state: { entity_id, state, attributes } });
const DEVICES = [
light("wohnzimmer_decke", "Wohnzimmer Deckenlicht", "wohnzimmer", true),
light("stehlampe", "Stehlampe", "wohnzimmer", true, { brightness: 90, color_mode: "hs", rgb_color: [255, 150, 60] }),
light("kueche", "Küchenlicht", "kueche", false),
light("schlafzimmer", "Schlafzimmer Decke", "schlafzimmer", false),
light("nachttisch", "Nachttisch", "schlafzimmer", true, { brightness: 60 }),
light("bad", "Bad Spots", "bad", true, { brightness: 220, color_temp_kelvin: 4000 }),
light("flur", "Flurlicht", "flur", true, { brightness: 120 }),
light("kinderzimmer", "Kinderzimmer Decke", "kinderzimmer", true, { brightness: 150 }),
light("schreibtisch", "Schreibtischlampe", "arbeitszimmer", true, { color_temp_kelvin: 4500 }),
light("esstisch", "Esstisch Pendel", "kueche", true, { brightness: 140 }),
light("kueche_links", "Küche links", "kueche", true, { brightness: 230, color_mode: "hs", rgb_color: [255, 70, 40] }),
light("kueche_rechts", "Küche rechts", "kueche", true, { brightness: 230, color_mode: "hs", rgb_color: [60, 110, 255] }),
light("garten", "Garten Wegleuchten", null, true, { brightness: 170 }),
light("pool", "Pool Spot", null, true, { brightness: 200, color_mode: "hs", rgb_color: [40, 200, 255] }),
light("haustuer", "Haustür Außenlicht", "flur", true, { brightness: 200 }),
light("led_band", "LED Band", "wohnzimmer", true, { brightness: 160, color_mode: "hs", rgb_color: [120, 90, 255], effect: "colorloop", effect_list: ["colorloop", "none"] }),
entity("cover.wohnzimmer", "wohnzimmer", "open", { friendly_name: "Wohnzimmer Rollladen", current_position: 70, supported_features: 15 }),
entity("cover.kueche", "kueche", "open", { friendly_name: "Rollladen Küche", current_position: 40, supported_features: 15 }),
entity("climate.wohnzimmer", "wohnzimmer", "heat", {
friendly_name: "Wohnzimmer Heizung",
current_temperature: 21.4,
temperature: 21.5,
hvac_modes: ["off", "heat", "auto"],
hvac_action: "heating",
min_temp: 5,
max_temp: 30,
target_temp_step: 0.5,
}),
entity("climate.schlafzimmer", "schlafzimmer", "heat", {
friendly_name: "Schlafzimmer Heizung",
current_temperature: 18.2,
temperature: 18,
hvac_modes: ["off", "heat"],
hvac_action: "idle",
min_temp: 5,
max_temp: 30,
}),
entity("media_player.fernseher", "wohnzimmer", "playing", { friendly_name: "Fernseher", device_class: "tv", app_name: "Netflix", media_title: "Serie", volume_level: 0.35, entity_picture: COVER }),
entity("media_player.kueche_lautsprecher", "kueche", "playing", { friendly_name: "Küche Lautsprecher", device_class: "speaker", media_title: "Blue Train", media_artist: "John Coltrane", volume_level: 0.45, entity_picture: COVER, group_members: ["media_player.kueche_lautsprecher", "media_player.bad_lautsprecher"] }),
entity("media_player.bad_lautsprecher", "bad", "playing", { friendly_name: "Bad Lautsprecher", device_class: "speaker", media_title: "Blue Train", media_artist: "John Coltrane", volume_level: 0.3, entity_picture: COVER, group_members: ["media_player.kueche_lautsprecher", "media_player.bad_lautsprecher"] }),
entity("switch.kaffeemaschine", "kueche", "on", { friendly_name: "Kaffeemaschine" }),
entity("camera.wohnzimmer", "wohnzimmer", "idle", { friendly_name: "Wohnzimmer Kamera", entity_picture: CAMERA_STILL }),
entity("sensor.wohnzimmer_temperatur", "wohnzimmer", "21.4", { friendly_name: "Wohnzimmer Temperatur", device_class: "temperature", unit_of_measurement: "°C" }),
entity("sensor.kueche_temperatur", "kueche", "23.4", { friendly_name: "Küche Temperatur", device_class: "temperature", unit_of_measurement: "°C" }),
entity("sensor.schlafzimmer_temperatur", "schlafzimmer", "18.1", { friendly_name: "Schlafzimmer Temperatur", device_class: "temperature", unit_of_measurement: "°C" }),
entity("sensor.bad_temperatur", "bad", "24.6", { friendly_name: "Bad Temperatur", device_class: "temperature", unit_of_measurement: "°C" }),
entity("sensor.flur_temperatur", "flur", "19.6", { friendly_name: "Flur Temperatur", device_class: "temperature", unit_of_measurement: "°C" }),
entity("sun.sun", null, "above_horizon", { friendly_name: "Sonne", elevation: 32, azimuth: 205 }),
entity("sensor.wohnzimmer_feuchte", "wohnzimmer", "48", { friendly_name: "Wohnzimmer Luftfeuchtigkeit", device_class: "humidity", unit_of_measurement: "%" }),
entity("binary_sensor.kueche_fenster", "kueche", "on", { friendly_name: "Küche Fenster", device_class: "window" }),
entity("binary_sensor.kueche_rauch", "kueche", "off", { friendly_name: "Küche Rauchmelder", device_class: "smoke" }),
entity("binary_sensor.garage_auto", "garage", "on", { friendly_name: "Auto in der Garage", device_class: "occupancy" }),
entity("sensor.van_ladestand", "garage", "78", { friendly_name: "Van Ladestand", device_class: "battery", unit_of_measurement: "%" }),
// helpers standing in for a car without an integration (Auto Pro with input_number / input_boolean)
entity("input_number.test_ladestand", null, "78.0", { friendly_name: "Test Auto Ladestand", unit_of_measurement: "%", min: 0, max: 100, step: 1 }),
entity("input_number.test_reichweite", null, "312.0", { friendly_name: "Test Auto Reichweite", unit_of_measurement: "km", min: 0, max: 600, step: 1 }),
entity("input_number.test_ladeleistung", null, "0.0", { friendly_name: "Test Auto Ladeleistung", unit_of_measurement: "W", min: 0, max: 11000, step: 100 }),
entity("input_boolean.test_verriegelt", null, "on", { friendly_name: "Test Auto verriegelt" }),
entity("input_boolean.test_klima", null, "on", { friendly_name: "Test Auto Klima" }),
entity("input_boolean.test_auto_da", null, "on", { friendly_name: "Test Auto da" }),
entity("sensor.van_reichweite", "garage", "312", { friendly_name: "Van Reichweite", unit_of_measurement: "km" }),
entity("sensor.van_ladeleistung", "garage", "7400", { friendly_name: "Van Ladeleistung", device_class: "power", unit_of_measurement: "W" }),
entity("lock.van", "garage", "locked", { friendly_name: "Van Verriegelung" }),
entity("switch.van_klima", "garage", "on", { friendly_name: "Van Klima" }),
entity("sensor.garage_fahrzeugtyp", "garage", "van", { friendly_name: "Fahrzeugtyp Garage" }),
entity("device_tracker.zweitwagen", null, "not_home", { friendly_name: "Zweitwagen" }),
entity("weather.zuhause", null, "sunny", { friendly_name: "Wetter" }),
entity("alarm_control_panel.haus", null, "disarmed", { friendly_name: "Alarmanlage" }),
entity("scene.wohnzimmer_kino", "wohnzimmer", "unknown", { friendly_name: "Wohnzimmer Kino" }),
entity("scene.wohnzimmer_lesen", "wohnzimmer", "unknown", { friendly_name: "Wohnzimmer Lesen" }),
entity("script.wohnzimmer_alles_aus", "wohnzimmer", "off", { friendly_name: "Wohnzimmer Alles aus" }),
entity("binary_sensor.flur_bewegung", "flur", "off", { friendly_name: "Flur Bewegung", device_class: "motion" }),
entity("binary_sensor.kueche_praesenz", "kueche", "off", { friendly_name: "Küche Präsenz", device_class: "presence" }),
entity("binary_sensor.kuehlschrank_tuer", "kueche", "off", { friendly_name: "Kühlschrank Tür", device_class: "door" }),
entity("binary_sensor.gefrierfach_tuer", "kueche", "on", { friendly_name: "Gefrierfach Tür", device_class: "door" }),
entity("binary_sensor.wohnzimmer_kamera_bewegung", "wohnzimmer", "on", { friendly_name: "Wohnzimmer Kamera Bewegung", device_class: "motion" }),
entity("binary_sensor.wohnzimmer_kamera_person", "wohnzimmer", "on", { friendly_name: "Wohnzimmer Kamera Person", device_class: "occupancy" }),
entity("binary_sensor.haustuer", "flur", "off", { friendly_name: "Haustür", device_class: "door" }),
entity("lock.haustuer", "flur", "unlocked", { friendly_name: "Haustür Schloss" }),
// household: bins with their next pickup, the mailbox, a plant's soil moisture
entity("sensor.restmuell", null, "morgen", { friendly_name: "Restmüll" }),
entity("sensor.papier", null, "5", { friendly_name: "Papier", unit_of_measurement: "Tage" }),
entity("sensor.gelbe_tonne", null, "heute", { friendly_name: "Gelbe Tonne" }),
entity("binary_sensor.post", null, "on", { friendly_name: "Briefkasten" }),
entity("sensor.monstera_feuchte", null, "14", { friendly_name: "Monstera Feuchte", unit_of_measurement: "%" }),
entity("binary_sensor.bett_links", "schlafzimmer", "on", { friendly_name: "Bett links belegt", device_class: "occupancy" }),
entity("binary_sensor.bett_rechts", "schlafzimmer", "off", { friendly_name: "Bett rechts belegt", device_class: "occupancy" }),
entity("cover.garagentor", "garage", "open", { friendly_name: "Garagentor", device_class: "garage", current_position: 60, supported_features: 15 }),
entity("binary_sensor.wohnzimmer_terrasse", "wohnzimmer", "on", { friendly_name: "Terrassentür", device_class: "opening" }),
entity("vacuum.saugi", "wohnzimmer", "cleaning", { friendly_name: "Saugi", battery_level: 64 }),
entity("binary_sensor.wohnzimmer_terrasse_2", "wohnzimmer", "off", { friendly_name: "Terrassentür Standflügel", device_class: "opening" }),
entity("binary_sensor.schlafzimmer_fenster", "schlafzimmer", "on", { friendly_name: "Schlafzimmer Fenster", device_class: "window" }),
entity("binary_sensor.schlafzimmer_kipp", "schlafzimmer", "on", { friendly_name: "Schlafzimmer Fenster gekippt", device_class: "window" }),
entity("scene.wohnzimmer_film", "wohnzimmer", "2024-01-01T00:00:00", { friendly_name: "Wohnzimmer Film" }),
entity("scene.wohnzimmer_lesen", "wohnzimmer", "2024-01-01T00:00:00", { friendly_name: "Wohnzimmer Lesen" }),
entity("script.gute_nacht", "schlafzimmer", "off", { friendly_name: "Gute Nacht" }),
// energy (invented values)
entity("sensor.netz_leistung", "flur", "420", { friendly_name: "Netz Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.pv_leistung", "flur", "1150", { friendly_name: "PV Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.balkon_leistung", "flur", "380", { friendly_name: "Balkonkraftwerk Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.akku_leistung", "flur", "-300", { friendly_name: "Akku Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.akku_ladestand", "flur", "64", { friendly_name: "Akku Ladestand", device_class: "battery", unit_of_measurement: "%" }),
entity("sensor.strompreis", null, "0.29", { friendly_name: "Strompreis", device_class: "monetary", unit_of_measurement: "€/kWh" }),
entity("sensor.fernseher_leistung", "wohnzimmer", "95", { friendly_name: "Fernseher Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.kaffeemaschine_leistung", "kueche", "0.9", { friendly_name: "Kaffeemaschine Leistung", device_class: "power", unit_of_measurement: "kW" }),
entity("sensor.kuehlschrank_leistung", "kueche", "85", { friendly_name: "Kühlschrank Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.waschmaschine_leistung", "bad", "430", { friendly_name: "Waschmaschine Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.pc_leistung", "arbeitszimmer", "70", { friendly_name: "Computer Leistung", device_class: "power", unit_of_measurement: "W" }),
entity("sensor.gaszaehler", "garage", "4821.374", { friendly_name: "Gaszähler", device_class: "gas", unit_of_measurement: "m³" }),
// people and their room sensors (as ESPresense or Bermuda would report them)
entity("person.mia", null, "home", { friendly_name: "Mia" }),
entity("person.tom", null, "home", { friendly_name: "Tom Beispiel" }),
entity("person.lea", null, "not_home", { friendly_name: "Lea" }),
entity("sensor.mia_raum", null, "Wohnzimmer", { friendly_name: "Mia Raum" }),
entity("sensor.tom_raum", null, "Küche", { friendly_name: "Tom Raum" }),
entity("sensor.lea_raum", null, "not_home", { friendly_name: "Lea Raum" }),
];
// a LED matrix with many light entities: only the main one (without a name of its own) is shown first
for (const [suffix, name] of [
["", null],
["_indicator_1", "Indicator 1"],
["_indicator_2", "Indicator 2"],
["_indicator_3", "Indicator 3"],
["_matrix", "Matrix"],
]) {
const id = `light.pixeluhr${suffix}`;
DEVICES.push({
entry: { entity_id: id, area_id: "wohnzimmer", device_id: "d_pixeluhr", ...(name ? { name } : {}) },
state: { entity_id: id, state: "off", attributes: { friendly_name: name ? `Pixeluhr ${name}` : "Pixeluhr", supported_color_modes: ["hs"] } },
});
}
// devices with a power sensor of their own
for (const [id, device] of [
["sensor.van_ladestand", "d_van"],
["sensor.van_reichweite", "d_van"],
["sensor.van_ladeleistung", "d_van"],
["lock.van", "d_van"],
["switch.van_klima", "d_van"],
["media_player.fernseher", "d_tv"],
["sensor.fernseher_leistung", "d_tv"],
["switch.kaffeemaschine", "d_kaffee"],
["sensor.kaffeemaschine_leistung", "d_kaffee"],
]) {
DEVICES.find((d) => d.entry.entity_id === id).entry.device_id = device;
}
export const DEMO_ENTITIES = Object.fromEntries(DEVICES.map((d) => [d.entry.entity_id, d.entry]));
export const DEMO_STATES = Object.fromEntries(DEVICES.map((d) => [d.state.entity_id, d.state]));
const place = (entity_id, x, z) => ({ entity_id, x, z, y: null });
DEMO_BUILDING.floors[0].placements = [
place("light.wohnzimmer_decke", 3.6, 2.6),
{ entity_id: "light.stehlampe", x: 5.3, z: 0.7, y: null, mount: "floor" },
place("cover.wohnzimmer", 1.6, 0.4),
place("climate.wohnzimmer", 0.5, 2.2),
place("media_player.fernseher", 3.0, 0.4),
place("media_player.kueche_lautsprecher", 9.4, 0.5),
place("media_player.bad_lautsprecher", 7.2, 6.4),
place("switch.kaffeemaschine", 9.4, 0.6),
place("binary_sensor.kueche_fenster", 7.2, 0.4),
place("light.schlafzimmer", 2.9, 6.8),
{ entity_id: "light.nachttisch", x: 3.3, z: 7.78, y: null, mount: "table" },
place("light.flur", 8.8, 6.9),
];
DEMO_BUILDING.floors[0].placements.push({ ...place("sensor.gaszaehler", 12.9, 4.6), name: "Gas Garage", show_name: true });
DEMO_BUILDING.floors[0].placements.push(
place("sensor.kuehlschrank_leistung", 6.35, 0.8),
place("sensor.waschmaschine_leistung", 6.4, 6.9),
place("sensor.akku_leistung", 7.3, 8.8),
);
DEMO_BUILDING.floors[1].placements = [place("light.kinderzimmer", 2.9, 2.8), place("light.schreibtisch", 6.2, 1.2), place("sensor.pc_leistung", 9.0, 0.9)];
// grid, solar and battery come from the devices in the garage (meter, inverter, home battery)
DEMO_BUILDING.energy = {
meter: null,
grid: null,
grid_invert: false,
solar: null,
battery: null,
battery_invert: false,
battery_soc: null,
consumption: null,
tariff: "sensor.strompreis",
};
DEMO_BUILDING.presence = [
{ person: "person.mia", sensor: "sensor.mia_raum" },
{ person: "person.tom", sensor: "sensor.tom_raum" },
{ person: "person.lea", sensor: "sensor.lea_raum" },
];
// Invented doors, windows and furniture for the preview.
let openingId = 0;
const hole = (type, room_id, edge, offset, width, extra = {}) => ({
id: `o${++openingId}`,
room_id,
edge,
offset,
width,
type,
sill: type === "door" ? 0 : 0.9,
height: type === "door" ? 2.05 : 1.3,
hinge: "left",
cover: null,
contact: null,
tilt: null,
...extra,
});
const terrace = { sill: 0, height: 2.15 };
DEMO_BUILDING.floors[0].openings = [
hole("window", "wohnen", 0, 1.6, 1.4, { contact: "none" }),
hole("window", "wohnen", 0, 4.3, 1.8, { ...terrace, leaves: 2, contact: "binary_sensor.wohnzimmer_terrasse", contact2: "binary_sensor.wohnzimmer_terrasse_2", hinge: "right" }),
hole("window", "wohnen", 3, 2.3, 1.2, { contact: "none" }),
hole("door", "wohnen", 1, 3.0, 1.4, { style: "passage" }),
hole("door", "wohnen", 2, 4.2, 0.9),
hole("window", "kueche", 0, 2.4, 1.2),
hole("door", "kueche", 1, 3.6, 0.9, { hinge: "right" }),
hole("garage", "garage", 1, 2.6, 2.5, { sill: 0, height: 2.1 }),
hole("door", "kueche", 2, 1.6, 0.9),
hole("window", "schlafen", 2, 2.2, 1.4, { contact: "binary_sensor.schlafzimmer_fenster", tilt: "binary_sensor.schlafzimmer_kipp" }),
hole("window", "schlafen", 3, 1.7, 1.0, { contact: "none" }),
hole("window", "bad", 2, 1.2, 0.8, { sill: 1.3, height: 0.8 }),
hole("door", "bad", 1, 1.2, 0.8),
hole("door", "flur", 4, 0.8, 1.4, { swing: "out", style: "sidelight", lock: "lock.haustuer" }),
];
DEMO_BUILDING.floors[1].openings = [
hole("window", "kind", 0, 2.2, 1.2),
hole("window", "arbeit", 0, 2.8, 1.6),
hole("window", "gast", 2, 3.0, 1.2),
hole("door", "kind", 1, 3.3, 0.9),
];
let furnitureId = 0;
const item = (type, x, z, w, d, h, rotation = 0) => ({ id: `m${++furnitureId}`, type, x, z, w, d, h, rotation, variant: null });
DEMO_BUILDING.floors[0].furniture = [
item("rug", 2.4, 2.3, 2.6, 1.7, 0.01),
item("sofa", 2.4, 3.7, 2.3, 0.92, 0.82, 180),
item("armchair", 0.75, 2.2, 0.85, 0.85, 0.8, 270),
{ ...item("tv_board", 2.4, 0.25, 1.8, 0.42, 0.5), pictures: [{ entity: "media_player.fernseher", attribute: "app_name", state: "netflix", image: "pic_demo" }] },
item("plant", 5.55, 0.45, 0.5, 0.5, 1.2),
item("shelf", 5.8, 2.6, 0.9, 0.35, 1.9, 90),
item("fridge", 6.35, 0.36, 0.6, 0.66, 1.85),
item("kitchen", 7.25, 0.31, 1.2, 0.62, 0.92),
item("stove", 8.15, 0.31, 0.6, 0.62, 0.92),
item("sink", 8.9, 0.31, 0.9, 0.62, 0.92),
item("kitchen", 9.65, 0.31, 0.6, 0.62, 0.92),
item("kitchen_wall", 7.25, 0.18, 1.2, 0.35, 0.7),
item("kitchen_wall", 8.9, 0.18, 0.9, 0.35, 0.7),
item("corner_bench", 7.1, 3.55, 2.0, 1.6, 0.9, 270),
item("table", 8.0, 2.9, 1.3, 0.85, 0.75),
{ ...item("lamp_pendant", 8.0, 2.9, 0.3, 0.3, 0.95), entity: "light.esstisch", variant: "globe" },
{ ...item("radiator", 0.08, 2.3, 1.0, 0.1, 0.6, 270), entity: "climate.wohnzimmer" },
// pets that roam their room
item("pack:nextfloor.a_haustiere:pet_cat", 1.6, 1.4, 0.2, 0.5, 0.3, 30),
item("pack:nextfloor.a_haustiere:pet_dog", 9.0, 2.0, 0.3, 0.75, 0.55, 200),
// a two-gang light switch by the kitchen door and a double socket over the worktop (smart home pack)
{ ...item("pack:nextfloor.a_smart:light_switch_2", 10.05, 0.006, 0.157, 0.012, 0.086), gang_entities: ["light.kueche_links", "light.kueche_rechts"] },
{ ...item("pack:nextfloor.a_smart:socket_2", 7.75, 0.006, 0.157, 0.012, 0.086), mount_y: 1.02, gang_entities: ["switch.kaffeemaschine", null] },
...[
[7.6, 10.4],
[7.6, 12.4],
].map(([x, z]) => ({ ...item("lamp_bollard", x, z, 0.16, 0.16, 0.8), entity: "light.garten" })),
{ ...item("lamp_garden", 12.4, -3.4, 0.12, 0.12, 0.3), entity: "light.pool" },
// vegetation from the garden pack (release 3): an oak and a birch on the front lawn, a fruit tree behind the house
item("pack:nextfloor.garten:tree_oak", -0.5, -5.4, 5.0, 5.0, 7.0),
item("pack:nextfloor.garten:tree_birch", 15.2, -5.8, 3.2, 3.2, 7.5),
item("pack:nextfloor.garten:shrub", 7.2, -1.2, 1.3, 1.3, 1.2),
item("pack:nextfloor.garten:shrub_flowering", 0.6, -1.4, 1.3, 1.3, 1.4),
item("pack:nextfloor.garten:tree_fruit", 2.2, 12.2, 3.2, 3.2, 3.6),
item("pack:nextfloor.garten:lawn_brush", 4.8, 12.0, 2.6, 2.6, 0.8),
{ ...item("lamp_wall", 8.9, 9.5, 0.22, 0.12, 0.2), entity: "light.haustuer" },
{ ...item("lamp_ceiling", 7.0, 2.1, 0.45, 0.45, 0.08), entity: "light.kueche_links" },
{ ...item("lamp_ceiling", 9.0, 2.1, 0.45, 0.45, 0.08), entity: "light.kueche_rechts" },
...[
[5.0, 5.4],
[6.2, 5.4],
[5.0, 6.9],
[6.2, 6.9],
].map(([x, z]) => ({ ...item("lamp_downlight", x, z, 0.1, 0.1, 0.02), entity: "light.bad" })),
{ ...item("led_strip", 2.4, 0.08, 3.2, 0.04, 0.03), entity: "light.led_band" },
// an upright strip at the wall, a light column from the floor up
{ ...item("led_strip", 0.1, 1.2, 1.8, 0.04, 0.03, 90), entity: "light.led_band", upright: true, mount_y: 0.1 },
item("chair", 8.4, 2.2, 0.45, 0.5, 0.9),
item("chair", 8.95, 2.9, 0.45, 0.5, 0.9, 270),
{ ...item("bed", 2.2, 6.97, 1.6, 2.05, 0.9, 180), state_entity: "binary_sensor.bett_links", state_entity2: "binary_sensor.bett_rechts", state_split: "left_right" },
item("nightstand", 1.1, 7.78, 0.45, 0.4, 0.5, 180),
item("nightstand", 3.3, 7.78, 0.45, 0.4, 0.5, 180),
item("wardrobe", 0.31, 5.55, 1.6, 0.6, 2.1, 270),
item("bathtub", 5.6, 7.6, 1.7, 0.75, 0.58, 180),
item("wc", 4.72, 5.35, 0.38, 0.6, 0.8, 270),
item("washbasin", 6.55, 5.3, 0.6, 0.46, 0.85, 90),
{ ...item("washer", 6.47, 6.45, 0.6, 0.6, 0.85, 90) },
item("coffee_table", 2.4, 2.4, 1.1, 0.6, 0.42),
item("stairs", 9.42, 6.3, 1.0, 3.2, 2.75),
item("wardrobe", 7.1, 6.4, 1.2, 0.4, 2.0, 270),
{ ...item("robot_vacuum", 5.7, 3.2, 0.36, 0.5, 0.1, 270), entity: "vacuum.saugi" },
{
// along the garage (3.6 m wide, 5.2 m deep): the van fits inside instead of poking through the wall
...item("parking", 11.8, 2.6, 2.6, 5.0, 0.02, 0),
entity: "binary_sensor.garage_auto",
car: { soc: "sensor.van_ladestand", range: "sensor.van_reichweite", charging: "sensor.van_ladeleistung", lock: "lock.van", climate: "switch.van_klima" },
vehicle: "pack:nextfloor.fahrzeuge:van",
scale: 0.95,
type_entity: "sensor.garage_fahrzeugtyp",
types: [
{ state: "van", vehicle: "pack:nextfloor.fahrzeuge:van" },
{ state: "suv", vehicle: "pack:nextfloor.fahrzeuge:ev_suv" },
],
},
{ ...item("parking", 16.2, 2.7, 2.6, 5.2, 0.02, 90), entity: "device_tracker.zweitwagen", vehicle: "pack:nextfloor.fahrzeuge:small_car" },
];
// a partition through half of the guest room (a free-standing wall)
// a half-height wall between the kids' room and the office (edge 1 of the kids' room)
DEMO_BUILDING.floors[1].rooms.find((r) => r.id === "kind").wall_heights = [null, 1.0, null, null];
DEMO_BUILDING.floors[1].walls = [{ id: "wall_demo", a: [8, 8], b: [8, 6], thickness: null, height: 1.1 }];
DEMO_BUILDING.floors[0].walls = [{ id: "wall_garage", a: [10, 1.1], b: [12.6, 1.1], thickness: null, height: null }];
DEMO_BUILDING.floors[0].openings.push(hole("door", "garage", 0, 1.2, 0.9, { wall: "wall_garage" }));
DEMO_BUILDING.floors[1].furniture = [
item("bed", 1.0, 1.4, 1.0, 2.05, 0.8, 90),
item("desk", 2.8, 3.8, 1.2, 0.6, 0.75, 180),
item("rug", 2.2, 2.6, 1.6, 1.2, 0.01),
{ ...item("desk", 8.4, 0.36, 1.6, 0.7, 0.75), pictures: [{ entity: "camera.wohnzimmer", state: "*", image: "camera:camera.wohnzimmer" }] },
item("chair", 8.4, 1.1, 0.46, 0.5, 0.9, 180),
item("shelf", 9.8, 2.1, 1.2, 0.35, 1.9, 90),
{ ...item("pack:nextfloor.kino:media_wall", 5.9, 0.3, 3.0, 0.45, 2.2), pictures: [{ entity: "media_player.fernseher", attribute: "app_name", state: "netflix", image: "pic_demo" }] },
item("sofa", 5.4, 3.6, 1.9, 0.85, 0.8, 180),
item("bed", 5.0, 6.9, 1.4, 2.0, 0.85, 180),
item("wardrobe", 3.72, 5.4, 1.4, 0.6, 2.1, 270),
item("bathtub", 0.45, 6.1, 1.7, 0.75, 0.58, 90),
item("washbasin", 2.1, 4.5, 0.6, 0.46, 0.85),
];
// Invented garden and roof.
const area = (id, type, x0, z0, x1, z1) => ({ id, type, points: [[x0, z0], [x1, z0], [x1, z1], [x0, z1]] });
DEMO_BUILDING.floors[0].outdoor = [
area("a1", "lawn", -3, -8, 17, -0.3),
area("a2", "lawn", -3, 9.5, 6.5, 14),
area("a3", "terrace", 1.5, -2.8, 6.2, -0.3),
area("a4", "pool", 8.5, -6.5, 12, -3.5),
area("a5", "path", 7.0, 9.5, 8.2, 14),
area("a6", "driveway", 13.9, 0.8, 18.5, 4.6),
area("a7", "hedge", -3.5, -8.5, -2.9, 14),
area("a8", "bed", 1.5, 10.2, 5.5, 11.2),
area("a9", "fence", -4, -9, 19, 14.5),
// a wild patch cut out of the front lawn, a pergola with bracing on the terrace side, the driveway falls to the street
{ ...area("a10", "wild", 9.5, -2.6, 12.2, -1.0), cut: true },
{ ...area("a11", "pergola", 13.4, -3.6, 16.2, -0.9), height: 2.3, bracing: true },
];
DEMO_BUILDING.floors[0].outdoor[5] = { ...DEMO_BUILDING.floors[0].outdoor[5], slope: 0.35, slope_dir: "x" };
// meter, solar inverter, home battery and wallbox on the back wall of the garage
DEMO_BUILDING.floors[0].furniture.push(
{ ...item("meter", 13.75, 0.11, 0.55, 0.21, 1.1), power: "sensor.netz_leistung" },
{ ...item("inverter", 13.0, 0.11, 0.5, 0.2, 0.65), id: "inv_main", power: "sensor.pv_leistung" },
// a balcony plant of its own: a small inverter with its field on the north face
{ ...item("inverter", 13.6, 0.11, 0.3, 0.15, 0.4), id: "inv_balkon", name: "Balkonkraftwerk", power: "sensor.balkon_leistung" },
{ ...item("home_battery", 12.3, 0.14, 0.6, 0.25, 1.1), power: "sensor.akku_leistung", soc: "sensor.akku_ladestand" },
item("wallbox", 10.6, 0.09, 0.3, 0.15, 0.42),
);
DEMO_BUILDING.settings = {
...DEMO_BUILDING.settings,
north: 0,
favorites: ["scene.wohnzimmer_film", "scene.wohnzimmer_lesen", "script.gute_nacht"],
buttons: [
{ id: "b1", label: "Rollos", icon: "window-shutter", action: "fire_dom_event", data: { browser_mod: { service: "browser_mod.popup", data: { title: "Rollos" } } } },
{ id: "b2", label: "Energie", icon: "lightning-bolt", action: "navigate", target: "/energy" },
],
// a solar field of 2 × 7 modules on the south side of the roof
roof: { type: "gable", pitch: 35, overhang: 0.4,
solar: [
{ id: "pv_sued", face: "main:b", u: 1.4, v: 0.75, rows: 2, cols: 7, portrait: true, string: "str_main" },
{ id: "pv_balkon", face: "main:a", u: 1.4, v: 0.75, rows: 1, cols: 2, portrait: true, string: "str_balkon" },
],
strings: [
{ id: "str_main", name: "Strang Süd", entity: null, inverter: "inv_main" },
{ id: "str_balkon", name: "Balkon", entity: null, inverter: "inv_balkon" },
],
// a roof window beside it: open, with the blind half down
windows: [{ id: "dachfenster", face: "main:b", u: 10.0, v: 1.0, contact: "binary_sensor.schlafzimmer_fenster", cover: "cover.kueche" }],
},
};
// an invented furniture pack (the preview does not check signatures)
export const DEMO_PACK = {
format: "nfpack",
version: 1,
id: "demo.pack",
name: "Demo-Pack",
publisher: "Demo",
items: [
{
id: "cube_seat",
name: { de: "Sitzwürfel", en: "Seat cube" },
size: [0.45, 0.45, 0.45],
parts: [
{ shape: "box", x: 0, z: 0, w: 1, d: 1, y: 0, h: 0.9, color: "fabric", edges: true },
{ shape: "box", x: 0, z: 0, w: 0.9, d: 0.9, y: 0.9, h: 0.1, color: "cushion" },
],
},
],
};
+499
View File
@@ -0,0 +1,499 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8" />
<!-- like Home Assistant's own page: no Referer to other sites unless a request asks for one -->
<meta name="referrer" content="same-origin" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>NextFloor – Vorschau</title>
<style>
/* Like HA: the panel's parent has no explicit height, the panel sizes itself. */
body {
margin: 0;
background: var(--primary-background-color, #111111);
color: var(--primary-text-color, #e1e1e1);
}
</style>
</head>
<body>
<nextfloor-panel></nextfloor-panel>
<script src="./basic-types.js"></script>
<script src="./pack-ids.js"></script>
<script src="./pack-names.js"></script>
<script type="module">
// Mock of the Home Assistant frontend object with invented demo data.
import { DEMO_AREAS, DEMO_BUILDING, DEMO_FLOORS, DEMO_PACK, DEMO_ENTITIES, DEMO_STATES, DEMO_PICTURES } from "./demo-data.js";
const uploadedMeshes = new Map();
const params = new URLSearchParams(location.search);
// Home Assistant's default themes, so the preview shows how NextFloor follows them (?ha=light, dark otherwise)
const light = params.get("ha") === "light";
const haTheme = light
? { "--primary-color": "#03a9f4", "--text-primary-color": "#ffffff", "--primary-text-color": "#212121", "--secondary-text-color": "#727272", "--card-background-color": "#ffffff", "--primary-background-color": "#fafafa", "--secondary-background-color": "#e5e5e5", "--divider-color": "rgba(0, 0, 0, 0.12)", "--ha-card-border-radius": "12px", "--state-light-active-color": "#ffc107", "--error-color": "#db4437", "--success-color": "#43a047", "--info-color": "#039be5", "--primary-font-family": "Roboto, 'Noto Sans', sans-serif" }
: { "--primary-color": "#03a9f4", "--text-primary-color": "#ffffff", "--primary-text-color": "#e1e1e1", "--secondary-text-color": "#9b9b9b", "--card-background-color": "#1c1c1c", "--primary-background-color": "#111111", "--secondary-background-color": "#1a1a1a", "--divider-color": "rgba(225, 225, 225, 0.12)", "--ha-card-border-radius": "12px", "--state-light-active-color": "#ffc107", "--error-color": "#db4437", "--success-color": "#43a047", "--info-color": "#039be5", "--primary-font-family": "Roboto, 'Noto Sans', sans-serif" };
for (const [k, v] of Object.entries(haTheme)) document.documentElement.style.setProperty(k, v);
document.documentElement.style.colorScheme = light ? "light" : "dark";
// the power flow lines are on with ?flows (and off without, whatever an earlier page stored)
try {
localStorage.setItem("nextfloor.flows", params.has("flows") ? "1" : "0");
} catch {}
let building = params.has("empty") ? { version: 1, floors: [], settings: { wall_exterior: 0.24, wall_interior: 0.12, grid: 0.05 } } : DEMO_BUILDING;
// ?state=<url of a plan as JSON> starts from that plan (the tutorial recorder hands the end of one episode to the next)
if (params.has("state")) building = await (await fetch(params.get("state"))).json();
// ?shared: a plan shared as a file from NextFloor (a small page that embeds this one) arrives by message, with its own packs
let sharedPacks = [];
if (params.has("shared")) {
const shared = await new Promise((resolve) => {
addEventListener("message", (e) => {
if (e.data && e.data.type === "nextfloor-share" && e.data.building && Array.isArray(e.data.building.floors)) resolve(e.data);
});
(window.parent !== window ? window.parent : window.opener)?.postMessage({ type: "nextfloor-share-ready" }, "*");
});
building = shared.building;
sharedPacks = Array.isArray(shared.packs) ? shared.packs : [];
}
window.nfDemoState = () => structuredClone(building);
// ?map and ?north=180 switch the real map and the compass on for a look (the demo ships with both off)
if (params.has("forecast")) {
building = structuredClone(building);
building.settings.forecast = { days: 5, corner: params.get("forecast") === "left" ? "top_left" : "top_right" };
}
// ?chimney: one chimney of each shape on the first roof face, for a look
if (params.has("chimney")) {
building = structuredClone(building);
const roof = building.settings.roof;
const side = params.get("chimney") === "b" ? "b" : "a";
const face = roof.type === "custom" ? `${roof.sections[0].id}:${side}` : `main:${side}`;
roof.chimneys = ["brick", "round", "wide", "steel"].map((shape, i) => ({ id: `c${i}`, face, u: 1 + i * 2, v: 2.5, shape }));
}
if (params.has("map") || params.has("north")) {
building = structuredClone(building);
if (params.has("north")) building.settings.north = Number(params.get("north")) || 0;
if (params.has("map")) building.settings.map = { on: true, lat: 50.1109, lon: 8.6821, x: 5, z: 4, opacity: 0.6, zoom: 19, url: null };
}
// development view: a whole pack laid out in rows on a plain floor (?pack=nextfloor.ikea, or ?cars for the Teslas)
const showPack = params.get("pack") || (params.has("cars") ? "nextfloor.fahrzeuge" : null);
if (showPack) {
const pack = await (await fetch(`../custom_components/nextfloor/packs/${showPack}.json`)).json();
const prefix = params.get("cars") || (params.has("cars") ? "tesla" : params.get("only") || "");
let items = pack.items.filter((i) => i.id.startsWith(prefix));
// &colors: one of every colour of every item
if (params.has("colors")) items = items.flatMap((it) => (it.colors ?? [null]).map((c, k) => ({ ...it, variant: k === 0 ? null : c?.id ?? null })));
const eg = structuredClone(DEMO_BUILDING.floors[0]);
const rowWidth = Number(params.get("row")) || 30;
let x = 0.6, z = 0.6, rowDepth = 0, maxX = 0;
const furniture = [];
items.forEach((it, i) => {
const [w, d, h] = it.size;
if (x + w > rowWidth && x > 0.6) { x = 0.6; z += rowDepth + 0.8; rowDepth = 0; }
furniture.push({ id: `show${i}`, type: `pack:${pack.id}:${it.id}`, x: x + w / 2, z: z + d / 2, w, d, h, rotation: 0, variant: it.variant ?? null });
x += w + 0.7; rowDepth = Math.max(rowDepth, d); maxX = Math.max(maxX, x);
});
const width = maxX + 0.2, depth = z + rowDepth + 0.6;
eg.rooms = [{ ...eg.rooms[0], id: "room_show", name: "Showcase", area_id: null, points: [[0, 0], [width, 0], [width, depth], [0, depth]] }];
eg.openings = [];
eg.placements = [];
eg.outdoor = [];
eg.walls = [];
eg.furniture = furniture;
window.nfShowcase = { cx: width / 2, cz: depth / 2, width, depth };
building = { ...DEMO_BUILDING, floors: [eg], settings: { ...DEMO_BUILDING.settings, roof: { type: "none" } } };
}
// model showcase (?showcase): every model of NextFloor, a page of ten at a time, to look at them live
if (params.has("showcase")) {
const lang = params.get("lang") === "en" ? "en" : "de";
const text = { de: { title: "Alle Modelle", back: "Zur Demo", prev: "‹ zurück", next: "weiter ›", set: "Gruppe", order: "Reihenfolge im Raum: von links nach rechts, vorn nach hinten" }, en: { title: "All models", back: "Back to the demo", prev: "‹ previous", next: "next ›", set: "Group", order: "Order in the room: left to right, front to back" } }[lang];
const names = (n) => n?.[lang] ?? n?.en ?? Object.values(n ?? {})[0] ?? "";
const sets = [
...window.BASIC_TYPES.map((g) => ({ id: `basic:${g.id}`, label: `${names(g.name)}`, items: g.items.map((i) => ({ type: i.type, size: i.size, name: names(i.name) })) })),
];
for (const id of window.PACK_IDS) {
try {
const pack = await (await fetch(`../custom_components/nextfloor/packs/${id}.json`)).json();
sets.push({ id: `pack:${id.replace("nextfloor.", "")}`, label: lang === "en" ? (window.PACK_EN?.[pack.id] ?? pack.name) : pack.name, items: pack.items.map((i) => ({ type: `pack:${pack.id}:${i.id}`, size: i.size, name: names(i.name) })) });
} catch {}
}
const current = sets.find((x) => x.id === params.get("set")) ?? sets[0];
const perPage = 10;
const pages = Math.max(1, Math.ceil(current.items.length / perPage));
const page = Math.min(pages, Math.max(1, Number(params.get("page")) || 1));
const shown = current.items.slice((page - 1) * perPage, page * perPage);
const eg = structuredClone(DEMO_BUILDING.floors[0]);
// the walls are cut low in this view; tall models (trees, wardrobes) must still show whole
eg.cut_height = 12;
eg.height = 12;
const rowWidth = 8;
let x = 0.6, z = 0.6, rowDepth = 0, maxX = 0;
const furniture = [];
shown.forEach((it, i) => {
const [w, d, h] = it.size;
if (x + w > rowWidth && x > 0.6) { x = 0.6; z += rowDepth + 0.8; rowDepth = 0; }
furniture.push({ id: `show${i}`, type: it.type, x: x + w / 2, z: z + d / 2, w, d, h, rotation: 0, variant: null });
x += w + 0.7; rowDepth = Math.max(rowDepth, d); maxX = Math.max(maxX, x);
});
const width = Math.max(maxX + 0.2, 4), depth = z + rowDepth + 0.6;
eg.rooms = [{ ...eg.rooms[0], id: "room_show", name: text.title, area_id: null, points: [[0, 0], [width, 0], [width, depth], [0, depth]], wall_heights: [0, 0, 0, 0], wall_thickness: undefined, wall_splits: undefined }];
for (const key of ["openings", "placements", "outdoor", "walls"]) eg[key] = [];
eg.furniture = furniture;
building = { ...DEMO_BUILDING, floors: [eg], settings: { ...DEMO_BUILDING.settings, roof: { type: "none" } } };
const go = (set, n) => { const q = new URLSearchParams(location.search); q.set("set", set); q.set("page", String(n)); location.search = q.toString(); };
const bar = document.createElement("div");
bar.style.cssText = "position:fixed;left:12px;bottom:12px;z-index:50;max-width:min(360px,calc(100vw - 24px));padding:12px 14px;border-radius:14px;background:rgba(20,22,28,.92);color:#e8eaf0;font:13px Roboto,sans-serif;box-shadow:0 6px 24px rgba(0,0,0,.45)";
const select = Object.assign(document.createElement("select"), { innerHTML: sets.map((x) => `<option value="${x.id}" ${x === current ? "selected" : ""}>${x.label} (${x.items.length})</option>`).join("") });
select.style.cssText = "width:100%;margin:6px 0;padding:6px;border-radius:8px;background:#2a2d36;color:inherit;border:1px solid #444";
select.onchange = () => go(select.value, 1);
bar.innerHTML = `<b style="font-size:15px">${text.title}</b> <span style="opacity:.6">· ${text.set}</span>`;
bar.append(select);
const list = Object.assign(document.createElement("ol"), { innerHTML: shown.map((it) => `<li>${it.name}</li>`).join("") });
list.style.cssText = "margin:6px 0 8px 18px;padding:0;columns:2;line-height:1.5";
const note = Object.assign(document.createElement("div"), { textContent: text.order });
note.style.cssText = "opacity:.55;font-size:11px;margin-bottom:8px";
const nav = document.createElement("div");
nav.style.cssText = "display:flex;gap:8px;align-items:center";
const button = (label, disabled, onClick) => Object.assign(document.createElement("button"), { textContent: label, disabled, onclick: onClick, style: "padding:6px 12px;border-radius:8px;border:0;background:#03a9f4;color:#fff;cursor:pointer;opacity:" + (disabled ? ".35" : "1") });
const link = Object.assign(document.createElement("a"), { textContent: text.back, href: `?lang=${lang}`, style: "margin-left:auto;color:#7fd0ff" });
nav.append(button(text.prev, page <= 1, () => go(current.id, page - 1)), Object.assign(document.createElement("span"), { textContent: `${page} / ${pages}` }), button(text.next, page >= pages, () => go(current.id, page + 1)), link);
bar.append(list, note, nav);
// look into the room from above: the floor opened, the walls cut away
const open = setInterval(() => {
const panel = document.querySelector("nextfloor-panel");
if (!panel?.data?.building) return;
clearInterval(open);
panel._floorId = eg.id;
panel._wallMode = "cut";
}, 200);
addEventListener("DOMContentLoaded", () => document.body.append(bar));
if (document.readyState !== "loading") document.body.append(bar);
}
if (!params.has("showcase") && !params.has("pack") && !params.has("cars") && !params.has("noshowcase")) {
const link = Object.assign(document.createElement("a"), { href: `?showcase&lang=${params.get("lang") === "en" ? "en" : "de"}`, textContent: params.get("lang") === "en" ? "▦ All models" : "▦ Alle Modelle ansehen" });
link.style.cssText = "position:fixed;right:12px;bottom:12px;z-index:40;padding:8px 14px;border-radius:999px;background:rgba(20,22,28,.9);color:#7fd0ff;font:13px Roboto,sans-serif;text-decoration:none;box-shadow:0 4px 16px rgba(0,0,0,.4)";
document.body.append(link);
}
let revision = 1;
const images = { ...DEMO_PICTURES };
const listeners = new Set();
// invented restore points
let history = [{ id: "s0", revision: 0, saved_at: Date.now() / 1000 - 3600, building: structuredClone(building) }];
// furniture packs: the invented demo pack and the packs that come with NextFloor
let importedPacks = null;
// one shared load: parallel callers must not see the list half filled
let packsLoad = null;
function previewPacks() {
packsLoad ??= (async () => {
const list = [DEMO_PACK, ...sharedPacks];
for (const id of window.PACK_IDS) {
try {
const res = await fetch(`../custom_components/nextfloor/packs/${id}.json`);
if (res.ok) list.push({ builtin: true, ...(await res.json()) });
} catch {
// served without the packs: the demo pack alone
}
}
importedPacks = list;
return list;
})();
return packsLoad.then(() => importedPacks);
}
const hass = {
language: params.get("lang") || "de",
config: { latitude: 50.1109, longitude: 8.6821 },
themes: { darkMode: !light },
user: { is_admin: !params.has("user"), name: "Demo" },
areas: DEMO_AREAS,
floors: DEMO_FLOORS,
entities: DEMO_ENTITIES,
devices: {},
states: structuredClone(DEMO_STATES),
connection: {
async subscribeMessage(cb) {
listeners.add(cb);
return async () => listeners.delete(cb);
},
},
async callService(domain, service, data) {
// enough behaviour to see the effect of the room panel and of taps in 3D
const states = { ...current.states };
for (const id of [].concat(data?.entity_id ?? [])) {
const st = states[id];
if (!st) continue;
const next = { ...st, attributes: { ...st.attributes } };
const a = next.attributes;
const setOn = (on) => {
next.state = on ? "on" : "off";
if (domain === "light" && on && a.brightness === undefined) a.brightness = 200;
if (domain === "light" && !on) delete a.brightness;
};
if (service === "toggle") setOn(st.state !== "on");
else if (service === "turn_off") setOn(false);
else if (service === "turn_on" && domain === "light") {
setOn(true);
if (data.brightness_pct !== undefined) a.brightness = Math.round((data.brightness_pct / 100) * 255);
if (data.color_temp_kelvin !== undefined) Object.assign(a, { color_temp_kelvin: data.color_temp_kelvin, color_mode: "color_temp" });
if (data.rgb_color) Object.assign(a, { rgb_color: data.rgb_color, color_mode: "hs" });
} else if (service === "open_cover") {
next.state = "open";
a.current_position = 100;
} else if (service === "close_cover") {
next.state = "closed";
a.current_position = 0;
} else if (service === "set_cover_position") {
a.current_position = data.position;
next.state = data.position > 0 ? "open" : "closed";
} else if (service === "set_temperature") a.temperature = data.temperature;
else if (service === "set_hvac_mode") next.state = data.hvac_mode;
else if (service === "media_play_pause") next.state = st.state === "playing" ? "paused" : "playing";
else if (service === "volume_set") a.volume_level = data.volume_level;
states[id] = next;
}
current = { ...current, states };
if (window.nfCard) window.nfCard.hass = current;
else if (window.nfPanel) window.nfPanel.hass = current;
},
// a model the owner uploaded: only when the page is told where to read it from (?meshdir=)
async fetchWithAuth(path, init = {}) {
const id = /mesh\/([a-z0-9_%]+)/.exec(path)?.[1];
// models uploaded in this page stay in memory, as on a real Home Assistant they stay in its configuration folder
if (id && init.method === "POST") return uploadedMeshes.set(id, init.body) && new Response(null, { status: 201 });
if (id && init.method === "DELETE") return uploadedMeshes.delete(id) && new Response(null, { status: 204 });
if (id && uploadedMeshes.has(id)) return new Response(uploadedMeshes.get(id), { status: 200 });
const dir = params.get("meshdir");
return id && dir ? fetch(`${dir}/${id}.glb`) : new Response(null, { status: 404 });
},
async callWS(msg) {
switch (msg.type) {
case "call_service": {
// the weather forecast card (?forecast): five invented days
if (msg.domain !== "weather" || msg.service !== "get_forecasts") return { response: {} };
const id = msg.target.entity_id;
const kinds = ["sunny", "partlycloudy", "rainy", "cloudy", "snowy"];
const forecast = kinds.map((condition, i) => ({ datetime: new Date(Date.now() + i * 86400000).toISOString(), condition, temperature: 12 - i * 2, templow: 4 - i, precipitation: condition === "rainy" ? 4.5 : 0, precipitation_probability: condition === "snowy" ? 60 : 0 }));
return { response: { [id]: { forecast } } };
}
case "nextfloor/building/get": {
// the online demo has no private packs: their items would stand as grey boxes, so leave them out
const packs = await previewPacks();
const known = new Set(packs.flatMap((p) => p.items.map((it) => `pack:${p.id}:${it.id}`)));
const shown = structuredClone(building);
for (const f of shown.floors) f.furniture = f.furniture.filter((m) => !m.type.startsWith("pack:") || known.has(m.type));
return { building: shown, revision };
}
case "nextfloor/building/save":
// ?savefail simulates a backend that still runs an older version
if (params.has("savefail")) throw { code: "invalid_format", message: "extra keys not allowed @ data['building']['floors'][0]['furniture'][0]['entity']" };
building = structuredClone(msg.building);
revision += 1;
for (const cb of listeners) cb({ revision });
return { revision };
case "history/history_during_period": {
// invented recorder history for the time travel: every light and door changes a few times over the span
const from = Date.parse(msg.start_time) / 1000;
const to = Date.parse(msg.end_time) / 1000;
const out = {};
(msg.entity_ids ?? []).forEach((id, k) => {
const st = this.states[id];
if (!st) return;
if (id.startsWith("sensor.") && Number.isFinite(Number(st.state))) {
// a number over the day: solar as a bell over noon, everything else wandering around its value
const rows = [];
for (let i = 0; i <= 96; i++) {
const t = from + ((to - from) * i) / 96;
const hour = new Date(t * 1000).getHours() + new Date(t * 1000).getMinutes() / 60;
const sun = Math.max(0, Math.sin(((hour - 6) / 14) * Math.PI));
const base = Number(st.state);
const v = /pv|solar/.test(id) ? Math.round(5200 * sun * (0.8 + 0.2 * Math.sin(i))) : Math.round(base * (0.6 + 0.4 * Math.abs(Math.sin(i / 7 + k))));
rows.push({ s: String(v), lu: t });
}
out[id] = rows;
return;
}
const rows = [{ s: id.startsWith("light.") || id.startsWith("binary_sensor.") ? "off" : st.state, a: st.attributes, lu: from }];
const steps = 6 + (k % 5);
for (let i = 1; i <= steps; i++) rows.push({ s: i % 2 ? (id.startsWith("cover.") ? "closed" : "on") : id.startsWith("cover.") ? "open" : "off", lu: from + ((to - from) * (i + (k % 3) / 3)) / (steps + 1) });
out[id] = rows;
});
return out;
}
case "nextfloor/history/list":
return { snapshots: history.map(({ building: b, ...rest }) => ({ ...rest, floors: b.floors.length, rooms: b.floors.reduce((n, f) => n + f.rooms.length, 0), furniture: b.floors.reduce((n, f) => n + f.furniture.length, 0) })).reverse() };
case "nextfloor/history/snapshot": {
const id = `s${history.length + 1}`;
history.push({ id, revision, saved_at: Date.now() / 1000, building: structuredClone(building), ...(msg.name ? { name: msg.name } : {}) });
return { id };
}
case "nextfloor/history/get": {
const snap = history.find((h) => h.id === msg.snapshot_id);
if (!snap) throw { code: "not_found", message: "Restore point not found" };
return { building: structuredClone(snap.building) };
}
case "nextfloor/history/delete":
history = history.filter((h) => h.id !== msg.snapshot_id);
return null;
case "nextfloor/history/restore": {
const snap = history.find((h) => h.id === msg.snapshot_id);
building = structuredClone(snap.building);
revision += 1;
for (const cb of listeners) cb({ revision });
return { revision };
}
case "nextfloor/image/get":
if (!images[msg.image_id]) throw { code: "not_found", message: "Image not found" };
return { data: images[msg.image_id] };
case "nextfloor/image/set":
images[msg.image_id] = msg.data;
return null;
case "nextfloor/packs/list":
return { packs: await previewPacks() };
case "nextfloor/packs/import": {
// plain JSON (or a wrapped {"payload": …} file), like the integration
let data = JSON.parse(msg.pack);
if (data.payload) data = data.payload;
if (data.format !== "nfpack") throw { code: "not_a_pack", message: "not a pack" };
importedPacks = [...importedPacks.filter((p) => p.id !== data.id), data];
return { id: data.id, name: data.name, publisher: data.publisher, licensee: null, items: data.items.length };
}
case "nextfloor/packs/remove":
importedPacks = importedPacks.filter((p) => p.id !== msg.pack_id);
return null;
case "recorder/statistics_during_period": {
// daily means (the week on the house card, a room's use this month): solar by the season, devices around their power now
if (msg.period === "day") {
const rows = (id) => {
const out = [];
const day = new Date(msg.start_time);
day.setHours(0, 0, 0, 0);
for (let k = 0; day.getTime() < Date.now(); k++, day.setDate(day.getDate() + 1)) {
const now = Math.max(0, Number(hass.states[id]?.state) || 0);
const mean = /pv|solar|balkon/.test(id) ? 600 + 250 * Math.sin(k) : Math.max(20, (now || 120) * (0.5 + 0.3 * Math.abs(Math.sin(k + id.length))));
out.push({ start: day.getTime(), end: day.getTime() + 86400000, mean: Math.round(mean) });
}
return out;
};
return Object.fromEntries((msg.statistic_ids ?? []).map((id) => [id, rows(id)]));
}
// today's solar curve: a sunny day, five-minute means from midnight up to now
const midnight = new Date();
midnight.setHours(0, 0, 0, 0);
const slots = Math.floor((Date.now() - midnight.getTime()) / 300000) + 1;
const peak = Number(hass.states["sensor.pv_leistung"]?.state) > 2000 ? 7100 : 3400;
const curve = Array.from({ length: slots }, (_, i) => {
const h = (i * 5) / 60;
const sun = Math.max(0, Math.sin((Math.PI * (h - 6.2)) / 13.2));
return { start: midnight.getTime() + i * 300000, end: midnight.getTime() + (i + 1) * 300000, mean: Math.round(peak * Math.pow(sun, 1.6) * (0.9 + 0.1 * Math.sin(i * 0.7))) };
});
return Object.fromEntries((msg.statistic_ids ?? []).map((id) => [id, curve]));
}
case "history/history_during_period": {
// invented motion of the last half hour: hall, kitchen, then the living-room camera
const now = Date.now() / 1000;
const on = (entity, ...minutesAgo) => [entity, minutesAgo.flatMap((m) => [{ s: "on", lu: now - m * 60 }, { s: "off", lu: now - m * 60 + 40 }])];
return Object.fromEntries([
on("binary_sensor.flur_bewegung", 26, 12),
on("binary_sensor.kueche_praesenz", 22, 9),
on("binary_sensor.wohnzimmer_kamera_bewegung", 17, 3),
on("binary_sensor.garage_auto", 28),
]);
}
default:
throw { code: "unknown_command", message: msg.type };
}
},
};
if (params.has("pv")) {
// ?pv=5400 sets the solar power (W) of the demo plant, e.g. a sunny noon
hass.states["sensor.pv_leistung"] = { ...hass.states["sensor.pv_leistung"], state: params.get("pv") };
}
if (params.has("weather")) {
// ?weather=pouring|snowy|fog|lightning-rainy|cloudy… sets the demo weather
hass.states["weather.zuhause"].state = params.get("weather");
hass.states["weather.zuhause"].attributes = { ...hass.states["weather.zuhause"].attributes, cloud_coverage: 85, wind_speed: 25, wind_speed_unit: "km/h" };
}
if (params.has("alerts")) {
// ?alerts: smoke in the kitchen while it rains on open windows
hass.states["binary_sensor.kueche_rauch"].state = "on";
hass.states["weather.zuhause"].state = "rainy";
}
let current = hass;
// window.nfDemoSet(entity, state, attributes): changes what a real Home Assistant would report (the tutorial recorder uses it)
window.nfDemoSet = (id, state, attributes = {}) => {
const old = current.states[id] ?? { entity_id: id, attributes: {} };
current = { ...current, states: { ...current.states, [id]: { ...old, state: state ?? old.state, attributes: { ...old.attributes, ...attributes } } } };
if (window.nfCard) window.nfCard.hass = current;
else if (window.nfPanel) window.nfPanel.hass = current;
};
await import("../custom_components/nextfloor/frontend/nextfloor.js");
if (params.has("site")) {
// ?site: the public online demo says what it is and where to get NextFloor
const de = hass.language === "de";
// phones: short and at the top of the 3D area, clear of the toolbars at the bottom
const narrow = innerWidth < 700;
const bar = document.createElement("div");
bar.style.cssText =
(narrow ? "position:fixed;left:50%;top:244px;" : "position:fixed;left:50%;bottom:64px;") +
"transform:translateX(-50%);z-index:10;display:flex;gap:10px;align-items:center;flex-wrap:nowrap;white-space:nowrap;justify-content:center;max-width:calc(100vw - 32px);padding:8px 14px;border-radius:999px;background:rgba(7,11,20,.88);border:1px solid rgba(0,229,255,.45);color:#cfe9ff;font:13px/1.3 Figtree,Roboto,sans-serif;box-shadow:0 0 18px rgba(0,229,255,.25)";
const link = (href, text) => `<a href="${href}" target="_blank" rel="noopener" style="color:#00e5ff;font-weight:600;text-decoration:none">${text}</a>`;
// the install button stands out; GitHub, the manual and the language as plain links
const install = (text) =>
`<a href="https://github.com/therealMRBK/NextFloor#installation" target="_blank" rel="noopener" style="background:#00e5ff;color:#06101c;font-weight:700;text-decoration:none;padding:5px 12px;border-radius:999px">${text}</a>`;
const github = link("https://github.com/therealMRBK/NextFloor", "★ GitHub");
bar.innerHTML = de
? `<span>${narrow ? "Demo" : "Demo mit erfundenen Daten – probier alles aus"}</span>${install(narrow ? "Installieren" : "Jetzt installieren")}${github}${narrow ? "" : link("https://github.com/therealMRBK/NextFloor/blob/main/docs/anleitung.md", "Anleitung")}${link("?site&lang=en", narrow ? "EN" : "English")}`
: `<span>${narrow ? "Demo" : "Demo with invented data – try everything"}</span>${install(narrow ? "Install" : "Install now")}${github}${narrow ? "" : link("https://github.com/therealMRBK/NextFloor/blob/main/docs/manual.md", "Manual")}${link("?site&lang=de", narrow ? "DE" : "Deutsch")}`;
const close = document.createElement("button");
close.textContent = "×";
close.setAttribute("aria-label", de ? "Schließen" : "Close");
close.style.cssText = "background:none;border:0;color:#cfe9ff;font-size:16px;cursor:pointer;padding:0 2px";
close.onclick = () => bar.remove();
bar.append(close);
document.body.append(bar);
}
if (params.has("card")) {
// ?card: the dashboard card next to its visual editor (like Home Assistant's card dialog)
document.querySelector("nextfloor-panel").remove();
const CardClass = customElements.get("nextfloor-card");
const wrap = document.createElement("div");
wrap.style.cssText = "display:grid;grid-template-columns:420px 1fr;gap:24px;padding:24px;font-family:Figtree,Roboto,sans-serif;--primary-text-color:#e1e1e1;--secondary-text-color:#9b9b9b;--card-background-color:#1c1c1c;--primary-color:#03a9f4;--divider-color:rgba(225,225,225,.2)";
const editorBox = document.createElement("div");
editorBox.style.cssText = "background:#1c1c1c;border-radius:12px;padding:20px";
const editor = await CardClass.getConfigElement();
const card = document.createElement("nextfloor-card");
let config = {
type: "custom:nextfloor-card",
quality: "low",
floor: params.get("floor") || building.floors.find((f) => f.id === "eg")?.id || building.floors[0]?.id || "eg",
flows: false,
controls: ["walls", "temperature"],
fullscreen_button: true,
floor_thumbs: true,
...(params.get("stack") ? { floor_stack: params.get("stack") } : {}),
...(params.has("nopanel") ? { room_panel: false } : {}),
...(params.has("roombuttons") ? { room_buttons: true } : {}),
...(params.has("night") ? { night: "00:00-23:59" } : {}),
...(params.has("kiosk") ? { idle_return: 1, idle_orbit: true } : {}),
};
card.setConfig(config);
editor.setConfig(config);
editor.addEventListener("config-changed", (e) => {
config = e.detail.config;
card.setConfig(config);
editor.setConfig(config);
});
editor.hass = hass;
card.hass = hass;
editorBox.append(editor);
wrap.append(editorBox, card);
document.body.append(wrap);
window.nfCard = card;
} else {
const panel = document.querySelector("nextfloor-panel");
panel.hass = hass;
window.addEventListener("hass-more-info", (e) => console.log("more-info", e.detail.entityId));
panel.narrow = window.innerWidth < 870;
window.nfPanel = panel;
}
</script>
</body>
</html>
+2
View File
@@ -0,0 +1,2 @@
// generated by tools/build_packs.py
window.PACK_IDS = ["nextfloor.wohnen", "nextfloor.kino", "nextfloor.kueche", "nextfloor.bad", "nextfloor.schlafen", "nextfloor.technik", "nextfloor.energie", "nextfloor.garten", "nextfloor.fitness", "nextfloor.fahrzeuge", "nextfloor.ikea", "nextfloor.treppen", "nextfloor.ausbau", "nextfloor.werkstatt", "nextfloor.a_wohnzimmer", "nextfloor.a_schlafzimmer", "nextfloor.a_kueche", "nextfloor.a_bad", "nextfloor.a_kinderzimmer", "nextfloor.a_buero", "nextfloor.a_fitness", "nextfloor.a_haustiere", "nextfloor.a_garten", "nextfloor.a_kino", "nextfloor.a_smart", "nextfloor.a_haustechnik", "nextfloor.a_saison", "nextfloor.a_smart2", "nextfloor.a_haustechnik2", "nextfloor.a_wellness", "nextfloor.a_garten2", "nextfloor.a_kueche2", "nextfloor.a_fahrzeuge2", "nextfloor.a_aussenkueche", "nextfloor.a_werkstatt2", "nextfloor.a_japandi", "nextfloor.a_loft", "nextfloor.a_gruen", "nextfloor.a_musik", "nextfloor.a_bilder", "nextfloor.a_winter", "nextfloor.a_halloween"];
+2
View File
@@ -0,0 +1,2 @@
// generated by tools/make_showcase_types.mjs
window.PACK_EN = {"nextfloor.a_bad":"Bathroom","nextfloor.a_buero":"Office & gaming","nextfloor.a_fitness":"Fitness","nextfloor.a_garten":"Garden & patio","nextfloor.a_haustechnik":"Utility & building services","nextfloor.a_haustiere":"Pets","nextfloor.a_kinderzimmer":"Kids' room","nextfloor.a_kino":"Home cinema & hi-fi","nextfloor.a_kueche":"Kitchen","nextfloor.a_schlafzimmer":"Bedroom","nextfloor.a_smart":"Smart home & tech","nextfloor.a_wohnzimmer":"Living room","nextfloor.ausbau":"Architecture & fit-out","nextfloor.bad":"Bathroom Extras","nextfloor.energie":"Energy & Building Services","nextfloor.fahrzeuge":"Vehicles","nextfloor.fitness":"Fitness (older)","nextfloor.garten":"Garden & Terrace (older)","nextfloor.ikea":"IKEA sizes","nextfloor.kino":"Home Cinema & Gaming","nextfloor.kueche":"Kitchen Extras","nextfloor.schlafen":"Bedroom & Kids","nextfloor.technik":"Office & Homelab","nextfloor.treppen":"Stairs & railings","nextfloor.werkstatt":"Garage & workshop","nextfloor.wohnen":"Living & Pets"};