291 files
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
* tap_action: none # none | more-info
|
||||
*/
|
||||
|
||||
const VERSION = "1.14.0";
|
||||
const VERSION = "1.15.0";
|
||||
|
||||
const ANIMATED_TRANSITIONS = [
|
||||
"fade",
|
||||
@@ -87,6 +87,49 @@ const CAPTION_WEIGHT_MAP = {
|
||||
semibold: 600,
|
||||
bold: 700,
|
||||
};
|
||||
const WEATHER_DISPLAYS = ["condition_temperature", "icon_temperature", "temperature"];
|
||||
const WEATHER_ICON_STYLES = ["yr", "meteocons", "home_assistant"];
|
||||
// Icon files in www/weather (MIT, see the LICENSE there) per HA weather condition. Yr has
|
||||
// no wind or warning symbol, so those come from Meteocons.
|
||||
const WEATHER_ICON_SETS = {
|
||||
yr: {
|
||||
"clear-night": "yr/clearsky_night",
|
||||
cloudy: "yr/cloudy",
|
||||
exceptional: "meteocons/code-red",
|
||||
fog: "yr/fog",
|
||||
hail: "yr/heavysleet",
|
||||
lightning: "yr/lightrainandthunder",
|
||||
"lightning-rainy": "yr/rainandthunder",
|
||||
partlycloudy: "yr/partlycloudy_day",
|
||||
"partlycloudy-night": "yr/partlycloudy_night",
|
||||
pouring: "yr/heavyrain",
|
||||
rainy: "yr/rain",
|
||||
snowy: "yr/snow",
|
||||
"snowy-rainy": "yr/sleet",
|
||||
sunny: "yr/clearsky_day",
|
||||
windy: "meteocons/wind",
|
||||
"windy-variant": "meteocons/wind",
|
||||
},
|
||||
meteocons: {
|
||||
"clear-night": "meteocons/clear-night",
|
||||
cloudy: "meteocons/cloudy",
|
||||
exceptional: "meteocons/code-red",
|
||||
fog: "meteocons/fog",
|
||||
hail: "meteocons/hail",
|
||||
lightning: "meteocons/thunderstorms",
|
||||
"lightning-rainy": "meteocons/thunderstorms-rain",
|
||||
partlycloudy: "meteocons/partly-cloudy-day",
|
||||
"partlycloudy-night": "meteocons/partly-cloudy-night",
|
||||
pouring: "meteocons/extreme-rain",
|
||||
rainy: "meteocons/rain",
|
||||
snowy: "meteocons/snow",
|
||||
"snowy-rainy": "meteocons/sleet",
|
||||
sunny: "meteocons/clear-day",
|
||||
windy: "meteocons/wind",
|
||||
"windy-variant": "meteocons/wind",
|
||||
},
|
||||
};
|
||||
const WEATHER_ICON_PATH = "/album_slideshow_static/weather";
|
||||
const DATE_FORMAT_PRESETS = {
|
||||
full: { year: "numeric", month: "long", day: "numeric" },
|
||||
long: { year: "numeric", month: "long", day: "numeric" },
|
||||
@@ -216,8 +259,10 @@ class PhotoControls {
|
||||
async _navigate(service) {
|
||||
if (this._busy || !this._state.entryId) return false;
|
||||
const entryId = this._state.entryId;
|
||||
// Step from the slide on screen, which may be held behind the camera.
|
||||
const data = Number.isInteger(this._state.frameId) ? { frame_id: this._state.frameId } : {};
|
||||
this._onNavigate?.("start", entryId);
|
||||
const success = await this._run(service, {}, entryId);
|
||||
const success = await this._run(service, data, entryId);
|
||||
this._onNavigate?.(success ? "complete" : "failed", entryId);
|
||||
return success;
|
||||
}
|
||||
@@ -684,6 +729,8 @@ function createAlbumSlideshowCardClass(Base) {
|
||||
time_seconds: raw.time_seconds === true,
|
||||
weather_entity: typeof raw.weather_entity === "string" && /^(weather|sensor)\.[a-z0-9_]+$/.test(raw.weather_entity.trim())
|
||||
? raw.weather_entity.trim() : null,
|
||||
weather_display: WEATHER_DISPLAYS.includes(raw.weather_display) ? raw.weather_display : "condition_temperature",
|
||||
weather_icons: WEATHER_ICON_STYLES.includes(raw.weather_icons) ? raw.weather_icons : "yr",
|
||||
color,
|
||||
font_size: fontSize,
|
||||
font_weight: fontWeight,
|
||||
@@ -727,7 +774,9 @@ function createAlbumSlideshowCardClass(Base) {
|
||||
if (!this._rendered) return;
|
||||
this._maybeSwap();
|
||||
if (this._captionData && this._captionConfigs().some((cap) => cap.show.includes("weather") && cap.weather_entity &&
|
||||
(previous?.states?.[cap.weather_entity] !== hass.states?.[cap.weather_entity] || previous?.locale !== hass.locale))) {
|
||||
(previous?.states?.[cap.weather_entity] !== hass.states?.[cap.weather_entity] || previous?.locale !== hass.locale ||
|
||||
(cap.weather_display === "icon_temperature" &&
|
||||
previous?.states?.["sun.sun"]?.state !== hass.states?.["sun.sun"]?.state)))) {
|
||||
this._renderCaptions(this._captionData, false);
|
||||
}
|
||||
}
|
||||
@@ -868,6 +917,20 @@ function createAlbumSlideshowCardClass(Base) {
|
||||
0 1px 2px rgba(0, 0, 0, 0.9),
|
||||
0 1px 6px rgba(0, 0, 0, 0.55);
|
||||
}
|
||||
.cap-icon { display: inline-block; width: 1.8em; height: 1.8em; margin: 0 0.12em 0 -0.1em; vertical-align: middle; }
|
||||
.cap-icon svg { display: block; width: 100%; height: 100%; }
|
||||
.cap-shadow .cap-icon { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
|
||||
.cap-icon .sun { fill: var(--weather-icon-sun-color, #fdd93c); }
|
||||
.cap-icon .moon { fill: var(--weather-icon-moon-color, #fcf497); }
|
||||
.cap-icon .cloud-back { fill: var(--weather-icon-cloud-back-color, #d4d4d4); }
|
||||
.cap-icon .cloud-front { fill: var(--weather-icon-cloud-front-color, #f9f9f9); }
|
||||
.cap-icon .rain { fill: var(--weather-icon-rain-color, #30b3ff); }
|
||||
.cap-icon .snow {
|
||||
fill: var(--weather-icon-snow-color, #f9f9f9);
|
||||
stroke: var(--weather-icon-snow-stroke-color, #d4d4d4);
|
||||
stroke-width: 1;
|
||||
paint-order: stroke;
|
||||
}
|
||||
${this._transitionStyles()}
|
||||
</style>
|
||||
<ha-card part="card">
|
||||
@@ -1112,6 +1175,7 @@ function createAlbumSlideshowCardClass(Base) {
|
||||
this._photoControls?.update({
|
||||
entryId: attrs.entry_id,
|
||||
photoIds: this._displayedPhotoIds,
|
||||
frameId: this._displayedFrameId,
|
||||
orientation: this._photoOrientation,
|
||||
hiddenCount: attrs.hidden_photo_count,
|
||||
canUndo: attrs.undo_hide_available,
|
||||
@@ -1427,12 +1491,27 @@ function createAlbumSlideshowCardClass(Base) {
|
||||
? this._hass.formatEntityState(entity)
|
||||
: isWeather ? humanizeOption(entity.state.replace("partlycloudy", "partly cloudy"))
|
||||
: [entity.state, attributes.unit_of_measurement].filter(Boolean).join(" ");
|
||||
if (!isWeather || typeof attributes.temperature !== "number" || !Number.isFinite(attributes.temperature)) return state;
|
||||
const temperature = this._hass.formatEntityAttributeValue
|
||||
? this._hass.formatEntityAttributeValue(entity, "temperature")
|
||||
: [new Intl.NumberFormat(this._locale(), { maximumFractionDigits: 1 }).format(attributes.temperature),
|
||||
attributes.temperature_unit || this._hass.config?.unit_system?.temperature].filter(Boolean).join(" ");
|
||||
return `${state}, ${temperature}`;
|
||||
if (!isWeather) return state;
|
||||
let temperature = "";
|
||||
if (typeof attributes.temperature === "number" && Number.isFinite(attributes.temperature)) {
|
||||
temperature = this._hass.formatEntityAttributeValue
|
||||
? this._hass.formatEntityAttributeValue(entity, "temperature")
|
||||
: [new Intl.NumberFormat(this._locale(), { maximumFractionDigits: 1 }).format(attributes.temperature),
|
||||
attributes.temperature_unit || this._hass.config?.unit_system?.temperature].filter(Boolean).join(" ");
|
||||
}
|
||||
if (cap.weather_display === "temperature") return temperature;
|
||||
if (cap.weather_display === "icon_temperature") {
|
||||
const night = entity.state === "partlycloudy" && this._hass.states["sun.sun"]?.state === "below_horizon";
|
||||
if (cap.weather_icons === "home_assistant") {
|
||||
const svg = homeAssistantWeatherSvg(entity.state, night);
|
||||
if (svg) return { svg, label: state, text: temperature };
|
||||
} else {
|
||||
const icons = WEATHER_ICON_SETS[cap.weather_icons] || WEATHER_ICON_SETS.yr;
|
||||
const icon = icons[night ? "partlycloudy-night" : entity.state];
|
||||
if (icon) return { icon, label: state, text: temperature };
|
||||
}
|
||||
}
|
||||
return temperature ? `${state}, ${temperature}` : state;
|
||||
}
|
||||
|
||||
/** Build one positioned caption block. ``orientation`` is ``null`` for a
|
||||
@@ -1497,7 +1576,19 @@ function createAlbumSlideshowCardClass(Base) {
|
||||
for (const line of lines) {
|
||||
const el = document.createElement("div");
|
||||
el.className = "cap-line";
|
||||
el.textContent = line;
|
||||
if (typeof line === "string") {
|
||||
el.textContent = line;
|
||||
} else {
|
||||
const icon = document.createElement(line.svg ? "span" : "img");
|
||||
icon.className = "cap-icon";
|
||||
if (line.svg) {
|
||||
icon.innerHTML = line.svg;
|
||||
} else {
|
||||
icon.alt = line.label;
|
||||
icon.src = `${WEATHER_ICON_PATH}/${line.icon}.svg?v=${VERSION}`;
|
||||
}
|
||||
el.append(icon, line.text);
|
||||
}
|
||||
box.appendChild(el);
|
||||
}
|
||||
region._captionStack.appendChild(box);
|
||||
@@ -1739,6 +1830,18 @@ const CAPTION_WEIGHT_OPTIONS = [
|
||||
{ value: "bold", label: "Bold" },
|
||||
];
|
||||
|
||||
const WEATHER_DISPLAY_OPTIONS = [
|
||||
{ value: "condition_temperature", label: "Condition and temperature" },
|
||||
{ value: "icon_temperature", label: "Icon and temperature" },
|
||||
{ value: "temperature", label: "Temperature only" },
|
||||
];
|
||||
|
||||
const WEATHER_ICON_OPTIONS = [
|
||||
{ value: "yr", label: "Yr" },
|
||||
{ value: "meteocons", label: "Meteocons" },
|
||||
{ value: "home_assistant", label: "Home Assistant" },
|
||||
];
|
||||
|
||||
const CAPTION_DATE_FORMAT_OPTIONS = [
|
||||
{ value: "medium", label: "Medium (Aug 16, 2014)" },
|
||||
{ value: "full", label: "Full (August 16, 2014)" },
|
||||
@@ -1772,6 +1875,8 @@ const CAPTION_DEFAULTS = {
|
||||
date_format: "medium",
|
||||
time_format: "auto",
|
||||
time_seconds: false,
|
||||
weather_display: "condition_temperature",
|
||||
weather_icons: "yr",
|
||||
color: "#ffffff",
|
||||
font_size: "14px",
|
||||
font_weight: "medium",
|
||||
@@ -2197,6 +2302,8 @@ function createAlbumSlideshowCardEditorClass(Base) {
|
||||
caption_time_format: c.time_format || CAPTION_DEFAULTS.time_format,
|
||||
caption_time_seconds: c.time_seconds === true,
|
||||
caption_weather_entity: c.weather_entity || "",
|
||||
caption_weather_display: c.weather_display || CAPTION_DEFAULTS.weather_display,
|
||||
caption_weather_icons: c.weather_icons || CAPTION_DEFAULTS.weather_icons,
|
||||
caption_color: c.color || CAPTION_DEFAULTS.color,
|
||||
caption_font_size: c.font_size || CAPTION_DEFAULTS.font_size,
|
||||
caption_font_weight: c.font_weight || CAPTION_DEFAULTS.font_weight,
|
||||
@@ -2221,6 +2328,16 @@ function createAlbumSlideshowCardEditorClass(Base) {
|
||||
if (data.caption_show.includes("weather")) {
|
||||
schema.push({ name: "caption_weather_entity", required: true,
|
||||
selector: { entity: { filter: [{ domain: ["weather", "sensor"] }] } } });
|
||||
if (data.caption_weather_entity.startsWith("weather.")) {
|
||||
schema.push({ name: "caption_weather_display", selector: { select: {
|
||||
mode: "dropdown", options: WEATHER_DISPLAY_OPTIONS,
|
||||
} } });
|
||||
if (data.caption_weather_display === "icon_temperature") {
|
||||
schema.push({ name: "caption_weather_icons", selector: { select: {
|
||||
mode: "dropdown", options: WEATHER_ICON_OPTIONS,
|
||||
} } });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.caption_show.includes("date")) {
|
||||
schema.push({ name: "caption_date_format", selector: { select: {
|
||||
@@ -2305,7 +2422,7 @@ function createAlbumSlideshowCardEditorClass(Base) {
|
||||
if (!Array.isArray(show)) show = typeof show === "string" ? show.split(/[,\s]+/) : [];
|
||||
const caption = { show: [...new Set(show.filter((field) => CAPTION_FIELDS.includes(field)))] };
|
||||
if (data.caption_enabled === false) caption.enabled = false;
|
||||
for (const field of ["position", "date_format", "time_format", "color", "font_size", "font_weight"]) {
|
||||
for (const field of ["position", "date_format", "time_format", "weather_display", "weather_icons", "color", "font_size", "font_weight"]) {
|
||||
const value = String(data[`caption_${field}`] || CAPTION_DEFAULTS[field]).trim();
|
||||
if (value && value !== CAPTION_DEFAULTS[field]) caption[field] = value;
|
||||
}
|
||||
@@ -2561,6 +2678,8 @@ function createAlbumSlideshowCardEditorClass(Base) {
|
||||
caption_time_format: "Time format",
|
||||
caption_time_seconds: "Show seconds",
|
||||
caption_weather_entity: "Weather source",
|
||||
caption_weather_display: "Weather display",
|
||||
caption_weather_icons: "Weather icons",
|
||||
caption_color: "Text color",
|
||||
caption_font_size: "Font size",
|
||||
caption_font_weight: "Font weight",
|
||||
@@ -2883,6 +3002,58 @@ function createAlbumSlideshowCardEditorClass(Base) {
|
||||
};
|
||||
}
|
||||
|
||||
// Home Assistant's own weather icon shapes, adapted from the frontend's src/data/weather.ts
|
||||
// (Apache-2.0, see www/weather/LICENSE). Colors follow the --weather-icon-* theme variables.
|
||||
const HA_WEATHER_PATHS = {
|
||||
sun: "m 14.39303,8.4033507 c 0,3.3114723 -2.684145,5.9956173 -5.9956169,5.9956173 -3.3114716,0 -5.9956168,-2.684145 -5.9956168,-5.9956173 0,-3.311471 2.6841452,-5.995617 5.9956168,-5.995617 3.3114719,0 5.9956169,2.684146 5.9956169,5.995617",
|
||||
moon: "m 13.502891,11.382935 c -1.011285,1.859223 -2.976664,3.121381 -5.2405751,3.121381 -3.289929,0 -5.953329,-2.663833 -5.953329,-5.9537625 0,-2.263911 1.261724,-4.228856 3.120948,-5.240575 -0.452782,0.842738 -0.712753,1.806363 -0.712753,2.832381 0,3.289928 2.663833,5.9533275 5.9533291,5.9533275 1.026017,0 1.989641,-0.259969 2.83238,-0.712752",
|
||||
partly: "m14.981 4.2112c0 1.9244-1.56 3.4844-3.484 3.4844-1.9244 0-3.4844-1.56-3.4844-3.4844s1.56-3.484 3.4844-3.484c1.924 0 3.484 1.5596 3.484 3.484",
|
||||
cloudBack: "m3.8863 5.035c-0.54892 0.16898-1.04 0.46637-1.4372 0.8636-0.63077 0.63041-1.0206 1.4933-1.0206 2.455 0 1.9251 1.5589 3.4682 3.4837 3.4682h6.9688c1.9251 0 3.484-1.5981 3.484-3.5232 0-1.9251-1.5589-3.5232-3.484-3.5232h-1.0834c-0.25294-1.6916-1.6986-2.9083-3.4463-2.9083-1.7995 0-3.2805 1.4153-3.465 3.1679",
|
||||
cloudFront: "m4.1996 7.6995c-0.33902 0.10407-0.64276 0.28787-0.88794 0.5334-0.39017 0.38982-0.63147 0.92322-0.63147 1.5176 0 1.1896 0.96414 2.1431 2.1537 2.1431h4.3071c1.1896 0 2.153-0.98742 2.153-2.1777 0-1.1896-0.96344-2.1777-2.153-2.1777h-0.66992c-0.15593-1.0449-1.0499-1.7974-2.1297-1.7974-1.112 0-2.0274 0.87524-2.1417 1.9586",
|
||||
rain: [
|
||||
"m5.2852 14.734c-0.22401 0.24765-0.57115 0.2988-0.77505 0.11395-0.20391-0.1845-0.18732-0.53481 0.036689-0.78281 0.14817-0.16298 0.59126-0.32914 0.87559-0.42369 0.12453-0.04092 0.22684 0.05186 0.19791 0.17956-0.065617 0.2921-0.18732 0.74965-0.33514 0.91299",
|
||||
"m11.257 14.163c-0.22437 0.24765-0.57115 0.2988-0.77505 0.11395-0.2039-0.1845-0.18768-0.53481 0.03669-0.78281 0.14817-0.16298 0.59126-0.32914 0.8756-0.42369 0.12453-0.04092 0.22684 0.05186 0.19791 0.17956-0.06562 0.2921-0.18732 0.74965-0.33514 0.91299",
|
||||
"m8.432 15.878c-0.15452 0.17039-0.3937 0.20567-0.53446 0.07867-0.14041-0.12735-0.12876-0.36865 0.025753-0.53975 0.10195-0.11218 0.40711-0.22684 0.60325-0.29175 0.085725-0.02858 0.15628 0.03563 0.13652 0.12382-0.045508 0.20108-0.12912 0.51647-0.23107 0.629",
|
||||
"m7.9991 14.118c-0.19226 0.21237-0.49001 0.25612-0.66499 0.09737-0.17462-0.15804-0.16051-0.45861 0.03175-0.67098 0.12665-0.14005 0.50729-0.28293 0.75071-0.36336 0.10689-0.03563 0.19473 0.0441 0.17004 0.15346-0.056092 0.25082-0.16051 0.64347-0.28751 0.78352",
|
||||
],
|
||||
pouring: [
|
||||
"m10.648 16.448c-0.19226 0.21449-0.49001 0.25894-0.66499 0.09878-0.17498-0.16016-0.16087-0.4639 0.03175-0.67874 0.12665-0.14146 0.50694-0.2854 0.75071-0.36724 0.10689-0.03563 0.19473 0.0448 0.17004 0.15558-0.05645 0.25365-0.16051 0.65017-0.28751 0.79163",
|
||||
"m5.9383 16.658c-0.22437 0.25012-0.5715 0.30162-0.77505 0.11501-0.20391-0.18627-0.18768-0.54046 0.036689-0.79093 0.14817-0.1651 0.59126-0.33267 0.87559-0.42827 0.12418-0.04127 0.22648 0.05221 0.19791 0.18168-0.065617 0.29528-0.18732 0.75741-0.33514 0.92251",
|
||||
],
|
||||
wind: [
|
||||
"m 13.59616,15.30968 c 0,0 -0.09137,-0.0071 -0.250472,-0.0187 -0.158045,-0.01235 -0.381353,-0.02893 -0.64382,-0.05715 -0.262466,-0.02716 -0.564444,-0.06385 -0.877358,-0.124531 -0.156986,-0.03034 -0.315383,-0.06844 -0.473781,-0.111478 -0.157691,-0.04551 -0.313266,-0.09842 -0.463902,-0.161219 l -0.267406,-0.0949 c -0.09984,-0.02646 -0.205669,-0.04904 -0.305153,-0.06738 -0.193322,-0.02716 -0.3838218,-0.03316 -0.5640912,-0.02011 -0.3626556,0.02611 -0.6847417,0.119239 -0.94615,0.226483 -0.2617611,0.108656 -0.4642556,0.230364 -0.600075,0.324203 -0.1358195,0.09419 -0.2049639,0.160514 -0.2049639,0.160514 0,0 0.089958,-0.01623 0.24765,-0.04445 0.1559278,-0.02575 0.3764139,-0.06174 0.6367639,-0.08714 0.2596444,-0.02646 0.5591527,-0.0441 0.8678333,-0.02328 0.076905,0.0035 0.1538111,0.01658 0.2321278,0.02293 0.077611,0.01058 0.1534581,0.02893 0.2314221,0.04022 0.07267,0.01834 0.1397,0.03986 0.213078,0.05644 l 0.238125,0.08925 c 0.09207,0.03281 0.183444,0.07055 0.275872,0.09878 0.09243,0.0261 0.185208,0.05327 0.277636,0.07161 0.184856,0.0388 0.367947,0.06174 0.543983,0.0702 0.353131,0.01905 0.678745,-0.01341 0.951442,-0.06456 0.27305,-0.05292 0.494595,-0.123119 0.646642,-0.181681 0.152047,-0.05785 0.234597,-0.104069 0.234597,-0.104069",
|
||||
"m 4.7519154,13.905801 c 0,0 0.091369,-0.0032 0.2511778,-0.0092 0.1580444,-0.0064 0.3820583,-0.01446 0.6455833,-0.03281 0.2631722,-0.01729 0.5662083,-0.04269 0.8812389,-0.09137 0.1576916,-0.02434 0.3175,-0.05609 0.4776611,-0.09384 0.1591027,-0.03951 0.3167944,-0.08643 0.4699,-0.14358 l 0.2702277,-0.08467 c 0.1008945,-0.02222 0.2074334,-0.04127 0.3072695,-0.05574 0.1943805,-0.01976 0.3848805,-0.0187 0.5651499,0.0014 0.3608917,0.03951 0.67945,0.144639 0.936625,0.261761 0.2575278,0.118534 0.4554364,0.247297 0.5873754,0.346781 0.132291,0.09913 0.198966,0.168275 0.198966,0.168275 0,0 -0.08925,-0.01976 -0.245886,-0.05397 C 9.9423347,14.087088 9.7232597,14.042988 9.4639681,14.00736 9.2057347,13.97173 8.9072848,13.94245 8.5978986,13.95162 c -0.077258,7.06e-4 -0.1541638,0.01058 -0.2328333,0.01411 -0.077964,0.0078 -0.1545166,0.02328 -0.2331861,0.03175 -0.073025,0.01588 -0.1404055,0.03422 -0.2141361,0.04798 l -0.2420055,0.08008 c -0.093486,0.02963 -0.1859139,0.06421 -0.2794,0.0889 C 7.3028516,14.23666 7.2093653,14.2603 7.116232,14.27512 6.9303181,14.30722 6.7465209,14.3231 6.5697792,14.32486 6.2166487,14.33046 5.8924459,14.28605 5.6218654,14.224318 5.3505793,14.161565 5.1318571,14.082895 4.9822793,14.01869 4.8327015,13.95519 4.7519154,13.905801 4.7519154,13.905801",
|
||||
],
|
||||
snow: [
|
||||
"m 8.4319893,15.348341 c 0,0.257881 -0.209197,0.467079 -0.467078,0.467079 -0.258586,0 -0.46743,-0.209198 -0.46743,-0.467079 0,-0.258233 0.208844,-0.467431 0.46743,-0.467431 0.257881,0 0.467078,0.209198 0.467078,0.467431",
|
||||
"m 11.263878,14.358553 c 0,0.364067 -0.295275,0.659694 -0.659695,0.659694 -0.364419,0 -0.6596937,-0.295627 -0.6596937,-0.659694 0,-0.364419 0.2952747,-0.659694 0.6596937,-0.659694 0.36442,0 0.659695,0.295275 0.659695,0.659694",
|
||||
"m 5.3252173,13.69847 c 0,0.364419 -0.295275,0.660047 -0.659695,0.660047 -0.364067,0 -0.659694,-0.295628 -0.659694,-0.660047 0,-0.364067 0.295627,-0.659694 0.659694,-0.659694 0.36442,0 0.659695,0.295627 0.659695,0.659694",
|
||||
],
|
||||
lightning: "m 9.9252695,10.935875 -1.6483986,2.341014 1.1170184,0.05929 -1.2169864,2.02141 3.0450261,-2.616159 H 9.8864918 L 10.97937,11.294651 10.700323,10.79794 h -0.508706 l -0.2663475,0.137936",
|
||||
};
|
||||
const HA_CLOUDY_STATES = new Set([
|
||||
"partlycloudy", "cloudy", "fog", "windy", "windy-variant", "hail", "rainy", "snowy",
|
||||
"snowy-rainy", "pouring", "lightning", "lightning-rainy",
|
||||
]);
|
||||
const HA_RAIN_STATES = new Set(["hail", "rainy", "pouring", "lightning-rainy"]);
|
||||
|
||||
function homeAssistantWeatherSvg(state, night) {
|
||||
const p = HA_WEATHER_PATHS;
|
||||
const paths = [];
|
||||
if (state === "sunny") paths.push(["sun", p.sun]);
|
||||
if (state === "clear-night") paths.push(["moon", p.moon]);
|
||||
if (state === "partlycloudy") paths.push([night ? "moon" : "sun", p.partly]);
|
||||
if (HA_CLOUDY_STATES.has(state)) paths.push(["cloud-back", p.cloudBack], ["cloud-front", p.cloudFront]);
|
||||
if (HA_RAIN_STATES.has(state)) paths.push(...p.rain.map((d) => ["rain", d]));
|
||||
if (state === "pouring") paths.push(...p.pouring.map((d) => ["rain", d]));
|
||||
if (state === "windy" || state === "windy-variant") paths.push(...p.wind.map((d) => ["cloud-back", d]));
|
||||
if (state === "snowy" || state === "snowy-rainy") paths.push(...p.snow.map((d) => ["snow", d]));
|
||||
if (state === "lightning" || state === "lightning-rainy") paths.push(["sun", p.lightning]);
|
||||
if (!paths.length) return null;
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17 17">${
|
||||
paths.map(([cls, d]) => `<path class="${cls}" d="${d}"/>`).join("")}</svg>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register both elements so they survive the
|
||||
* ``@webcomponents/scoped-custom-element-registry`` polyfill that
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
Apache License
|
||||
==============
|
||||
|
||||
_Version 2.0, January 2004_
|
||||
_<<http://www.apache.org/licenses/>>_
|
||||
|
||||
### Terms and Conditions for use, reproduction, and distribution
|
||||
|
||||
#### 1. Definitions
|
||||
|
||||
“License” shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
“Licensor” shall mean the copyright owner or entity authorized by the copyright
|
||||
owner that is granting the License.
|
||||
|
||||
“Legal Entity” shall mean the union of the acting entity and all other entities
|
||||
that control, are controlled by, or are under common control with that entity.
|
||||
For the purposes of this definition, “control” means **(i)** the power, direct or
|
||||
indirect, to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or **(iii)** beneficial ownership of such entity.
|
||||
|
||||
“You” (or “Your”) shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
“Source” form shall mean the preferred form for making modifications, including
|
||||
but not limited to software source code, documentation source, and configuration
|
||||
files.
|
||||
|
||||
“Object” form shall mean any form resulting from mechanical transformation or
|
||||
translation of a Source form, including but not limited to compiled object code,
|
||||
generated documentation, and conversions to other media types.
|
||||
|
||||
“Work” shall mean the work of authorship, whether in Source or Object form, made
|
||||
available under the License, as indicated by a copyright notice that is included
|
||||
in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
“Derivative Works” shall mean any work, whether in Source or Object form, that
|
||||
is based on (or derived from) the Work and for which the editorial revisions,
|
||||
annotations, elaborations, or other modifications represent, as a whole, an
|
||||
original work of authorship. For the purposes of this License, Derivative Works
|
||||
shall not include works that remain separable from, or merely link (or bind by
|
||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
“Contribution” shall mean any work of authorship, including the original version
|
||||
of the Work and any modifications or additions to that Work or Derivative Works
|
||||
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
||||
by the copyright owner or by an individual or Legal Entity authorized to submit
|
||||
on behalf of the copyright owner. For the purposes of this definition,
|
||||
“submitted” means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as “Not a Contribution.”
|
||||
|
||||
“Contributor” shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently
|
||||
incorporated within the Work.
|
||||
|
||||
#### 2. Grant of Copyright License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the Work and such
|
||||
Derivative Works in Source or Object form.
|
||||
|
||||
#### 3. Grant of Patent License
|
||||
|
||||
Subject to the terms and conditions of this License, each Contributor hereby
|
||||
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
||||
irrevocable (except as stated in this section) patent license to make, have
|
||||
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
|
||||
such license applies only to those patent claims licensable by such Contributor
|
||||
that are necessarily infringed by their Contribution(s) alone or by combination
|
||||
of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
|
||||
Contribution incorporated within the Work constitutes direct or contributory
|
||||
patent infringement, then any patent licenses granted to You under this License
|
||||
for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
#### 4. Redistribution
|
||||
|
||||
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
||||
in any medium, with or without modifications, and in Source or Object form,
|
||||
provided that You meet the following conditions:
|
||||
|
||||
* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
|
||||
this License; and
|
||||
* **(b)** You must cause any modified files to carry prominent notices stating that You
|
||||
changed the files; and
|
||||
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form
|
||||
of the Work, excluding those notices that do not pertain to any part of the
|
||||
Derivative Works; and
|
||||
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the
|
||||
attribution notices contained within such NOTICE file, excluding those notices
|
||||
that do not pertain to any part of the Derivative Works, in at least one of the
|
||||
following places: within a NOTICE text file distributed as part of the
|
||||
Derivative Works; within the Source form or documentation, if provided along
|
||||
with the Derivative Works; or, within a display generated by the Derivative
|
||||
Works, if and wherever such third-party notices normally appear. The contents of
|
||||
the NOTICE file are for informational purposes only and do not modify the
|
||||
License. You may add Your own attribution notices within Derivative Works that
|
||||
You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as
|
||||
modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide
|
||||
additional or different license terms and conditions for use, reproduction, or
|
||||
distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
#### 5. Submission of Contributions
|
||||
|
||||
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
||||
for inclusion in the Work by You to the Licensor shall be under the terms and
|
||||
conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of
|
||||
any separate license agreement you may have executed with Licensor regarding
|
||||
such Contributions.
|
||||
|
||||
#### 6. Trademarks
|
||||
|
||||
This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for
|
||||
reasonable and customary use in describing the origin of the Work and
|
||||
reproducing the content of the NOTICE file.
|
||||
|
||||
#### 7. Disclaimer of Warranty
|
||||
|
||||
Unless required by applicable law or agreed to in writing, Licensor provides the
|
||||
Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE,
|
||||
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
|
||||
solely responsible for determining the appropriateness of using or
|
||||
redistributing the Work and assume any risks associated with Your exercise of
|
||||
permissions under this License.
|
||||
|
||||
#### 8. Limitation of Liability
|
||||
|
||||
In no event and under no legal theory, whether in tort (including negligence),
|
||||
contract, or otherwise, unless required by applicable law (such as deliberate
|
||||
and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special, incidental,
|
||||
or consequential damages of any character arising as a result of this License or
|
||||
out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
|
||||
any and all other commercial damages or losses), even if such Contributor has
|
||||
been advised of the possibility of such damages.
|
||||
|
||||
#### 9. Accepting Warranty or Additional Liability
|
||||
|
||||
While redistributing the Work or Derivative Works thereof, You may choose to
|
||||
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
||||
other liability obligations and/or rights consistent with this License. However,
|
||||
in accepting such obligations, You may act only on Your own behalf and on Your
|
||||
sole responsibility, not on behalf of any other Contributor, and only if You
|
||||
agree to indemnify, defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
_END OF TERMS AND CONDITIONS_
|
||||
|
||||
### APPENDIX: How to apply the Apache License to your work
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate
|
||||
notice, with the fields enclosed by brackets `[]` replaced with your own
|
||||
identifying information. (Don't include the brackets!) The text should be
|
||||
enclosed in the appropriate comment syntax for the file format. We also
|
||||
recommend that a file or class name and description of purpose be included on
|
||||
the same “printed page” as the copyright notice for easier identification within
|
||||
third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Reference in New Issue
Block a user