diff --git a/README.md b/README.md index 06daa873..7cbaa818 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://github.com/aneisch/home-assistant-config/actions/workflows/check-ha-release-compatibility.yml/badge.svg)](https://github.com/aneisch/home-assistant-config/actions) [![GitHub last commit](https://img.shields.io/github/last-commit/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/commits/master) [![GitHub commit activity](https://img.shields.io/github/commit-activity/y/aneisch/home-assistant-config)](https://github.com/aneisch/home-assistant-config/graphs/commit-activity) -[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2024.3.1%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest) +[![HA Version](https://img.shields.io/badge/Running%20Home%20Assistant-2024.3.3%20(Latest)-brightgreen)](https://github.com/home-assistant/home-assistant/releases/latest)
Buy Me A Coffee @@ -57,7 +57,7 @@ Also using Grafana/Influx for graphing, both running in Docker containers on NUC Description | value -- | -- Lines of ESPHome YAML | 2801 -Lines of Home Assistant YAML | 9201 +Lines of Home Assistant YAML | 9205 [Integrations](https://www.home-assistant.io/integrations/) in use | 58 Zigbee devices in [`zha`](https://www.home-assistant.io/integrations/zha/) | 26 Z-Wave devices in [`zwave_js`](https://www.home-assistant.io/integrations/zwave_js/) | 37 @@ -71,7 +71,7 @@ Entities in the [`camera`](https://www.home-assistant.io/components/camera) doma Entities in the [`climate`](https://www.home-assistant.io/components/climate) domain | 1 Entities in the [`counter`](https://www.home-assistant.io/components/counter) domain | 1 Entities in the [`cover`](https://www.home-assistant.io/components/cover) domain | 13 -Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 2 +Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 4 Entities in the [`event`](https://www.home-assistant.io/components/event) domain | 50 Entities in the [`fan`](https://www.home-assistant.io/components/fan) domain | 3 Entities in the [`group`](https://www.home-assistant.io/components/group) domain | 17 @@ -91,17 +91,17 @@ Entities in the [`remote`](https://www.home-assistant.io/components/remote) doma Entities in the [`scene`](https://www.home-assistant.io/components/scene) domain | 2 Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 56 Entities in the [`select`](https://www.home-assistant.io/components/select) domain | 3 -Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 441 +Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 442 Entities in the [`siren`](https://www.home-assistant.io/components/siren) domain | 1 Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1 -Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 160 +Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 165 Entities in the [`timer`](https://www.home-assistant.io/components/timer) domain | 6 Entities in the [`tts`](https://www.home-assistant.io/components/tts) domain | 1 Entities in the [`update`](https://www.home-assistant.io/components/update) domain | 35 Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1 Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 2 Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6 -**Total state objects** | **1280** +**Total state objects** | **1288** ## The HACS integrations/plugins that I use: **Appdaemon**:
[aneisch/follow_me_appdaemon](https://github.com/aneisch/follow_me_appdaemon)
diff --git a/custom_components/frigate/icons.py b/custom_components/frigate/icons.py index 61675dee..e8a12807 100644 --- a/custom_components/frigate/icons.py +++ b/custom_components/frigate/icons.py @@ -19,6 +19,7 @@ ICON_PERSON = "mdi:human" ICON_SERVER = "mdi:server" ICON_SPEEDOMETER = "mdi:speedometer" +ICON_WAVEFORM = "mdi:waveform" ICON_DEFAULT_ON = "mdi:home" diff --git a/custom_components/frigate/manifest.json b/custom_components/frigate/manifest.json index 8105fdcb..466e5562 100644 --- a/custom_components/frigate/manifest.json +++ b/custom_components/frigate/manifest.json @@ -13,6 +13,6 @@ "documentation": "https://github.com/blakeblackshear/frigate", "iot_class": "local_push", "issue_tracker": "https://github.com/blakeblackshear/frigate-hass-integration/issues", - "requirements": ["pytz==2022.7"], - "version": "5.0.1" + "requirements": ["pytz"], + "version": "5.1.0" } diff --git a/custom_components/frigate/sensor.py b/custom_components/frigate/sensor.py index 9bf3b963..6a20e1e2 100644 --- a/custom_components/frigate/sensor.py +++ b/custom_components/frigate/sensor.py @@ -5,7 +5,12 @@ from typing import Any from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_URL, PERCENTAGE, UnitOfTemperature +from homeassistant.const import ( + CONF_URL, + PERCENTAGE, + UnitOfSoundPressure, + UnitOfTemperature, +) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -24,7 +29,13 @@ get_zones, ) from .const import ATTR_CONFIG, ATTR_COORDINATOR, DOMAIN, FPS, MS, NAME -from .icons import ICON_CORAL, ICON_SERVER, ICON_SPEEDOMETER, get_icon_from_type +from .icons import ( + ICON_CORAL, + ICON_SERVER, + ICON_SPEEDOMETER, + ICON_WAVEFORM, + get_icon_from_type, +) _LOGGER: logging.Logger = logging.getLogger(__name__) @@ -75,6 +86,9 @@ async def async_setup_entry( ] ) + if frigate_config["cameras"][name]["audio"]["enabled_in_config"]: + entities.append(CameraSoundSensor(coordinator, entry, name)) + frigate_config = hass.data[DOMAIN][entry.entry_id][ATTR_CONFIG] entities.extend( [ @@ -394,6 +408,78 @@ def icon(self) -> str: return ICON_SPEEDOMETER +class CameraSoundSensor(FrigateEntity, CoordinatorEntity): # type: ignore[misc] + """Frigate Camera Sound Level class.""" + + def __init__( + self, + coordinator: FrigateDataUpdateCoordinator, + config_entry: ConfigEntry, + cam_name: str, + ) -> None: + """Construct a CameraSoundSensor.""" + FrigateEntity.__init__(self, config_entry) + CoordinatorEntity.__init__(self, coordinator) + self._cam_name = cam_name + self._attr_entity_registry_enabled_default = True + + @property + def unique_id(self) -> str: + """Return a unique ID to use for this entity.""" + return get_frigate_entity_unique_id( + self._config_entry.entry_id, + "sensor_sound_level", + f"{self._cam_name}_dB", + ) + + @property + def device_info(self) -> DeviceInfo: + """Get device information.""" + return { + "identifiers": { + get_frigate_device_identifier(self._config_entry, self._cam_name) + }, + "via_device": get_frigate_device_identifier(self._config_entry), + "name": get_friendly_name(self._cam_name), + "model": self._get_model(), + "configuration_url": f"{self._config_entry.data.get(CONF_URL)}/cameras/{self._cam_name}", + "manufacturer": NAME, + } + + @property + def name(self) -> str: + """Return the name of the sensor.""" + return "sound level" + + @property + def unit_of_measurement(self) -> Any: + """Return the unit of measurement of the sensor.""" + return UnitOfSoundPressure.DECIBEL + + @property + def state(self) -> int | None: + """Return the state of the sensor.""" + + if self.coordinator.data: + data = ( + self.coordinator.data.get("cameras", {}) + .get(self._cam_name, {}) + .get("audio_dBFS") + ) + + if data is not None: + try: + return round(float(data)) + except ValueError: + pass + return None + + @property + def icon(self) -> str: + """Return the icon of the sensor.""" + return ICON_WAVEFORM + + class FrigateObjectCountSensor(FrigateMQTTEntity): """Frigate Motion Sensor class.""" diff --git a/custom_components/frigate/translations/de.json b/custom_components/frigate/translations/de.json index 5c8ff6e5..c554b60d 100644 --- a/custom_components/frigate/translations/de.json +++ b/custom_components/frigate/translations/de.json @@ -2,7 +2,7 @@ "config": { "step": { "user": { - "description": "URL, die Sie für den Zugriff auf Frigate verwenden (z. B. \"http://fregate:5000/\")\n\nWenn Sie HassOS mit dem Addon verwenden, sollte die URL „http://ccab4aaf-fregate:5000/“ lauten\n\nHome Assistant benötigt für alle Funktionen Zugriff auf Port 5000 (api) und 1935 (rtmp).\n\nDie Integration richtet Sensoren, Kameras und Medienbrowser-Funktionen ein.\n\nSensoren:\n- Statistiken zur Überwachung der Frigate-Leistung\n- Objektzählungen für alle Zonen und Kameras\n\nKameras:\n- Kameras für Bild des zuletzt erkannten Objekts für jede Kamera\n- Kameraeinheiten mit Stream-Unterstützung (erfordert RTMP)\n\nMedienbrowser:\n- Umfangreiche Benutzeroberfläche mit Vorschaubildern zum Durchsuchen von Event-Clips\n- Umfangreiche Benutzeroberfläche zum Durchsuchen von 24/7-Aufzeichnungen nach Monat, Tag, Kamera und Uhrzeit\n\nAPI:\n- Benachrichtigungs-API mit öffentlich zugänglichen Endpunkten für Bilder in Benachrichtigungen", + "description": "URL, die Sie für den Zugriff auf Frigate verwenden (z. B. \"http://frigate:5000/\")\n\nWenn Sie HassOS mit dem Addon verwenden, sollte die URL „http://ccab4aaf-frigate:5000/“ lauten\n\nHome Assistant benötigt für alle Funktionen Zugriff auf Port 5000 (api) und 1935 (rtmp).\n\nDie Integration richtet Sensoren, Kameras und Medienbrowser-Funktionen ein.\n\nSensoren:\n- Statistiken zur Überwachung der Frigate-Leistung\n- Objektzählungen für alle Zonen und Kameras\n\nKameras:\n- Kameras für Bild des zuletzt erkannten Objekts für jede Kamera\n- Kameraeinheiten mit Stream-Unterstützung (erfordert RTMP)\n\nMedienbrowser:\n- Umfangreiche Benutzeroberfläche mit Vorschaubildern zum Durchsuchen von Event-Clips\n- Umfangreiche Benutzeroberfläche zum Durchsuchen von 24/7-Aufzeichnungen nach Monat, Tag, Kamera und Uhrzeit\n\nAPI:\n- Benachrichtigungs-API mit öffentlich zugänglichen Endpunkten für Bilder in Benachrichtigungen", "data": { "url": "URL" } @@ -32,4 +32,4 @@ "only_advanced_options": "Der erweiterte Modus ist deaktiviert und es stehen nur erweiterte Optionen zur Verfügung" } } -} \ No newline at end of file +} diff --git a/custom_components/frigate/translations/fr.json b/custom_components/frigate/translations/fr.json new file mode 100644 index 00000000..7765b53f --- /dev/null +++ b/custom_components/frigate/translations/fr.json @@ -0,0 +1,36 @@ +{ + "config": { + "step": { + "user": { + "description": "URL que vous utilisez pour accéder à Frigate (par exemple, `http://frigate:5000/`)\n\nSi vous utilisez HassOS avec l'addon, l'URL devrait être `http://ccab4aaf-frigate:5000/`\n\nHome Assistant a besoin d'accès au port 5000 (api) et 1935 (rtmp) pour toutes les fonctionnalités.\n\nL'intégration configurera des capteurs, des caméras et la fonctionnalité de navigateur multimédia.\n\nCapteurs :\n- Statistiques pour surveiller la performance de Frigate\n- Comptes d'objets pour toutes les zones et caméras\n\nCaméras :\n- Caméras pour l'image du dernier objet détecté pour chaque caméra\n- Entités de caméra avec support de flux (nécessite RTMP)\n\nNavigateur multimédia :\n- Interface riche avec miniatures pour parcourir les clips d'événements\n- Interface riche pour parcourir les enregistrements 24/7 par mois, jour, caméra, heure\n\nAPI :\n- API de notification avec des points de terminaison publics pour les images dans les notifications", + "data": { + "url": "URL" + } + } + }, + "error": { + "cannot_connect": "Échec de la connexion", + "invalid_url": "URL invalide" + }, + "abort": { + "already_configured": "L'appareil est déjà configuré" + } + }, + "options": { + "step": { + "init": { + "data": { + "enable_webrtc": "Activer WebRTC pour les flux de caméra", + "rtmp_url_template": "Modèle d'URL RTMP (voir la documentation)", + "rtsp_url_template": "Modèle d'URL RTSP (voir la documentation)", + "media_browser_enable": "Activer le navigateur multimédia", + "notification_proxy_enable": "Activer le proxy d'événement de notification non authentifié", + "notification_proxy_expire_after_seconds": "Interdire l'accès à la notification non authentifiée après secondes (0=jamais)" + } + } + }, + "abort": { + "only_advanced_options": "Le mode avancé est désactivé et il n'y a que des options avancées" + } + } +} \ No newline at end of file diff --git a/packages/blinds.yaml b/packages/blinds.yaml index 87eb3526..9f34a149 100644 --- a/packages/blinds.yaml +++ b/packages/blinds.yaml @@ -202,6 +202,7 @@ automation: alias: Close Blinds at Sunset sequence: - service: cover.close_cover + continue_on_error: true target: entity_id: #- cover.office_blinds # Christmas @@ -210,6 +211,7 @@ automation: alias: Close Blinds Late sequence: - service: cover.close_cover + continue_on_error: true target: entity_id: - cover.office_blinds @@ -218,6 +220,7 @@ automation: alias: Open Blinds sequence: - service: cover.open_cover + continue_on_error: true target: entity_id: - cover.office_blinds @@ -226,6 +229,7 @@ automation: - if: "{{ states('input_boolean.guest_mode') == 'off' }}" then: - service: cover.open_cover + continue_on_error: true target: entity_id: - cover.guest_bedroom_blinds diff --git a/packages/frigate.yaml b/packages/frigate.yaml index 113493c1..94854e04 100644 --- a/packages/frigate.yaml +++ b/packages/frigate.yaml @@ -66,7 +66,7 @@ automation: - service: notify.signal_frigate data: message: >- - {{ generated_content.text }} + A person was detected. Clip: https://secret/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/clip.mp4 @@ -74,8 +74,8 @@ automation: Stream: https://secret/api/camera_proxy_stream/camera.{{trigger.payload_json['after']['camera'].lower()}}?token={{state_attr( 'camera.' ~ trigger.payload_json['after']['camera'].lower(), 'access_token')}} data: - attachments: - - /config/media/images/front_door.jpg + urls: + - http://localhost:8123/api/frigate/notifications/{{trigger.payload_json["after"]["id"]}}/snapshot.jpg?bbox=1×tamp=1&quality=100 - delay: '00:00:10' - alias: Front Door on Photo Frame diff --git a/www/community/uptime-card/uptime-card.js b/www/community/uptime-card/uptime-card.js index 2c970413..b15064b6 100644 --- a/www/community/uptime-card/uptime-card.js +++ b/www/community/uptime-card/uptime-card.js @@ -12,7 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ -function e(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,n,s):i(t,n))||s);return o>3&&s&&Object.defineProperty(t,n,s),s}var t=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,n="[^\\s]+",r=/\[([^]*?)\]/gm;function i(e,t){for(var n=[],r=0,i=e.length;r-1?r:null}};function s(e){for(var t=[],n=1;n3?0:(e-e%10!=10?1:0)*e%10]}},d=s({},u),h=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+h(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+h(Math.floor(Math.abs(t)/60),2)+":"+h(Math.abs(t)%60,2)}},p=function(e){return+e-1},m=[null,"[1-9]\\d?"],g=[null,n],v=["isPm",n,function(e,t){var n=e.toLowerCase();return n===t.amPm[0]?0:n===t.amPm[1]?1:null}],y=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var n=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?n:-n}return 0}],b=(o("monthNamesShort"),o("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var _=function(e,n,i){if(void 0===n&&(n=b.default),void 0===i&&(i={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var o=[];n=(n=b[n]||n).replace(r,(function(e,t){return o.push(t),"@@@"}));var a=s(s({},d),i);return(n=n.replace(t,(function(t){return f[t](e,a)}))).replace(/@@@/g,(function(){return o.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}})(),function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}}();var w=["closed","locked","off"],S=function(e,t,n,r){r=r||{},n=null==n?{}:n;var i=new Event(t,{bubbles:void 0===r.bubbles||r.bubbles,cancelable:Boolean(r.cancelable),composed:void 0===r.composed||r.composed});return i.detail=n,e.dispatchEvent(i),i},x=function(e){S(window,"haptic",e)},k=function(e,t,n,r,i){var o;if(i&&n.double_tap_action?o=n.double_tap_action:r&&n.hold_action?o=n.hold_action:!r&&n.tap_action&&(o=n.tap_action),o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(e){return e.user===t.user.id}))||confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?"))switch(o.action){case"more-info":(o.entity||n.entity||n.camera_image)&&(S(e,"hass-more-info",{entityId:o.entity?o.entity:n.entity?n.entity:n.camera_image}),o.haptic&&x(o.haptic));break;case"navigate":o.navigation_path&&(function(e,t,n){void 0===n&&(n=!1),n?history.replaceState(null,"",t):history.pushState(null,"",t),S(window,"location-changed",{replace:n})}(0,o.navigation_path),o.haptic&&x(o.haptic));break;case"url":o.url_path&&window.open(o.url_path),o.haptic&&x(o.haptic);break;case"toggle":n.entity&&(function(e,t){(function(e,t,n){void 0===n&&(n=!0);var r,i=function(e){return e.substr(0,e.indexOf("."))}(t),o="group"===i?"homeassistant":i;switch(i){case"lock":r=n?"unlock":"lock";break;case"cover":r=n?"open_cover":"close_cover";break;default:r=n?"turn_on":"turn_off"}e.callService(o,r,{entity_id:t})})(e,t,w.includes(e.states[t].state))}(t,n.entity),o.haptic&&x(o.haptic));break;case"call-service":if(!o.service)return;var s=o.service.split(".",2),a=s[0],c=s[1],l=Object.assign({},o.service_data);"entity"===l.entity_id&&(l.entity_id=n.entity),t.callService(a,c,l),o.haptic&&x(o.haptic);break;case"fire-dom-event":S(e,"ll-custom",o),o.haptic&&x(o.haptic)}}; +function e(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}var t=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,n="[^\\s]+",i=/\[([^]*?)\]/gm;function r(e,t){for(var n=[],i=0,r=e.length;i-1?i:null}};function a(e){for(var t=[],n=1;n3?0:(e-e%10!=10?1:0)*e%10]}},d=a({},u),h=function(e,t){for(void 0===t&&(t=2),e=String(e);e.length0?"-":"+")+h(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)},Z:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+h(Math.floor(Math.abs(t)/60),2)+":"+h(Math.abs(t)%60,2)}},p=function(e){return+e-1},m=[null,"[1-9]\\d?"],g=[null,n],v=["isPm",n,function(e,t){var n=e.toLowerCase();return n===t.amPm[0]?0:n===t.amPm[1]?1:null}],y=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(e){var t=(e+"").match(/([+-]|\d\d)/gi);if(t){var n=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?n:-n}return 0}],b=(o("monthNamesShort"),o("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var _=function(e,n,r){if(void 0===n&&(n=b.default),void 0===r&&(r={}),"number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date pass to format");var o=[];n=(n=b[n]||n).replace(i,(function(e,t){return o.push(t),"@@@"}));var s=a(a({},d),r);return(n=n.replace(t,(function(t){return f[t](e,s)}))).replace(/@@@/g,(function(){return o.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(e){return"RangeError"===e.name}})(),function(){try{(new Date).toLocaleString("i")}catch(e){return"RangeError"===e.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(e){return"RangeError"===e.name}}();var w=["closed","locked","off"],S=function(e,t,n,i){i=i||{},n=null==n?{}:n;var r=new Event(t,{bubbles:void 0===i.bubbles||i.bubbles,cancelable:Boolean(i.cancelable),composed:void 0===i.composed||i.composed});return r.detail=n,e.dispatchEvent(r),r},x=function(e){S(window,"haptic",e)},k=function(e,t,n,i,r){var o;if(r&&n.double_tap_action?o=n.double_tap_action:i&&n.hold_action?o=n.hold_action:!i&&n.tap_action&&(o=n.tap_action),o||(o={action:"more-info"}),!o.confirmation||o.confirmation.exemptions&&o.confirmation.exemptions.some((function(e){return e.user===t.user.id}))||confirm(o.confirmation.text||"Are you sure you want to "+o.action+"?"))switch(o.action){case"more-info":(o.entity||n.entity||n.camera_image)&&(S(e,"hass-more-info",{entityId:o.entity?o.entity:n.entity?n.entity:n.camera_image}),o.haptic&&x(o.haptic));break;case"navigate":o.navigation_path&&(function(e,t,n){void 0===n&&(n=!1),n?history.replaceState(null,"",t):history.pushState(null,"",t),S(window,"location-changed",{replace:n})}(0,o.navigation_path),o.haptic&&x(o.haptic));break;case"url":o.url_path&&window.open(o.url_path),o.haptic&&x(o.haptic);break;case"toggle":n.entity&&(function(e,t){(function(e,t,n){void 0===n&&(n=!0);var i,r=function(e){return e.substr(0,e.indexOf("."))}(t),o="group"===r?"homeassistant":r;switch(r){case"lock":i=n?"unlock":"lock";break;case"cover":i=n?"open_cover":"close_cover";break;default:i=n?"turn_on":"turn_off"}e.callService(o,i,{entity_id:t})})(e,t,w.includes(e.states[t].state))}(t,n.entity),o.haptic&&x(o.haptic));break;case"call-service":if(!o.service)return;var a=o.service.split(".",2),s=a[0],c=a[1],l=Object.assign({},o.service_data);"entity"===l.entity_id&&(l.entity_id=n.entity),t.callService(s,c,l),o.haptic&&x(o.haptic);break;case"fire-dom-event":S(e,"ll-custom",o),o.haptic&&x(o.haptic)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -26,7 +26,7 @@ function e(e,t,n,r){var i,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPro * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const P="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,C=(e,t,n=null)=>{for(;t!==n;){const n=t.nextSibling;e.removeChild(t),t=n}},N=`{{lit-${String(Math.random()).slice(2)}}}`,O=`\x3c!--${N}--\x3e`,I=new RegExp(`${N}|${O}`);class T{constructor(e,t){this.parts=[],this.element=t;const n=[],r=[],i=document.createTreeWalker(t.content,133,null,!1);let o=0,s=-1,a=0;const{strings:c,values:{length:l}}=e;for(;a0;){const t=c[a],n=D.exec(t)[2],r=n.toLowerCase()+"$lit$",i=e.getAttribute(r);e.removeAttribute(r);const o=i.split(I);this.parts.push({type:"attribute",index:s,name:n,strings:o}),a+=o.length-1}}"TEMPLATE"===e.tagName&&(r.push(e),i.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(N)>=0){const r=e.parentNode,i=t.split(I),o=i.length-1;for(let t=0;t{const n=e.length-t.length;return n>=0&&e.slice(n)===t},E=e=>-1!==e.index,$=()=>document.createComment(""),D=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function j(e,t){const{element:{content:n},parts:r}=e,i=document.createTreeWalker(n,133,null,!1);let o=R(r),s=r[o],a=-1,c=0;const l=[];let u=null;for(;i.nextNode();){a++;const e=i.currentNode;for(e.previousSibling===u&&(u=null),t.has(e)&&(l.push(e),null===u&&(u=e)),null!==u&&c++;void 0!==s&&s.index===a;)s.index=null!==u?-1:s.index-c,o=R(r,o),s=r[o]}l.forEach(e=>e.parentNode.removeChild(e))}const M=e=>{let t=11===e.nodeType?0:1;const n=document.createTreeWalker(e,133,null,!1);for(;n.nextNode();)t++;return t},R=(e,t=-1)=>{for(let n=t+1;n{for(;t!==n;){const n=t.nextSibling;e.removeChild(t),t=n}},C=`{{lit-${String(Math.random()).slice(2)}}}`,N=`\x3c!--${C}--\x3e`,I=new RegExp(`${C}|${N}`);class T{constructor(e,t){this.parts=[],this.element=t;const n=[],i=[],r=document.createTreeWalker(t.content,133,null,!1);let o=0,a=-1,s=0;const{strings:c,values:{length:l}}=e;for(;s0;){const t=c[s],n=D.exec(t)[2],i=n.toLowerCase()+"$lit$",r=e.getAttribute(i);e.removeAttribute(i);const o=r.split(I);this.parts.push({type:"attribute",index:a,name:n,strings:o}),s+=o.length-1}}"TEMPLATE"===e.tagName&&(i.push(e),r.currentNode=e.content)}else if(3===e.nodeType){const t=e.data;if(t.indexOf(C)>=0){const i=e.parentNode,r=t.split(I),o=r.length-1;for(let t=0;t{const n=e.length-t.length;return n>=0&&e.slice(n)===t},E=e=>-1!==e.index,$=()=>document.createComment(""),D=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function j(e,t){const{element:{content:n},parts:i}=e,r=document.createTreeWalker(n,133,null,!1);let o=R(i),a=i[o],s=-1,c=0;const l=[];let u=null;for(;r.nextNode();){s++;const e=r.currentNode;for(e.previousSibling===u&&(u=null),t.has(e)&&(l.push(e),null===u&&(u=e)),null!==u&&c++;void 0!==a&&a.index===s;)a.index=null!==u?-1:a.index-c,o=R(i,o),a=i[o]}l.forEach(e=>e.parentNode.removeChild(e))}const M=e=>{let t=11===e.nodeType?0:1;const n=document.createTreeWalker(e,133,null,!1);for(;n.nextNode();)t++;return t},R=(e,t=-1)=>{for(let n=t+1;n"function"==typeof e&&B.has(e),U={},V={}; * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class L{constructor(e,t,n){this.__parts=[],this.template=e,this.processor=t,this.options=n}update(e){let t=0;for(const n of this.__parts)void 0!==n&&n.setValue(e[t]),t++;for(const e of this.__parts)void 0!==e&&e.commit()}_clone(){const e=P?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),t=[],n=this.template.parts,r=document.createTreeWalker(e,133,null,!1);let i,o=0,s=0,a=r.nextNode();for(;oe}),H=` ${N} `;class Y{constructor(e,t,n,r){this.strings=e,this.values=t,this.type=n,this.processor=r}getHTML(){const e=this.strings.length-1;let t="",n=!1;for(let r=0;r-1||n)&&-1===e.indexOf("--\x3e",i+1);const o=D.exec(e);t+=null===o?e+(n?H:O):e.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[3]+N}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==F&&(t=F.createHTML(t)),e.innerHTML=t,e}}class W extends Y{getHTML(){return`${super.getHTML()}`}getTemplateElement(){const e=super.getTemplateElement(),t=e.content,n=t.firstChild;return t.removeChild(n),((e,t,n=null,r=null)=>{for(;t!==n;){const n=t.nextSibling;e.insertBefore(t,r),t=n}})(t,n.firstChild),e}} + */const H=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:e=>e}),L=` ${C} `;class q{constructor(e,t,n,i){this.strings=e,this.values=t,this.type=n,this.processor=i}getHTML(){const e=this.strings.length-1;let t="",n=!1;for(let i=0;i-1||n)&&-1===e.indexOf("--\x3e",r+1);const o=D.exec(e);t+=null===o?e+(n?L:N):e.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[3]+C}return t+=this.strings[e],t}getTemplateElement(){const e=document.createElement("template");let t=this.getHTML();return void 0!==H&&(t=H.createHTML(t)),e.innerHTML=t,e}}class Y extends q{getHTML(){return`${super.getHTML()}`}getTemplateElement(){const e=super.getTemplateElement(),t=e.content,n=t.firstChild;return t.removeChild(n),((e,t,n=null,i=null)=>{for(;t!==n;){const n=t.nextSibling;e.insertBefore(t,i),t=n}})(t,n.firstChild),e}} /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -80,7 +80,7 @@ class L{constructor(e,t,n){this.__parts=[],this.template=e,this.processor=t,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */const q=e=>null===e||!("object"==typeof e||"function"==typeof e),J=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class K{constructor(e,t,n){this.dirty=!0,this.element=e,this.name=t,this.strings=n,this.parts=[];for(let e=0;e{try{const e={get capture(){return te=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}})();class ne{constructor(e,t,n){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=n,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;z(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=U,e(this)}if(this.__pendingValue===U)return;const e=this.__pendingValue,t=this.value,n=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive),r=null!=e&&(null==t||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),r&&(this.__options=re(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=U}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const re=e=>e&&(te?{capture:e.capture,passive:e.passive,once:e.once}:e.capture) + */const W=e=>null===e||!("object"==typeof e||"function"==typeof e),J=e=>Array.isArray(e)||!(!e||!e[Symbol.iterator]);class K{constructor(e,t,n){this.dirty=!0,this.element=e,this.name=t,this.strings=n,this.parts=[];for(let e=0;e{try{const e={get capture(){return te=!0,!1}};window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){}})();class ne{constructor(e,t,n){this.value=void 0,this.__pendingValue=void 0,this.element=e,this.eventName=t,this.eventContext=n,this.__boundHandleEvent=e=>this.handleEvent(e)}setValue(e){this.__pendingValue=e}commit(){for(;z(this.__pendingValue);){const e=this.__pendingValue;this.__pendingValue=U,e(this)}if(this.__pendingValue===U)return;const e=this.__pendingValue,t=this.value,n=null==e||null!=t&&(e.capture!==t.capture||e.once!==t.once||e.passive!==t.passive),i=null!=e&&(null==t||n);n&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),i&&(this.__options=ie(e),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=e,this.__pendingValue=U}handleEvent(e){"function"==typeof this.value?this.value.call(this.eventContext||this.element,e):this.value.handleEvent(e)}}const ie=e=>e&&(te?{capture:e.capture,passive:e.passive,once:e.once}:e.capture) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -93,7 +93,7 @@ class L{constructor(e,t,n){this.__parts=[],this.template=e,this.processor=t,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */;function ie(e){let t=oe.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},oe.set(e.type,t));let n=t.stringsArray.get(e.strings);if(void 0!==n)return n;const r=e.strings.join(N);return n=t.keyString.get(r),void 0===n&&(n=new T(e,e.getTemplateElement()),t.keyString.set(r,n)),t.stringsArray.set(e.strings,n),n}const oe=new Map,se=new WeakMap; + */;function re(e){let t=oe.get(e.type);void 0===t&&(t={stringsArray:new WeakMap,keyString:new Map},oe.set(e.type,t));let n=t.stringsArray.get(e.strings);if(void 0!==n)return n;const i=e.strings.join(C);return n=t.keyString.get(i),void 0===n&&(n=new T(e,e.getTemplateElement()),t.keyString.set(i,n)),t.stringsArray.set(e.strings,n),n}const oe=new Map,ae=new WeakMap; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -106,7 +106,7 @@ class L{constructor(e,t,n){this.__parts=[],this.template=e,this.processor=t,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */const ae=new + */const se=new /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -120,7 +120,7 @@ class L{constructor(e,t,n){this.__parts=[],this.template=e,this.processor=t,this * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class{handleAttributeExpressions(e,t,n,r){const i=t[0];if("."===i){return new X(e,t.slice(1),n).parts}if("@"===i)return[new ne(e,t.slice(1),r.eventContext)];if("?"===i)return[new G(e,t.slice(1),n)];return new K(e,t,n).parts}handleTextExpression(e){return new Q(e)}}; +class{handleAttributeExpressions(e,t,n,i){const r=t[0];if("."===r){return new X(e,t.slice(1),n).parts}if("@"===r)return[new ne(e,t.slice(1),i.eventContext)];if("?"===r)return[new G(e,t.slice(1),n)];return new K(e,t,n).parts}handleTextExpression(e){return new Q(e)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -133,7 +133,7 @@ class{handleAttributeExpressions(e,t,n,r){const i=t[0];if("."===i){return new X( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const ce=(e,...t)=>new Y(e,t,"html",ae),le=(e,...t)=>new W(e,t,"svg",ae) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.3.0");const ce=(e,...t)=>new q(e,t,"html",se),le=(e,...t)=>new Y(e,t,"svg",se) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -146,7 +146,7 @@ class{handleAttributeExpressions(e,t,n,r){const i=t[0];if("."===i){return new X( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */,ue=(e,t)=>`${e}--${t}`;let de=!0;void 0===window.ShadyCSS?de=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),de=!1);const he=e=>t=>{const n=ue(t.type,e);let r=oe.get(n);void 0===r&&(r={stringsArray:new WeakMap,keyString:new Map},oe.set(n,r));let i=r.stringsArray.get(t.strings);if(void 0!==i)return i;const o=t.strings.join(N);if(i=r.keyString.get(o),void 0===i){const n=t.getTemplateElement();de&&window.ShadyCSS.prepareTemplateDom(n,e),i=new T(t,n),r.keyString.set(o,i)}return r.stringsArray.set(t.strings,i),i},fe=["html","svg"],pe=new Set,me=(e,t,n)=>{pe.add(e);const r=n?n.element:document.createElement("template"),i=t.querySelectorAll("style"),{length:o}=i;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(r,e);const s=document.createElement("style");for(let e=0;e{fe.forEach(t=>{const n=oe.get(ue(t,e));void 0!==n&&n.keyString.forEach(e=>{const{element:{content:t}}=e,n=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{n.add(e)}),j(e,n)})})})(e);const a=r.content;n?function(e,t,n=null){const{element:{content:r},parts:i}=e;if(null==n)return void r.appendChild(t);const o=document.createTreeWalker(r,133,null,!1);let s=R(i),a=0,c=-1;for(;o.nextNode();){c++;for(o.currentNode===n&&(a=M(t),n.parentNode.insertBefore(t,n));-1!==s&&i[s].index===c;){if(a>0){for(;-1!==s;)i[s].index+=a,s=R(i,s);return}s=R(i,s)}}}(n,s,a.firstChild):a.insertBefore(s,a.firstChild),window.ShadyCSS.prepareTemplateStyles(r,e);const c=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)t.insertBefore(c.cloneNode(!0),t.firstChild);else if(n){a.insertBefore(s,a.firstChild);const e=new Set;e.add(s),j(n,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const ge={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},ve=(e,t)=>t!==e&&(t==t||e==e),ye={attribute:!0,type:String,converter:ge,reflect:!1,hasChanged:ve};class be extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,n)=>{const r=this._attributeNameForProperty(n,t);void 0!==r&&(this._attributeToPropertyMap.set(r,n),e.push(r))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=ye){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const n="symbol"==typeof e?Symbol():"__"+e,r=this.getPropertyDescriptor(e,n,t);void 0!==r&&Object.defineProperty(this.prototype,e,r)}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(r){const i=this[e];this[t]=r,this.requestUpdateInternal(e,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||ye}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const n of t)this.createProperty(n,e[n])}}static _attributeNameForProperty(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,n=ve){return n(e,t)}static _propertyValueFromAttribute(e,t){const n=t.type,r=t.converter||ge,i="function"==typeof r?r:r.fromAttribute;return i?i(e,n):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const n=t.type,r=t.converter;return(r&&r.toAttribute||ge.toAttribute)(e,n)}initialize(){this._updateState=0,this._updatePromise=new Promise(e=>this._enableUpdatingResolver=e),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,n){t!==n&&this._attributeToProperty(e,n)}_propertyToAttribute(e,t,n=ye){const r=this.constructor,i=r._attributeNameForProperty(e,n);if(void 0!==i){const e=r._propertyValueToAttribute(t,n);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(i):this.setAttribute(i,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const n=this.constructor,r=n._attributeToPropertyMap.get(e);if(void 0!==r){const e=n.getPropertyOptions(r);this._updateState=16|this._updateState,this[r]=n._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}requestUpdateInternal(e,t,n){let r=!0;if(void 0!==e){const i=this.constructor;n=n||i.getPropertyOptions(e),i._valueHasChanged(this[e],t,n.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,n))):r=!1}!this._hasRequestedUpdate&&r&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(e,t){return this.requestUpdateInternal(e,t),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const e=this.performUpdate();return null!=e&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e?this.update(t):this._markUpdated()}catch(t){throw e=!1,this._markUpdated(),t}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0),this._markUpdated()}updated(e){}firstUpdated(e){}}be.finalized=!0; + */,ue=(e,t)=>`${e}--${t}`;let de=!0;void 0===window.ShadyCSS?de=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),de=!1);const he=e=>t=>{const n=ue(t.type,e);let i=oe.get(n);void 0===i&&(i={stringsArray:new WeakMap,keyString:new Map},oe.set(n,i));let r=i.stringsArray.get(t.strings);if(void 0!==r)return r;const o=t.strings.join(C);if(r=i.keyString.get(o),void 0===r){const n=t.getTemplateElement();de&&window.ShadyCSS.prepareTemplateDom(n,e),r=new T(t,n),i.keyString.set(o,r)}return i.stringsArray.set(t.strings,r),r},fe=["html","svg"],pe=new Set,me=(e,t,n)=>{pe.add(e);const i=n?n.element:document.createElement("template"),r=t.querySelectorAll("style"),{length:o}=r;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(i,e);const a=document.createElement("style");for(let e=0;e{fe.forEach(t=>{const n=oe.get(ue(t,e));void 0!==n&&n.keyString.forEach(e=>{const{element:{content:t}}=e,n=new Set;Array.from(t.querySelectorAll("style")).forEach(e=>{n.add(e)}),j(e,n)})})})(e);const s=i.content;n?function(e,t,n=null){const{element:{content:i},parts:r}=e;if(null==n)return void i.appendChild(t);const o=document.createTreeWalker(i,133,null,!1);let a=R(r),s=0,c=-1;for(;o.nextNode();){c++;for(o.currentNode===n&&(s=M(t),n.parentNode.insertBefore(t,n));-1!==a&&r[a].index===c;){if(s>0){for(;-1!==a;)r[a].index+=s,a=R(r,a);return}a=R(r,a)}}}(n,a,s.firstChild):s.insertBefore(a,s.firstChild),window.ShadyCSS.prepareTemplateStyles(i,e);const c=s.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==c)t.insertBefore(c.cloneNode(!0),t.firstChild);else if(n){s.insertBefore(a,s.firstChild);const e=new Set;e.add(a),j(n,e)}};window.JSCompiler_renameProperty=(e,t)=>e;const ge={toAttribute(e,t){switch(t){case Boolean:return e?"":null;case Object:case Array:return null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){switch(t){case Boolean:return null!==e;case Number:return null===e?null:Number(e);case Object:case Array:return JSON.parse(e)}return e}},ve=(e,t)=>t!==e&&(t==t||e==e),ye={attribute:!0,type:String,converter:ge,reflect:!1,hasChanged:ve};class be extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const e=[];return this._classProperties.forEach((t,n)=>{const i=this._attributeNameForProperty(n,t);void 0!==i&&(this._attributeToPropertyMap.set(i,n),e.push(i))}),e}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const e=Object.getPrototypeOf(this)._classProperties;void 0!==e&&e.forEach((e,t)=>this._classProperties.set(t,e))}}static createProperty(e,t=ye){if(this._ensureClassProperties(),this._classProperties.set(e,t),t.noAccessor||this.prototype.hasOwnProperty(e))return;const n="symbol"==typeof e?Symbol():"__"+e,i=this.getPropertyDescriptor(e,n,t);void 0!==i&&Object.defineProperty(this.prototype,e,i)}static getPropertyDescriptor(e,t,n){return{get(){return this[t]},set(i){const r=this[e];this[t]=i,this.requestUpdateInternal(e,r,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this._classProperties&&this._classProperties.get(e)||ye}static finalize(){const e=Object.getPrototypeOf(this);if(e.hasOwnProperty("finalized")||e.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const e=this.properties,t=[...Object.getOwnPropertyNames(e),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e):[]];for(const n of t)this.createProperty(n,e[n])}}static _attributeNameForProperty(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}static _valueHasChanged(e,t,n=ve){return n(e,t)}static _propertyValueFromAttribute(e,t){const n=t.type,i=t.converter||ge,r="function"==typeof i?i:i.fromAttribute;return r?r(e,n):e}static _propertyValueToAttribute(e,t){if(void 0===t.reflect)return;const n=t.type,i=t.converter;return(i&&i.toAttribute||ge.toAttribute)(e,n)}initialize(){this._updateState=0,this._updatePromise=new Promise(e=>this._enableUpdatingResolver=e),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((e,t)=>{if(this.hasOwnProperty(t)){const e=this[t];delete this[t],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(t,e)}})}_applyInstanceProperties(){this._instanceProperties.forEach((e,t)=>this[t]=e),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(e,t,n){t!==n&&this._attributeToProperty(e,n)}_propertyToAttribute(e,t,n=ye){const i=this.constructor,r=i._attributeNameForProperty(e,n);if(void 0!==r){const e=i._propertyValueToAttribute(t,n);if(void 0===e)return;this._updateState=8|this._updateState,null==e?this.removeAttribute(r):this.setAttribute(r,e),this._updateState=-9&this._updateState}}_attributeToProperty(e,t){if(8&this._updateState)return;const n=this.constructor,i=n._attributeToPropertyMap.get(e);if(void 0!==i){const e=n.getPropertyOptions(i);this._updateState=16|this._updateState,this[i]=n._propertyValueFromAttribute(t,e),this._updateState=-17&this._updateState}}requestUpdateInternal(e,t,n){let i=!0;if(void 0!==e){const r=this.constructor;n=n||r.getPropertyOptions(e),r._valueHasChanged(this[e],t,n.hasChanged)?(this._changedProperties.has(e)||this._changedProperties.set(e,t),!0!==n.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(e,n))):i=!1}!this._hasRequestedUpdate&&i&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(e,t){return this.requestUpdateInternal(e,t),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(e){}const e=this.performUpdate();return null!=e&&await e,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let e=!1;const t=this._changedProperties;try{e=this.shouldUpdate(t),e?this.update(t):this._markUpdated()}catch(t){throw e=!1,this._markUpdated(),t}e&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(t)),this.updated(t))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this._updatePromise}shouldUpdate(e){return!0}update(e){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((e,t)=>this._propertyToAttribute(t,this[t],e)),this._reflectingProperties=void 0),this._markUpdated()}updated(e){}firstUpdated(e){}}be.finalized=!0; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -160,7 +160,7 @@ class{handleAttributeExpressions(e,t,n,r){const i=t[0];if("."===i){return new X( * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const _e=e=>t=>"function"==typeof t?((e,t)=>(window.customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:n,elements:r}=t;return{kind:n,elements:r,finisher(t){window.customElements.define(e,t)}}})(e,t),we=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?Object.assign(Object.assign({},t),{finisher(n){n.createProperty(t.key,e)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(n){n.createProperty(t.key,e)}};function Se(e){return(t,n)=>void 0!==n?((e,t,n)=>{t.constructor.createProperty(n,e)})(e,t,n):we(e,t)}function xe(e){return Se({attribute:!1,hasChanged:null==e?void 0:e.hasChanged})} +const _e=e=>t=>"function"==typeof t?((e,t)=>(window.customElements.define(e,t),t))(e,t):((e,t)=>{const{kind:n,elements:i}=t;return{kind:n,elements:i,finisher(t){window.customElements.define(e,t)}}})(e,t),we=(e,t)=>"method"===t.kind&&t.descriptor&&!("value"in t.descriptor)?Object.assign(Object.assign({},t),{finisher(n){n.createProperty(t.key,e)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof t.initializer&&(this[t.key]=t.initializer.call(this))},finisher(n){n.createProperty(t.key,e)}};function Se(e){return(t,n)=>void 0!==n?((e,t,n)=>{t.constructor.createProperty(n,e)})(e,t,n):we(e,t)}function xe(e){return Se({attribute:!1,hasChanged:null==e?void 0:e.hasChanged})} /** @license Copyright (c) 2019 The Polymer Project Authors. All rights reserved. @@ -170,7 +170,7 @@ http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt -*/const ke=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Pe=Symbol();class Ce{constructor(e,t){if(t!==Pe)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(ke?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Ne=(e,...t)=>{const n=t.reduce((t,n,r)=>t+(e=>{if(e instanceof Ce)return e.cssText;if("number"==typeof e)return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(n)+e[r+1],e[0]);return new Ce(n,Pe)}; +*/const ke=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Pe=Symbol();class Oe{constructor(e,t){if(t!==Pe)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e}get styleSheet(){return void 0===this._styleSheet&&(ke?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Ce=(e,...t)=>{const n=t.reduce((t,n,i)=>t+(e=>{if(e instanceof Oe)return e.cssText;if("number"==typeof e)return e;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${e}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(n)+e[i+1],e[0]);return new Oe(n,Pe)}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -184,7 +184,7 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const Oe={};class Ie extends be{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(Array.isArray(e)){const t=(e,n)=>e.reduceRight((e,n)=>Array.isArray(n)?t(n,e):(e.add(n),e),n),n=t(e,new Set),r=[];n.forEach(e=>r.unshift(e)),this._styles=r}else this._styles=void 0===e?[]:[e];this._styles=this._styles.map(e=>{if(e instanceof CSSStyleSheet&&!ke){const t=Array.prototype.slice.call(e.cssRules).reduce((e,t)=>e+t.cssText,"");return new Ce(String(t),Pe)}return e})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?ke?this.renderRoot.adoptedStyleSheets=e.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==Oe&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return Oe}}Ie.finalized=!0,Ie.render=(e,t,n)=>{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const r=n.scopeName,i=se.has(t),o=de&&11===t.nodeType&&!!t.host,s=o&&!pe.has(r),a=s?document.createDocumentFragment():t;if(((e,t,n)=>{let r=se.get(t);void 0===r&&(C(t,t.firstChild),se.set(t,r=new Q(Object.assign({templateFactory:ie},n))),r.appendInto(t)),r.setValue(e),r.commit()})(e,a,Object.assign({templateFactory:he(r)},n)),s){const e=se.get(a);se.delete(a);const n=e.value instanceof L?e.value.template:void 0;me(r,a,n),C(t,t.firstChild),t.appendChild(a),se.set(t,e)}!i&&o&&window.ShadyCSS.styleElement(t.host)};const Te={hours_to_show:24,severity:100,update_interval:30,title_template:"[[[ return entity.attributes.friendly_name; ]]]",average_template:"[[[ return variables.uptime.toFixed(2); ]]]%",status_template:"[[[ return variables.current; ]]]",title_adaptive_color:!1,status_adaptive_color:!1,icon_adaptive_color:!1,tooltip_adaptive_color:!1},Ae={ok:"#45C669",ko:"#C66445",half:"#C6B145",none:"#C9C9C9",title:"grey",status:"grey",tooltip:"grey",footer:"#AAAAAA",icon:"var(--state-icon-color)"},Ee={header:!0,title:!0,icon:!0,status:!0,timeline:!0,footer:!0,average:!0},$e={height:46,round:1,spacing:4,amount:36},De={hour24:!1,template:"[[[ return variables.from_date; ]]] - [[[ return variables.to_date; ]]] | [[[ return variables.average; ]]]%",animation:!0},je={action:"more-info"},Me={header:"spaced",icon_first:!1,status:"spaced",tooltip_first:!1},Re={animation:"raise",duration:.5},Be={title:25,status:25};let ze=class extends Ie{constructor(){super(...arguments),this._initialized=!1}setConfig(e){this._config=e,this.loadCardHelpers()}shouldUpdate(){return this._initialized||this._initialize(),!0}render(){return this.hass&&this._helpers&&this.options?(this._helpers.importMoreInfoControl("climate"),ce` +(window.litElementVersions||(window.litElementVersions=[])).push("2.4.0");const Ne={};class Ie extends be{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const e=this.getStyles();if(Array.isArray(e)){const t=(e,n)=>e.reduceRight((e,n)=>Array.isArray(n)?t(n,e):(e.add(n),e),n),n=t(e,new Set),i=[];n.forEach(e=>i.unshift(e)),this._styles=i}else this._styles=void 0===e?[]:[e];this._styles=this._styles.map(e=>{if(e instanceof CSSStyleSheet&&!ke){const t=Array.prototype.slice.call(e.cssRules).reduce((e,t)=>e+t.cssText,"");return new Oe(String(t),Pe)}return e})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){const e=this.constructor._styles;0!==e.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?ke?this.renderRoot.adoptedStyleSheets=e.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(e.map(e=>e.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(e){const t=this.render();super.update(e),t!==Ne&&this.constructor.render(t,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(e=>{const t=document.createElement("style");t.textContent=e.cssText,this.renderRoot.appendChild(t)}))}render(){return Ne}}Ie.finalized=!0,Ie.render=(e,t,n)=>{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const i=n.scopeName,r=ae.has(t),o=de&&11===t.nodeType&&!!t.host,a=o&&!pe.has(i),s=a?document.createDocumentFragment():t;if(((e,t,n)=>{let i=ae.get(t);void 0===i&&(O(t,t.firstChild),ae.set(t,i=new Q(Object.assign({templateFactory:re},n))),i.appendInto(t)),i.setValue(e),i.commit()})(e,s,Object.assign({templateFactory:he(i)},n)),a){const e=ae.get(s);ae.delete(s);const n=e.value instanceof F?e.value.template:void 0;me(i,s,n),O(t,t.firstChild),t.appendChild(s),ae.set(t,e)}!r&&o&&window.ShadyCSS.styleElement(t.host)};const Te={severity:100,update_interval:30,title_template:"[[[ return entity.attributes.friendly_name; ]]]",average_template:"[[[ return variables.uptime.toFixed(2); ]]]%",status_template:"[[[ return variables.current; ]]]",title_adaptive_color:!1,status_adaptive_color:!1,icon_adaptive_color:!1,tooltip_adaptive_color:!1},Ae={ok:"#45C669",ko:"#C66445",half:"#C6B145",none:"#C9C9C9",title:"grey",status:"grey",tooltip:"grey",footer:"#AAAAAA",icon:"var(--state-icon-color)"},Ee={header:!0,title:!0,icon:!0,status:!0,timeline:!0,footer:!0,average:!0},$e={height:46,round:1,spacing:4,amount:36},De={hour24:!1,template:"[[[ return variables.from_date; ]]] - [[[ return variables.to_date; ]]] | [[[ return variables.average; ]]]%",animation:!0},je={action:"more-info"},Me={header:"spaced",icon_first:!1,status:"spaced",tooltip_first:!1},Re={animation:"raise",duration:.5},Be={title:25,status:25},ze={quantity:1,unit:"day"};let Ue=class extends Ie{constructor(){super(...arguments),this._initialized=!1}setConfig(e){this._config=e,this.loadCardHelpers()}shouldUpdate(){return this._initialized||this._initialize(),!0}render(){return this.hass&&this._helpers&&this.options?(this._helpers.importMoreInfoControl("climate"),ce`
${Object.entries(this.options).map(e=>this.renderOption(e[0],e[1]))}
@@ -248,7 +248,7 @@ found at http://polymer.github.io/PATENTS.txt `)} - `}getPropertyValue(e){if(null==this._config)return;const t=e.section?this._config[e.section]:this._config;return null!=t?t[e.name]:void 0}_initialize(){var e,t,n,r,i,o,s,a,c,l,u,d,h,f,p;if(void 0===this.hass)return;if(void 0===this._config)return;if(void 0===this._helpers)return;this._initialized=!0;const m=Object.keys(this.hass.states),g=["more-info","url","navigate","toggle","call-service","fire-dom-event"],v=["center","right","left","spaced"],y=["fade","shadow"],b=["card","status","title","icon"],_=["none","raise","reveal","slide"];this.options={mandatory:{icon:"tune",name:"Mandatory",description:"Required options for this card to function",show:!0,properties:[{type:"dropdown",items:m,name:"entity",label:"Entity",selected:m.indexOf((null===(e=this._config)||void 0===e?void 0:e.entity)||"")}]},customization:{icon:"cog",name:"Global customization",description:"Customize the name, icon, etc",show:!1,properties:[{type:"input",name:"attribute",label:"Attribute"},{type:"input",name:"icon",label:"Icon"},{type:"input",name:"ko_icon",label:"KO Icon"},{type:"input",name:"none_icon",label:"None Icon"},{type:"number",name:"severity",label:"Severity",min:0,max:100,default:Te.severity},{type:"number",name:"update_interval",label:"Update interval",min:0,max:86400,default:Te.update_interval},{type:"number",name:"hours_to_show",label:"Hours to show",min:1/60,max:8760,default:Te.hours_to_show},{type:"input",name:"ok",label:"Ok status name"},{type:"input",name:"ko",label:"Ko status name"},{type:"input",name:"none",label:"None status name"},{type:"input",name:"title_template",label:"Title template",default:Te.title_template},{type:"input",name:"status_template",label:"The template of the status",default:Te.status_template},{type:"input",name:"average_template",label:"Average template",default:Te.average_template},{type:"switch",name:"title_adaptive_color",label:"Adaptive color for title",default:Te.title_adaptive_color},{type:"switch",name:"status_adaptive_color",label:"Adaptive color for status",default:Te.status_adaptive_color},{type:"switch",name:"icon_adaptive_color",label:"Adaptive color for icon",default:Te.icon_adaptive_color},{type:"switch",name:"tooltip_adaptive_color",label:"Adaptive color for tooltip",default:Te.tooltip_adaptive_color}]},bar:{icon:"chart-bar",name:"Bar customization",description:"Customize the bar style",show:!1,properties:[{type:"number",name:"height",section:"bar",label:"Height",min:4,max:200,default:$e.height},{type:"number",name:"round",section:"bar",label:"Round corner ratio",min:0,max:100,default:$e.round},{type:"number",name:"spacing",section:"bar",label:"Spacing",min:0,max:10,default:$e.spacing},{type:"number",name:"amount",section:"bar",label:"Amount",min:1,max:100,default:$e.amount}]},init:{icon:"watch",name:"Init customization",description:"Customize the initialization animation",show:!1,properties:[{type:"dropdown",items:_,name:"animation",section:"init",label:"Animation during initilization",selected:_.indexOf((null===(n=null===(t=this._config)||void 0===t?void 0:t.init)||void 0===n?void 0:n.animation)||Re.animation)},{type:"number",name:"duration",section:"init",label:"Animation duration",min:0,max:10,default:Re.duration}]},color:{icon:"palette",name:"Color customization",description:"Customize the color palette",show:!1,properties:[{type:"input",name:"ok",section:"color",label:"Ok's element color",default:Ae.ok},{type:"input",name:"ko",section:"color",label:"Ko's element color",default:Ae.ko},{type:"input",name:"none",section:"color",label:"Unknown's element color",default:Ae.none},{type:"input",name:"half",section:"color",label:"Half's element color",default:Ae.half},{type:"input",name:"title",section:"color",label:"Title text color",default:Ae.title},{type:"input",name:"status",section:"color",label:"Status text color",default:Ae.status},{type:"input",name:"icon",section:"color",label:"Icon color",default:Ae.icon},{type:"input",name:"ko_icon",section:"color",label:"KO Icon color"},{type:"input",name:"tooltip",section:"color",label:"Tooltip text color",default:Ae.tooltip},{type:"input",name:"footer",section:"color",label:"Footer text color",default:Ae.footer}]},show:{icon:"eye",name:"Toggle elements",description:"Show or hide uptime card elements",show:!1,properties:[{type:"switch",name:"header",section:"show",label:"Toggle header",default:Ee.header},{type:"switch",name:"title",section:"show",label:"Toggle title",default:Ee.title},{type:"switch",name:"icon",section:"show",label:"Toggle icon",default:Ee.icon},{type:"switch",name:"status",section:"show",label:"Toggle status",default:Ee.status},{type:"switch",name:"timeline",section:"show",label:"Toggle timeline",default:Ee.timeline},{type:"switch",name:"footer",section:"show",label:"Toggle footer",default:Ee.footer},{type:"switch",name:"average",section:"show",label:"Toggle average",default:Ee.average}]},alias:{icon:"reload",name:"Alias",description:"Replace status name by alias",show:!1,properties:[{type:"input",name:"ok",section:"alias",label:"Alias for Ok status"},{type:"input",name:"ko",section:"alias",label:"Alias for Ko status"}]},tooltip:{icon:"tooltip-text",name:"Tooltip elements",description:"Handle tooltip information",show:!1,properties:[{type:"switch",name:"hour24",section:"tooltip",label:"Set to true to display times in 24-hour format.",default:De.hour24},{type:"switch",name:"animation",section:"tooltip",label:"Set to true to show the animation.",default:De.animation},{type:"input",name:"template",section:"tooltip",label:"Template of the tooltip.",default:De.template}]},tap_action:{icon:"gesture-tap",name:"Tap action elements",description:"Handle tap action information",show:!1,properties:[{type:"dropdown",items:g,name:"action",section:"tap_action",label:"Action to perform.",selected:g.indexOf((null===(i=null===(r=this._config)||void 0===r?void 0:r.tap_action)||void 0===i?void 0:i.action)||je.action)},{type:"input",name:"entity",section:"tap_action",label:"(Only for more-info) Override the entity for more information."},{type:"input",name:"navigation_path",section:"tap_action",label:"(Only for navigate) Path to navigate to (e.g. `/lovelace/0/`)."},{type:"input",name:"url_path",section:"tap_action",label:"(Only for url) URL to open."},{type:"input",name:"service",section:"tap_action",label:"(Only for call-service) Service to call."},{type:"input",name:"service-data",section:"tap_action",label:"(Only for call-service) Service data to include."},{type:"dropdown",items:["success","warning","failure","light","medium","heavy","selection"],name:"haptic",section:"tap_action",label:"Haptic feedback.",selected:g.indexOf((null===(s=null===(o=this._config)||void 0===o?void 0:o.tap_action)||void 0===s?void 0:s.haptic)||"")}]},alignment:{icon:"ruler",name:"Alignment",description:"Align elements from the card",show:!1,properties:[{type:"dropdown",items:v,name:"header",section:"alignment",label:"Alignment of the header.",selected:v.indexOf((null===(c=null===(a=this._config)||void 0===a?void 0:a.alignment)||void 0===c?void 0:c.header)||Me.header)},{type:"switch",name:"icon_first",section:"alignment",label:"Set to true if the icon should be placed before the title.",default:Me.icon_first},{type:"dropdown",items:v,name:"status",section:"alignment",label:"Alignment of the status.",selected:v.indexOf((null===(u=null===(l=this._config)||void 0===l?void 0:l.alignment)||void 0===u?void 0:u.status)||Me.status)},{type:"switch",name:"tooltip_first",section:"alignment",label:"Set to true if the tooltip should be placed before the state.",default:Me.tooltip_first}]},blink:{icon:"alert",name:"Blink customization",description:"Customize blink",show:!1,properties:[{type:"dropdown",items:y,name:"effect",section:"blink",label:"The blink effect.",selected:y.indexOf(null===(h=null===(d=this._config)||void 0===d?void 0:d.blink)||void 0===h?void 0:h.effect)},{type:"dropdown",items:b,name:"target",section:"blink",label:"Set the component to blink.",selected:b.indexOf(null===(p=null===(f=this._config)||void 0===f?void 0:f.blink)||void 0===p?void 0:p.target)},{type:"number",name:"speed",label:"The animation speed.",section:"blink",min:0,max:100}]},clip:{icon:"scissors-cutting",name:"Clip customization",description:"Customize max length of texts",show:!1,properties:[{name:"title",type:"number",label:"The max length of the title before clipping.",section:"clip",min:0,max:100,default:Be.title},{name:"status",type:"number",label:"The max length of the status before clipping.",section:"clip",min:0,max:100,default:Be.status}]}}}async loadCardHelpers(){this._helpers=await window.loadCardHelpers()}_toggleOption(e){if(null==this.options)return;const t=!this.options[e.target.option].show;for(const[e]of Object.entries(this.options))this.options[e].show=!1;this.options[e.target.option].show=t,this._toggle=!this._toggle}_valueChanged(e){if(!this._config||!this.hass)return;const t=e.target,n=t.configSection,r=Object.assign({},this._config),i=(n?Object.assign({},r[n]):r)||{};if(t.configValue)if(void 0===t.value&&void 0===t.checked||""===t.value)delete i[t.configValue],this._config=n?Object.assign(Object.assign({},r),{[n]:i}):Object.assign({},i);else{const e=t.configValue,i=void 0!==t.checked?t.checked:t.value,o=t.number?parseFloat(i):i;this._config=n?Object.assign(Object.assign({},r),{[n]:Object.assign(Object.assign({},r[n]),{[e]:o})}):Object.assign(Object.assign({},r),{[e]:o})}S(this,"config-changed",{config:this._config})}static get styles(){return Ne` + `}getPropertyValue(e){if(null==this._config)return;const t=e.section?this._config[e.section]:this._config;return null!=t?t[e.name]:void 0}_initialize(){var e,t,n,i,r,o,a,s,c,l,u,d,h,f,p,m,g;if(void 0===this.hass)return;if(void 0===this._config)return;if(void 0===this._helpers)return;this._initialized=!0;const v=Object.keys(this.hass.states),y=["more-info","url","navigate","toggle","call-service","fire-dom-event"],b=["center","right","left","spaced"],_=["fade","shadow"],w=["card","status","title","icon"],S=["none","raise","reveal","slide"],x=["minute","hour","day","week","month","year"];this.options={mandatory:{icon:"tune",name:"Mandatory",description:"Required options for this card to function",show:!0,properties:[{type:"dropdown",items:v,name:"entity",label:"Entity",selected:v.indexOf((null===(e=this._config)||void 0===e?void 0:e.entity)||"")}]},customization:{icon:"cog",name:"Global customization",description:"Customize the name, icon, etc",show:!1,properties:[{type:"input",name:"attribute",label:"Attribute"},{type:"input",name:"icon",label:"Icon"},{type:"input",name:"ko_icon",label:"KO Icon"},{type:"input",name:"none_icon",label:"None Icon"},{type:"number",name:"severity",label:"Severity",min:0,max:100,default:Te.severity},{type:"number",name:"update_interval",label:"Update interval",min:0,max:86400,default:Te.update_interval},{type:"input",name:"ok",label:"Ok status name"},{type:"input",name:"ko",label:"Ko status name"},{type:"input",name:"none",label:"None status name"},{type:"input",name:"title_template",label:"Title template",default:Te.title_template},{type:"input",name:"status_template",label:"The template of the status",default:Te.status_template},{type:"input",name:"average_template",label:"Average template",default:Te.average_template},{type:"switch",name:"title_adaptive_color",label:"Adaptive color for title",default:Te.title_adaptive_color},{type:"switch",name:"status_adaptive_color",label:"Adaptive color for status",default:Te.status_adaptive_color},{type:"switch",name:"icon_adaptive_color",label:"Adaptive color for icon",default:Te.icon_adaptive_color},{type:"switch",name:"tooltip_adaptive_color",label:"Adaptive color for tooltip",default:Te.tooltip_adaptive_color}]},bar:{icon:"chart-bar",name:"Bar customization",description:"Customize the bar style",show:!1,properties:[{type:"number",name:"height",section:"bar",label:"Height",min:4,max:200,default:$e.height},{type:"number",name:"round",section:"bar",label:"Round corner ratio",min:0,max:100,default:$e.round},{type:"number",name:"spacing",section:"bar",label:"Spacing",min:0,max:10,default:$e.spacing},{type:"number",name:"amount",section:"bar",label:"Amount",min:1,max:100,default:$e.amount}]},init:{icon:"watch",name:"Init customization",description:"Customize the initialization animation",show:!1,properties:[{type:"dropdown",items:S,name:"animation",section:"init",label:"Animation during initilization",selected:S.indexOf((null===(n=null===(t=this._config)||void 0===t?void 0:t.init)||void 0===n?void 0:n.animation)||Re.animation)},{type:"number",name:"duration",section:"init",label:"Animation duration",min:0,max:10,default:Re.duration}]},color:{icon:"palette",name:"Color customization",description:"Customize the color palette",show:!1,properties:[{type:"input",name:"ok",section:"color",label:"Ok's element color",default:Ae.ok},{type:"input",name:"ko",section:"color",label:"Ko's element color",default:Ae.ko},{type:"input",name:"none",section:"color",label:"Unknown's element color",default:Ae.none},{type:"input",name:"half",section:"color",label:"Half's element color",default:Ae.half},{type:"input",name:"title",section:"color",label:"Title text color",default:Ae.title},{type:"input",name:"status",section:"color",label:"Status text color",default:Ae.status},{type:"input",name:"icon",section:"color",label:"Icon color",default:Ae.icon},{type:"input",name:"ko_icon",section:"color",label:"KO Icon color"},{type:"input",name:"tooltip",section:"color",label:"Tooltip text color",default:Ae.tooltip},{type:"input",name:"footer",section:"color",label:"Footer text color",default:Ae.footer}]},show:{icon:"eye",name:"Toggle elements",description:"Show or hide uptime card elements",show:!1,properties:[{type:"switch",name:"header",section:"show",label:"Toggle header",default:Ee.header},{type:"switch",name:"title",section:"show",label:"Toggle title",default:Ee.title},{type:"switch",name:"icon",section:"show",label:"Toggle icon",default:Ee.icon},{type:"switch",name:"status",section:"show",label:"Toggle status",default:Ee.status},{type:"switch",name:"timeline",section:"show",label:"Toggle timeline",default:Ee.timeline},{type:"switch",name:"footer",section:"show",label:"Toggle footer",default:Ee.footer},{type:"switch",name:"average",section:"show",label:"Toggle average",default:Ee.average}]},alias:{icon:"reload",name:"Alias",description:"Replace status name by alias",show:!1,properties:[{type:"input",name:"ok",section:"alias",label:"Alias for Ok status"},{type:"input",name:"ko",section:"alias",label:"Alias for Ko status"}]},tooltip:{icon:"tooltip-text",name:"Tooltip elements",description:"Handle tooltip information",show:!1,properties:[{type:"switch",name:"hour24",section:"tooltip",label:"Set to true to display times in 24-hour format.",default:De.hour24},{type:"switch",name:"animation",section:"tooltip",label:"Set to true to show the animation.",default:De.animation},{type:"input",name:"template",section:"tooltip",label:"Template of the tooltip.",default:De.template}]},tap_action:{icon:"gesture-tap",name:"Tap action elements",description:"Handle tap action information",show:!1,properties:[{type:"dropdown",items:y,name:"action",section:"tap_action",label:"Action to perform.",selected:y.indexOf((null===(r=null===(i=this._config)||void 0===i?void 0:i.tap_action)||void 0===r?void 0:r.action)||je.action)},{type:"input",name:"entity",section:"tap_action",label:"(Only for more-info) Override the entity for more information."},{type:"input",name:"navigation_path",section:"tap_action",label:"(Only for navigate) Path to navigate to (e.g. `/lovelace/0/`)."},{type:"input",name:"url_path",section:"tap_action",label:"(Only for url) URL to open."},{type:"input",name:"service",section:"tap_action",label:"(Only for call-service) Service to call."},{type:"input",name:"service-data",section:"tap_action",label:"(Only for call-service) Service data to include."},{type:"dropdown",items:["success","warning","failure","light","medium","heavy","selection"],name:"haptic",section:"tap_action",label:"Haptic feedback.",selected:y.indexOf((null===(a=null===(o=this._config)||void 0===o?void 0:o.tap_action)||void 0===a?void 0:a.haptic)||"")}]},alignment:{icon:"ruler",name:"Alignment",description:"Align elements from the card",show:!1,properties:[{type:"dropdown",items:b,name:"header",section:"alignment",label:"Alignment of the header.",selected:b.indexOf((null===(c=null===(s=this._config)||void 0===s?void 0:s.alignment)||void 0===c?void 0:c.header)||Me.header)},{type:"switch",name:"icon_first",section:"alignment",label:"Set to true if the icon should be placed before the title.",default:Me.icon_first},{type:"dropdown",items:b,name:"status",section:"alignment",label:"Alignment of the status.",selected:b.indexOf((null===(u=null===(l=this._config)||void 0===l?void 0:l.alignment)||void 0===u?void 0:u.status)||Me.status)},{type:"switch",name:"tooltip_first",section:"alignment",label:"Set to true if the tooltip should be placed before the state.",default:Me.tooltip_first}]},blink:{icon:"alert",name:"Blink customization",description:"Customize blink",show:!1,properties:[{type:"dropdown",items:_,name:"effect",section:"blink",label:"The blink effect.",selected:_.indexOf(null===(h=null===(d=this._config)||void 0===d?void 0:d.blink)||void 0===h?void 0:h.effect)},{type:"dropdown",items:w,name:"target",section:"blink",label:"Set the component to blink.",selected:w.indexOf(null===(p=null===(f=this._config)||void 0===f?void 0:f.blink)||void 0===p?void 0:p.target)},{type:"number",name:"speed",label:"The animation speed.",section:"blink",min:0,max:100}]},clip:{icon:"scissors-cutting",name:"Clip customization",description:"Customize max length of texts",show:!1,properties:[{name:"title",type:"number",label:"The max length of the title before clipping.",section:"clip",min:0,max:100,default:Be.title},{name:"status",type:"number",label:"The max length of the status before clipping.",section:"clip",min:0,max:100,default:Be.status}]},duration:{icon:"clock",name:"Duration customization",description:"Customize the uptime duration",show:!1,properties:[{type:"number",name:"quantity",section:"duration",label:"Duration quantity",min:0,max:24,default:ze.quantity},{type:"dropdown",items:x,name:"unit",section:"duration",label:"Duration unit",selected:x.indexOf((null===(g=null===(m=this._config)||void 0===m?void 0:m.duration)||void 0===g?void 0:g.unit)||ze.unit)}]}}}async loadCardHelpers(){this._helpers=await window.loadCardHelpers()}_toggleOption(e){if(null==this.options)return;const t=!this.options[e.target.option].show;for(const[e]of Object.entries(this.options))this.options[e].show=!1;this.options[e.target.option].show=t,this._toggle=!this._toggle}_valueChanged(e){if(!this._config||!this.hass)return;const t=e.target,n=t.configSection,i=Object.assign({},this._config),r=(n?Object.assign({},i[n]):i)||{};if(t.configValue)if(void 0===t.value&&void 0===t.checked||""===t.value)delete r[t.configValue],this._config=n?Object.assign(Object.assign({},i),{[n]:r}):Object.assign({},r);else{const e=t.configValue,r=void 0!==t.checked?t.checked:t.value,o=t.number?parseFloat(r):r;this._config=n?Object.assign(Object.assign({},i),{[n]:Object.assign(Object.assign({},i[n]),{[e]:o})}):Object.assign(Object.assign({},i),{[e]:o})}S(this,"config-changed",{config:this._config})}static get styles(){return Ce` .option { padding: 4px 0px; cursor: pointer; @@ -276,7 +276,7 @@ found at http://polymer.github.io/PATENTS.txt ha-formfield { padding-bottom: 8px; } - `}};e([Se({attribute:!1})],ze.prototype,"hass",void 0),e([xe()],ze.prototype,"_config",void 0),e([xe()],ze.prototype,"_toggle",void 0),e([xe()],ze.prototype,"_helpers",void 0),e([xe()],ze.prototype,"options",void 0),ze=e([_e("uptime-card-editor")],ze);var Ue=function(){try{if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!=typeof mozIndexedDB)return mozIndexedDB;if("undefined"!=typeof OIndexedDB)return OIndexedDB;if("undefined"!=typeof msIndexedDB)return msIndexedDB}catch(e){return}}();function Ve(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r=43)}})).catch((function(){return!1}))}(e).then((function(e){return We=e,We}))}function Ze(e){var t=qe[e.name],n={};n.promise=new Promise((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function Qe(e){var t=qe[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function Ge(e,t){var n=qe[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function Xe(e,t){return new Promise((function(n,r){if(qe[e.name]=qe[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);Ze(e),e.db.close()}var i=[e.name];t&&i.push(e.version);var o=Ue.open.apply(Ue,i);t&&(o.onupgradeneeded=function(t){var n=o.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore("local-forage-detect-blob-support")}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),r(o.error)},o.onsuccess=function(){n(o.result),Qe(e)}}))}function et(e){return Xe(e,!1)}function tt(e){return Xe(e,!0)}function nt(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),r=e.versione.db.version;if(r&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||n){if(n){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function rt(e){return Ve([function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),i=0;i0&&(!e.db||"InvalidStateError"===i.name||"NotFoundError"===i.name))return Promise.resolve().then(()=>{if(!e.db||"NotFoundError"===i.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),tt(e)}).then(()=>function(e){Ze(e);for(var t=qe[e.name],n=t.forages,r=0;r(e.db=t,nt(e)?tt(e):t)).then(r=>{e.db=t.db=r;for(var i=0;i{throw Ge(e,t),t})}(e).then((function(){st(e,t,n,r-1)}))).catch(n);n(i)}}var at={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var r in e)n[r]=e[r];var i=qe[n.name];i||(i={forages:[],db:null,dbReady:null,deferredOperations:[]},qe[n.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=ot);var o=[];function s(){return Promise.resolve()}for(var a=0;a{const n=qe[e.name],r=n.forages;n.db=t;for(var i=0;i{if(!t.objectStoreNames.contains(e.storeName))return;const n=t.version+1;Ze(e);const r=qe[e.name],i=r.forages;t.close();for(let e=0;e{const i=Ue.open(e.name,n);i.onerror=e=>{i.result.close(),r(e)},i.onupgradeneeded=()=>{i.result.deleteObjectStore(e.storeName)},i.onsuccess=()=>{const e=i.result;e.close(),t(e)}}).then(e=>{r.db=e;for(let t=0;t{throw(Ge(e,t)||Promise.resolve()).catch(()=>{}),t})}):t.then(t=>{Ze(e);const n=qe[e.name],r=n.forages;t.close();for(var i=0;i{var r=Ue.deleteDatabase(e.name);r.onerror=r.onblocked=e=>{const t=r.result;t&&t.close(),n(e)},r.onsuccess=()=>{const e=r.result;e&&e.close(),t(e)}}).then(e=>{n.db=e;for(var t=0;t{throw(Ge(e,t)||Promise.resolve()).catch(()=>{}),t})})}else r=Promise.reject("Invalid arguments");return Le(r,t),r}};var ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lt=/^~~local_forage_type~([^~]+)~/,ut="__lfsc__:".length,dt=ut+"arbf".length,ht=Object.prototype.toString;function ft(e){var t,n,r,i,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);var l=new ArrayBuffer(s),u=new Uint8Array(l);for(t=0;t>4,u[c++]=(15&r)<<4|i>>2,u[c++]=(3&i)<<6|63&o;return l}function pt(e){var t,n=new Uint8Array(e),r="";for(t=0;t>2],r+=ct[(3&n[t])<<4|n[t+1]>>4],r+=ct[(15&n[t+1])<<2|n[t+2]>>6],r+=ct[63&n[t+2]];return n.length%3==2?r=r.substring(0,r.length-1)+"=":n.length%3==1&&(r=r.substring(0,r.length-2)+"=="),r}var mt={serialize:function(e,t){var n="";if(e&&(n=ht.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===ht.call(e.buffer))){var r,i="__lfsc__:";e instanceof ArrayBuffer?(r=e,i+="arbf"):(r=e.buffer,"[object Int8Array]"===n?i+="si08":"[object Uint8Array]"===n?i+="ui08":"[object Uint8ClampedArray]"===n?i+="uic8":"[object Int16Array]"===n?i+="si16":"[object Uint16Array]"===n?i+="ur16":"[object Int32Array]"===n?i+="si32":"[object Uint32Array]"===n?i+="ui32":"[object Float32Array]"===n?i+="fl32":"[object Float64Array]"===n?i+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(i+pt(r))}else if("[object Blob]"===n){var o=new FileReader;o.onload=function(){var n="~~local_forage_type~"+e.type+"~"+pt(this.result);t("__lfsc__:blob"+n)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if("__lfsc__:"!==e.substring(0,ut))return JSON.parse(e);var t,n=e.substring(dt),r=e.substring(ut,dt);if("blob"===r&<.test(n)){var i=n.match(lt);t=i[1],n=n.substring(i[0].length)}var o=ft(n);switch(r){case"arbf":return o;case"blob":return Ve([o],{type:t});case"si08":return new Int8Array(o);case"ui08":return new Uint8Array(o);case"uic8":return new Uint8ClampedArray(o);case"si16":return new Int16Array(o);case"ur16":return new Uint16Array(o);case"si32":return new Int32Array(o);case"ui32":return new Uint32Array(o);case"fl32":return new Float32Array(o);case"fl64":return new Float64Array(o);default:throw new Error("Unkown type: "+r)}},stringToBuffer:ft,bufferToString:pt};function gt(e,t,n,r){e.executeSql(`CREATE TABLE IF NOT EXISTS ${t.storeName} (id INTEGER PRIMARY KEY, key unique, value)`,[],n,r)}function vt(e,t,n,r,i,o){e.executeSql(n,r,i,(function(e,s){s.code===s.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,a){a.rows.length?o(e,s):gt(e,t,(function(){e.executeSql(n,r,i,o)}),o)}),o):o(e,s)}),o)}function yt(e,t,n,r){var i=this;e=He(e);var o=new Promise((function(o,s){i.ready().then((function(){void 0===t&&(t=null);var a=t,c=i._dbInfo;c.serializer.serialize(t,(function(t,l){l?s(l):c.db.transaction((function(n){vt(n,c,`INSERT OR REPLACE INTO ${c.storeName} (key, value) VALUES (?, ?)`,[e,t],(function(){o(a)}),(function(e,t){s(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(r>0)return void o(yt.apply(i,[e,a,n,r-1]));s(t)}}))}))})).catch(s)}));return Le(o,n),o}function bt(e){return new Promise((function(t,n){e.transaction((function(r){r.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,r){for(var i=[],o=0;o0}var xt={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=wt(e,this._defaultConfig),St()?(this._dbInfo=t,t.serializer=mt,Promise.resolve()):Promise.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,r=n.ready().then((function(){for(var t=n._dbInfo,r=t.keyPrefix,i=r.length,o=localStorage.length,s=1,a=0;a=0;n--){var r=localStorage.key(n);0===r.indexOf(e)&&localStorage.removeItem(r)}}));return Le(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return Le(t,e),t},key:function(e,t){var n=this,r=n.ready().then((function(){var t,r=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(r.keyPrefix.length)),t}));return Le(r,t),r},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,r=[],i=0;i=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):Promise.reject("Invalid arguments"),t),r}};const kt=(e,t)=>{const n=e.length;let r=0;for(;r{})}config(e){if("object"==typeof e){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(let t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config}defineDriver(e,t,n){const r=new Promise((function(t,n){try{const r=e._driver,i=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(i);const o=At.concat("_initStorage");for(let t=0,r=o.length;t(null===t._ready&&(t._ready=t._initDriver()),t._ready));return Fe(n,e,e),n}setDriver(e,t,n){const r=this;Pt(e)||(e=[e]);const i=this._getSupportedDrivers(e);function o(){r._config.driver=r.driver()}function s(e){return r._extend(e),o(),r._ready=r._initStorage(r._config),r._ready}const a=null!==this._driverSet?this._driverSet.catch(()=>Promise.resolve()):Promise.resolve();return this._driverSet=a.then(()=>{const e=i[0];return r._dbInfo=null,r._ready=null,r.getDriver(e).then(e=>{r._driver=e._driver,o(),r._wrapLibraryMethodsWithReady(),r._initDriver=function(e){return function(){let t=0;return function n(){for(;t{o();const e=new Error("No available storage method found.");return r._driverSet=Promise.reject(e),r._driverSet}),Fe(this._driverSet,t,n),this._driverSet}supports(e){return!!Nt[e]}_extend(e){Dt(this,e)}_getSupportedDrivers(e){const t=[];for(let n=0,r=e.length;n=43)}})).catch((function(){return!1}))}(e).then((function(e){return We=e,We}))}function Qe(e){var t=Je[e.name],n={};n.promise=new Promise((function(e,t){n.resolve=e,n.reject=t})),t.deferredOperations.push(n),t.dbReady?t.dbReady=t.dbReady.then((function(){return n.promise})):t.dbReady=n.promise}function Ge(e){var t=Je[e.name].deferredOperations.pop();if(t)return t.resolve(),t.promise}function Xe(e,t){var n=Je[e.name].deferredOperations.pop();if(n)return n.reject(t),n.promise}function et(e,t){return new Promise((function(n,i){if(Je[e.name]=Je[e.name]||{forages:[],db:null,dbReady:null,deferredOperations:[]},e.db){if(!t)return n(e.db);Qe(e),e.db.close()}var r=[e.name];t&&r.push(e.version);var o=Ve.open.apply(Ve,r);t&&(o.onupgradeneeded=function(t){var n=o.result;try{n.createObjectStore(e.storeName),t.oldVersion<=1&&n.createObjectStore("local-forage-detect-blob-support")}catch(n){if("ConstraintError"!==n.name)throw n;console.warn('The database "'+e.name+'" has been upgraded from version '+t.oldVersion+" to version "+t.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),o.onerror=function(e){e.preventDefault(),i(o.error)},o.onsuccess=function(){n(o.result),Ge(e)}}))}function tt(e){return et(e,!1)}function nt(e){return et(e,!0)}function it(e,t){if(!e.db)return!0;var n=!e.db.objectStoreNames.contains(e.storeName),i=e.versione.db.version;if(i&&(e.version!==t&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),r||n){if(n){var o=e.db.version+1;o>e.version&&(e.version=o)}return!0}return!1}function rt(e){return Fe([function(e){for(var t=e.length,n=new ArrayBuffer(t),i=new Uint8Array(n),r=0;r0&&(!e.db||"InvalidStateError"===r.name||"NotFoundError"===r.name))return Promise.resolve().then(()=>{if(!e.db||"NotFoundError"===r.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),nt(e)}).then(()=>function(e){Qe(e);for(var t=Je[e.name],n=t.forages,i=0;i(e.db=t,it(e)?nt(e):t)).then(i=>{e.db=t.db=i;for(var r=0;r{throw Xe(e,t),t})}(e).then((function(){st(e,t,n,i-1)}))).catch(n);n(r)}}var ct={_driver:"asyncStorage",_initStorage:function(e){var t=this,n={db:null};if(e)for(var i in e)n[i]=e[i];var r=Je[n.name];r||(r={forages:[],db:null,dbReady:null,deferredOperations:[]},Je[n.name]=r),r.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=at);var o=[];function a(){return Promise.resolve()}for(var s=0;s{const n=Je[e.name],i=n.forages;n.db=t;for(var r=0;r{if(!t.objectStoreNames.contains(e.storeName))return;const n=t.version+1;Qe(e);const i=Je[e.name],r=i.forages;t.close();for(let e=0;e{const r=Ve.open(e.name,n);r.onerror=e=>{r.result.close(),i(e)},r.onupgradeneeded=()=>{r.result.deleteObjectStore(e.storeName)},r.onsuccess=()=>{const e=r.result;e.close(),t(e)}}).then(e=>{i.db=e;for(let t=0;t{throw(Xe(e,t)||Promise.resolve()).catch(()=>{}),t})}):t.then(t=>{Qe(e);const n=Je[e.name],i=n.forages;t.close();for(var r=0;r{var i=Ve.deleteDatabase(e.name);i.onerror=i.onblocked=e=>{const t=i.result;t&&t.close(),n(e)},i.onsuccess=()=>{const e=i.result;e&&e.close(),t(e)}}).then(e=>{n.db=e;for(var t=0;t{throw(Xe(e,t)||Promise.resolve()).catch(()=>{}),t})})}else i=Promise.reject("Invalid arguments");return He(i,t),i}};var lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ut=/^~~local_forage_type~([^~]+)~/,dt="__lfsc__:".length,ht=dt+"arbf".length,ft=Object.prototype.toString;function pt(e){var t,n,i,r,o,a=.75*e.length,s=e.length,c=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var l=new ArrayBuffer(a),u=new Uint8Array(l);for(t=0;t>4,u[c++]=(15&i)<<4|r>>2,u[c++]=(3&r)<<6|63&o;return l}function mt(e){var t,n=new Uint8Array(e),i="";for(t=0;t>2],i+=lt[(3&n[t])<<4|n[t+1]>>4],i+=lt[(15&n[t+1])<<2|n[t+2]>>6],i+=lt[63&n[t+2]];return n.length%3==2?i=i.substring(0,i.length-1)+"=":n.length%3==1&&(i=i.substring(0,i.length-2)+"=="),i}var gt={serialize:function(e,t){var n="";if(e&&(n=ft.call(e)),e&&("[object ArrayBuffer]"===n||e.buffer&&"[object ArrayBuffer]"===ft.call(e.buffer))){var i,r="__lfsc__:";e instanceof ArrayBuffer?(i=e,r+="arbf"):(i=e.buffer,"[object Int8Array]"===n?r+="si08":"[object Uint8Array]"===n?r+="ui08":"[object Uint8ClampedArray]"===n?r+="uic8":"[object Int16Array]"===n?r+="si16":"[object Uint16Array]"===n?r+="ur16":"[object Int32Array]"===n?r+="si32":"[object Uint32Array]"===n?r+="ui32":"[object Float32Array]"===n?r+="fl32":"[object Float64Array]"===n?r+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(r+mt(i))}else if("[object Blob]"===n){var o=new FileReader;o.onload=function(){var n="~~local_forage_type~"+e.type+"~"+mt(this.result);t("__lfsc__:blob"+n)},o.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(n){console.error("Couldn't convert value into a JSON string: ",e),t(null,n)}},deserialize:function(e){if("__lfsc__:"!==e.substring(0,dt))return JSON.parse(e);var t,n=e.substring(ht),i=e.substring(dt,ht);if("blob"===i&&ut.test(n)){var r=n.match(ut);t=r[1],n=n.substring(r[0].length)}var o=pt(n);switch(i){case"arbf":return o;case"blob":return Fe([o],{type:t});case"si08":return new Int8Array(o);case"ui08":return new Uint8Array(o);case"uic8":return new Uint8ClampedArray(o);case"si16":return new Int16Array(o);case"ur16":return new Uint16Array(o);case"si32":return new Int32Array(o);case"ui32":return new Uint32Array(o);case"fl32":return new Float32Array(o);case"fl64":return new Float64Array(o);default:throw new Error("Unkown type: "+i)}},stringToBuffer:pt,bufferToString:mt};function vt(e,t,n,i){e.executeSql(`CREATE TABLE IF NOT EXISTS ${t.storeName} (id INTEGER PRIMARY KEY, key unique, value)`,[],n,i)}function yt(e,t,n,i,r,o){e.executeSql(n,i,r,(function(e,a){a.code===a.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],(function(e,s){s.rows.length?o(e,a):vt(e,t,(function(){e.executeSql(n,i,r,o)}),o)}),o):o(e,a)}),o)}function bt(e,t,n,i){var r=this;e=qe(e);var o=new Promise((function(o,a){r.ready().then((function(){void 0===t&&(t=null);var s=t,c=r._dbInfo;c.serializer.serialize(t,(function(t,l){l?a(l):c.db.transaction((function(n){yt(n,c,`INSERT OR REPLACE INTO ${c.storeName} (key, value) VALUES (?, ?)`,[e,t],(function(){o(s)}),(function(e,t){a(t)}))}),(function(t){if(t.code===t.QUOTA_ERR){if(i>0)return void o(bt.apply(r,[e,s,n,i-1]));a(t)}}))}))})).catch(a)}));return He(o,n),o}function _t(e){return new Promise((function(t,n){e.transaction((function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],(function(n,i){for(var r=[],o=0;o0}var kt={_driver:"localStorageWrapper",_initStorage:function(e){var t={};if(e)for(var n in e)t[n]=e[n];return t.keyPrefix=St(e,this._defaultConfig),xt()?(this._dbInfo=t,t.serializer=gt,Promise.resolve()):Promise.reject()},_support:function(){try{return"undefined"!=typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(e){return!1}}(),iterate:function(e,t){var n=this,i=n.ready().then((function(){for(var t=n._dbInfo,i=t.keyPrefix,r=i.length,o=localStorage.length,a=1,s=0;s=0;n--){var i=localStorage.key(n);0===i.indexOf(e)&&localStorage.removeItem(i)}}));return He(n,e),n},length:function(e){var t=this.keys().then((function(e){return e.length}));return He(t,e),t},key:function(e,t){var n=this,i=n.ready().then((function(){var t,i=n._dbInfo;try{t=localStorage.key(e)}catch(e){t=null}return t&&(t=t.substring(i.keyPrefix.length)),t}));return He(i,t),i},keys:function(e){var t=this,n=t.ready().then((function(){for(var e=t._dbInfo,n=localStorage.length,i=[],r=0;r=0;t--){var n=localStorage.key(t);0===n.indexOf(e)&&localStorage.removeItem(n)}})):Promise.reject("Invalid arguments"),t),i}};const Pt=(e,t)=>{const n=e.length;let i=0;for(;i{})}config(e){if("object"==typeof e){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(let t in e){if("storeName"===t&&(e[t]=e[t].replace(/\W/g,"_")),"version"===t&&"number"!=typeof e[t])return new Error("Database version must be a number.");this._config[t]=e[t]}return!("driver"in e)||!e.driver||this.setDriver(this._config.driver)}return"string"==typeof e?this._config[e]:this._config}defineDriver(e,t,n){const i=new Promise((function(t,n){try{const i=e._driver,r=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!e._driver)return void n(r);const o=Et.concat("_initStorage");for(let t=0,i=o.length;t(null===t._ready&&(t._ready=t._initDriver()),t._ready));return Le(n,e,e),n}setDriver(e,t,n){const i=this;Ot(e)||(e=[e]);const r=this._getSupportedDrivers(e);function o(){i._config.driver=i.driver()}function a(e){return i._extend(e),o(),i._ready=i._initStorage(i._config),i._ready}const s=null!==this._driverSet?this._driverSet.catch(()=>Promise.resolve()):Promise.resolve();return this._driverSet=s.then(()=>{const e=r[0];return i._dbInfo=null,i._ready=null,i.getDriver(e).then(e=>{i._driver=e._driver,o(),i._wrapLibraryMethodsWithReady(),i._initDriver=function(e){return function(){let t=0;return function n(){for(;t{o();const e=new Error("No available storage method found.");return i._driverSet=Promise.reject(e),i._driverSet}),Le(this._driverSet,t,n),this._driverSet}supports(e){return!!Nt[e]}_extend(e){jt(this,e)}_getSupportedDrivers(e){const t=[];for(let n=0,i=e.length;ne.length>t?e.slice(0,t)+"...":e,zt=(e,t,n,r)=>([...e.matchAll(/\[\[\[ (.*?) \]\]\]/g)].map(e=>e[1]).forEach(i=>{const o=`[[[ ${i} ]]]`;try{const s=new Function("entity","variables","configuration",i);e=e.replace(o,s(r,t,n))}catch(t){e=e.replace(o,"error")}}),e);console.info("%c uptime-card \n 0.15.0 ","color: white; background-color: #C6B145; font-weight: 700;"),window.customCards=window.customCards||[],window.customCards.push({type:"uptime-card",name:"Uptime Card",description:"The uptime card show you the history of your binary sensors in a cool way."});let Ut=class extends Ie{constructor(){super(...arguments),this.lastUpdate=0}static async getConfigElement(){return document.createElement("uptime-card-editor")}static getStubConfig(){return{}}set hass(e){const t=(new Date).getTime();t-this.lastUpdate<1e3*this.config.update_interval||(this._hass=e,this.updateData(),this.lastUpdate=t)}get actions(){return["more-info","url","navigate","toggle","call-service","fire-dom-event"]}setConfig(e){if(!e)throw new Error("Invalid configuration !");this.config=Object.assign(Object.assign(Object.assign({},Te),e),{color:Object.assign(Object.assign({},Ae),e.color),alias:Object.assign({},e.alias),show:Object.assign(Object.assign({},Ee),e.show),bar:Object.assign(Object.assign({},$e),e.bar),tooltip:Object.assign(Object.assign({},De),e.tooltip),tap_action:Object.assign(Object.assign({},je),e.tap_action),alignment:Object.assign(Object.assign({},Me),e.alignment),init:Object.assign(Object.assign({},Re),e.init),clip:Object.assign(Object.assign({},Be),e.clip)}),"string"==typeof this.config.ok&&(this.config.ok=[this.config.ok]),"string"==typeof this.config.ko&&(this.config.ko=[this.config.ko]),null!=this.config.ok&&(this.config.ok=this.config.ok.map(e=>e.toString())),null!=this.config.ko&&(this.config.ko=this.config.ko.map(e=>e.toString())),this.updateData()}shouldUpdate(e){return!!this.config&&function(e,t,n){if(t.has("config")||n)return!0;if(e.config.entity){var r=t.get("hass");return!r||r.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1}(this,e,!1)}firstUpdated(e){this.updateData()}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.interval&&clearInterval(this.interval),super.disconnectedCallback()}async updateData(){if(null==this.config||null==this._hass)return;const{entity:e,hours_to_show:t,attribute:n}=this.config;if(this.sensor!=this._hass.states[this.config.entity]&&(this.sensor=this._hass.states[this.config.entity],null==this.sensor))return;const r=this.getStatus();if(null==r)return void(this.cache={points:[],lastFetched:-1,lastChanged:-1,hoursToShow:t});const i=n?`${e}#${n}`:e,o=await this.getCache(i);let s;null!=o&&(this.cache=o);const a=null==o||o.hoursToShowe.x>this.getMinimumDate()),m=0==p?f:f.slice(p-1),g=this.cleanPoints(m);if(g.length>0)s={points:g,lastFetched:d,lastChanged:g[g.length-1].x,hoursToShow:t};else{const e=new Date(this.sensor.last_changed).getTime();s={points:[{x:e,y:r}],lastFetched:d,lastChanged:e,hoursToShow:t}}await this.setCache(i,s),this.cache=s}async getCache(e){const t=await Mt.getItem(e);return null==t?(console.warn(`Can't load the key ${e} from cache.`),null):(n=t,JSON.parse(n));var n}async setCache(e,t){return Mt.setItem(e,(n=t,JSON.stringify(n)));var n}isOk(e){const{ok:t,ko:n,entity:r,none:i}=this.config;if(null!=e){if(null==t?void 0:t.includes(e))return!0;if(null==n?void 0:n.includes(e))return!1;if(!(null==i?void 0:i.includes(e))){if(null==t&&null==n){const t=r.startsWith("binary_sensor.")||r.startsWith("switch.")||r.startsWith("input_boolean.");return null!=r&&t?"on"==e||"off"!=e&&void 0:void 0}return null==t}}}findBarPeriod(e){const{bar:t}=this.config,n=this.getUptimeSize()/t.amount,r=(new Date).getTime()-(t.amount-1-e)*n;return{from:r-n+1,to:r}}findBarRepartition(e){var t,n;const r={ok:0,ko:0,none:100};if(null==this.cache)return r;const i=this.cache.points.findIndex(t=>t.x>=e.from),o=this.cache.points.findIndex(t=>t.x>e.to);let s;if(0==this.cache.points.length)return r;if(-1==i)s=[this.cache.points[this.cache.points.length-1]];else{if(0==i&&0==o)return r;{const e=0==i?0:1,t=-1==o?this.cache.points.length:o;s=this.cache.points.slice(i-e,t)}}const a={ok:0,ko:0,none:0},c=e.to-e.from;for(let r=0;r{const t=r?e.attributes[r]:e.state;return{x:new Date(e.last_changed).getTime(),y:t}}):[]}cleanPoints(e){const t=[];let n=void 0;for(const r of e)r.y!=n&&(t.push(r),n=r.y);return t}handleClick(e){e.stopPropagation(),this.config&&this._hass&&k(this,this._hass,this.config,!1,!1)}computeBarColor(e){const{severity:t,color:n,color_thresholds:r}=this.config;if(100==e.none)return n.none;if(r){const t=r.slice().sort((e,t)=>e.value-t.value).find(t=>t.value>=e.ok);return t?t.color:n.none}return 100==e.ok?n.ok:e.ko>=t?n.ko:n.half}attachBlink(e){const t=this.config.blink;return this.isOk(this.getStatus())||!t||e!=t.target||"card"!=t.target&&"shadow"==t.effect?"":`animation: blink-${t.effect} ${t.speed}s infinite;`}render(){const{bar:e}=this.config,t=[...Array(e.amount).keys()].map((e,t)=>{const n=this.findBarPeriod(t);return{period:n,repartition:this.findBarRepartition(n),index:t}});return ce` +`,zt=(e,t)=>e.length>t?e.slice(0,t)+"...":e,Ut=(e,t,n,i)=>([...e.matchAll(/\[\[\[ (.*?) \]\]\]/g)].map(e=>e[1]).forEach(r=>{const o=`[[[ ${r} ]]]`;try{const a=new Function("entity","variables","configuration",r);e=e.replace(o,a(i,t,n))}catch(t){e=e.replace(o,"error")}}),e);console.info("%c uptime-card \n 0.16.0 ","color: white; background-color: #C6B145; font-weight: 700;"),window.customCards=window.customCards||[],window.customCards.push({type:"uptime-card",name:"Uptime Card",description:"The uptime card show you the history of your binary sensors in a cool way."});let Vt=class extends Ie{constructor(){super(...arguments),this.lastUpdate=0}static async getConfigElement(){return document.createElement("uptime-card-editor")}static getStubConfig(){return{}}set hass(e){const t=(new Date).getTime();t-this.lastUpdate<1e3*this.config.update_interval||(this._hass=e,this.updateData(),this.lastUpdate=t)}get actions(){return["more-info","url","navigate","toggle","call-service","fire-dom-event"]}setConfig(e){if(!e)throw new Error("Invalid configuration !");const t=void 0!==e.hours_to_show?{quantity:e.hours_to_show,unit:"hour"}:{};this.config=Object.assign(Object.assign(Object.assign({},Te),e),{color:Object.assign(Object.assign({},Ae),e.color),alias:Object.assign({},e.alias),show:Object.assign(Object.assign({},Ee),e.show),bar:Object.assign(Object.assign({},$e),e.bar),tooltip:Object.assign(Object.assign({},De),e.tooltip),tap_action:Object.assign(Object.assign({},je),e.tap_action),alignment:Object.assign(Object.assign({},Me),e.alignment),init:Object.assign(Object.assign({},Re),e.init),clip:Object.assign(Object.assign({},Be),e.clip),duration:Object.assign(Object.assign(Object.assign({},ze),t),e.duration)}),"string"==typeof this.config.ok&&(this.config.ok=[this.config.ok]),"string"==typeof this.config.ko&&(this.config.ko=[this.config.ko]),null!=this.config.ok&&(this.config.ok=this.config.ok.map(e=>e.toString())),null!=this.config.ko&&(this.config.ko=this.config.ko.map(e=>e.toString())),this.updateData()}shouldUpdate(e){return!!this.config&&function(e,t,n){if(t.has("config")||n)return!0;if(e.config.entity){var i=t.get("hass");return!i||i.states[e.config.entity]!==e.hass.states[e.config.entity]}return!1}(this,e,!1)}firstUpdated(e){this.updateData()}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.interval&&clearInterval(this.interval),super.disconnectedCallback()}async updateData(){if(null==this.config||null==this._hass)return;const{entity:e,duration:t,attribute:n}=this.config,i=this.durationToHoursToShow(t);if(this.sensor!=this._hass.states[this.config.entity]&&(this.sensor=this._hass.states[this.config.entity],null==this.sensor))return;const r=this.getStatus();if(null==r)return void(this.cache={points:[],lastFetched:-1,lastChanged:-1,hoursToShow:i});const o=n?`${e}#${n}`:e,a=await this.getCache(o);let s;null!=a&&(this.cache=a);const c=null==a||a.hoursToShowe.x>this.getMinimumDate()),g=0==m?p:p.slice(m-1),v=this.cleanPoints(g);if(v.length>0)s={points:v,lastFetched:h,lastChanged:v[v.length-1].x,hoursToShow:i};else{const e=new Date(this.sensor.last_changed).getTime();s={points:[{x:e,y:r}],lastFetched:h,lastChanged:e,hoursToShow:i}}await this.setCache(o,s),this.cache=s}async getCache(e){const t=await Rt.getItem(e);return null==t?(console.warn(`Can't load the key ${e} from cache.`),null):(n=t,JSON.parse(n));var n}async setCache(e,t){return Rt.setItem(e,(n=t,JSON.stringify(n)));var n}isOk(e){const{ok:t,ko:n,entity:i,none:r}=this.config;if(null!=e){if(null==t?void 0:t.includes(e))return!0;if(null==n?void 0:n.includes(e))return!1;if(!(null==r?void 0:r.includes(e))){if(null==t&&null==n){const t=i.startsWith("binary_sensor.")||i.startsWith("switch.")||i.startsWith("input_boolean.");return null!=i&&t?"on"==e||"off"!=e&&void 0:void 0}return null==t}}}findBarPeriod(e){const{bar:t}=this.config,n=this.getUptimeSize()/t.amount,i=(new Date).getTime()-(t.amount-1-e)*n;return{from:i-n+1,to:i}}findBarRepartition(e){var t,n;const i={ok:0,ko:0,none:100};if(null==this.cache)return i;const r=this.cache.points.findIndex(t=>t.x>=e.from),o=this.cache.points.findIndex(t=>t.x>e.to);let a;if(0==this.cache.points.length)return i;if(-1==r)a=[this.cache.points[this.cache.points.length-1]];else{if(0==r&&0==o)return i;{const e=0==r?0:1,t=-1==o?this.cache.points.length:o;a=this.cache.points.slice(r-e,t)}}const s={ok:0,ko:0,none:0},c=e.to-e.from;for(let i=0;i{const t=i?e.attributes[i]:e.state;return{x:new Date(e.last_changed).getTime(),y:t}}):[]}cleanPoints(e){const t=[];let n=void 0;for(const i of e)i.y!=n&&(t.push(i),n=i.y);return t}handleClick(e){e.stopPropagation(),this.config&&this._hass&&k(this,this._hass,this.config,!1,!1)}computeBarColor(e){const{severity:t,color:n,color_thresholds:i}=this.config;if(100==e.none)return n.none;if(i){const t=i.slice().sort((e,t)=>e.value-t.value).find(t=>t.value>=e.ok);return t?t.color:n.none}return 100==e.ok?n.ok:e.ko>=t?n.ko:n.half}attachBlink(e){const t=this.config.blink;return this.isOk(this.getStatus())||!t||e!=t.target||"card"!=t.target&&"shadow"==t.effect?"":`animation: blink-${t.effect} ${t.speed}s infinite;`}render(){const{bar:e}=this.config,t=[...Array(e.amount).keys()].map((e,t)=>{const n=this.findBarPeriod(t);return{period:n,repartition:this.findBarRepartition(n),index:t}});return ce` ${this.renderInformation()} ${this.renderTimeline(t)} ${this.renderFooter(t.map(e=>e.repartition))} @@ -458,61 +458,61 @@ found at http://polymer.github.io/PATENTS.txt
${this.renderTitle()} ${this.renderIcon()}
- `:ce``}renderTitle(){const{color:e,title_adaptive_color:t,show:n,title_template:r}=this.config,i=zt(r,{},this.config,this.sensor);return n.title?ce` + `:ce``}renderTitle(){const{color:e,title_adaptive_color:t,show:n,title_template:i}=this.config,r=Ut(i,{},this.config,this.sensor);return n.title?ce`
${Bt(i,this.config.clip.title)}${zt(r,this.config.clip.title)}
`:ce``}renderStatus(){const{show:e,alignment:t}=this.config;return e.status?ce`
${this.renderState()} ${this.renderTooltip()}
- `:ce``}renderState(){const{alias:e,color:t,status_adaptive_color:n,status_template:r,ok:i,ko:o}=this.config;let s;s=null==this.sensor?"Unknown":1==this.isOk(this.getStatus())&&e.ok?e.ok:0==this.isOk(this.getStatus())&&e.ko?e.ko:null==this.isOk(this.getStatus())?"Unknown":this.getStatus()||"Unknown";const a=zt(r,{current:s,ok:e.ok||i||"[[[ return variables.ok ]]]",ko:e.ko||o||"[[[ return variables.ko ]]]"},this.config,this.sensor);return ce` + `:ce``}renderState(){const{alias:e,color:t,status_adaptive_color:n,status_template:i,ok:r,ko:o}=this.config;let a;a=null==this.sensor?"Unknown":1==this.isOk(this.getStatus())&&e.ok?e.ok:0==this.isOk(this.getStatus())&&e.ko?e.ko:null==this.isOk(this.getStatus())?"Unknown":this.getStatus()||"Unknown";const s=Ut(i,{current:a,ok:e.ok||r||"[[[ return variables.ok ]]]",ko:e.ko||o||"[[[ return variables.ko ]]]"},this.config,this.sensor);return ce` ${Bt(a,this.config.clip.status)}${zt(s,this.config.clip.status)} - `}renderTooltip(){const{hours_to_show:e,tooltip:t,tooltip_adaptive_color:n,color:r}=this.config;if(null==this.tooltip)return ce``;const i={hour:"numeric",minute:"numeric",hour12:0==t.hour24},o=Object.assign(Object.assign({},i),{weekday:"short",day:"numeric"}),s=this._hass.language,a=e<=24?i:o,c=new Date(this.tooltip.period.from).toLocaleString(s,a),l=new Date(this.tooltip.period.to).toLocaleString(s,i),u=this.tooltip.repartition.ok.toFixed(2),d=zt(t.template,{from_date:c,to_date:l,average:u},this.config,this.sensor);let h=r.tooltip;return n&&(h=100==this.tooltip.repartition.ok?r.ok:100==this.tooltip.repartition.ko?r.ko:100==this.tooltip.repartition.none?r.none:r.half),ce` - ${d} - `}renderIcon(){var e;const{icon:t,ko_icon:n,none_icon:r,show:i,icon_adaptive_color:o,color:s}=this.config,a=this.isOk(this.getStatus()),c=void 0===a&&r?r:!1===a&&n?n:t,l=!1===a&&s.ko_icon?s.ko_icon:s.icon,u=c||(null===(e=this.sensor)||void 0===e?void 0:e.attributes.icon)||"mdi:heart",d=`background-image: url(${u}); background-size: cover;`,h=(null==u?void 0:u.startsWith("/local"))||(null==u?void 0:u.startsWith("http"))?ce` + `}durationToHoursToShow(e){switch(e.unit){case"minute":return e.quantity/60;case"hour":return e.quantity;case"day":return 24*e.quantity;case"week":return 24*e.quantity*7;case"month":return 24*e.quantity*30;case"year":return 24*e.quantity*30*12}}durationToFormatOptions(e,t){const n={hour:"numeric",minute:"numeric",second:"numeric",hour12:0==t},i={hour:"numeric",minute:"numeric",hour12:0==t},r={weekday:"short",day:"numeric"},o=Object.assign(Object.assign({},i),r),a=Object.assign(Object.assign({},i),r),s=Object.assign(Object.assign(Object.assign({},r),{month:"short"}),{year:"numeric"});switch(e.unit){case"minute":return[n,n];case"hour":return[o,i];case"day":return[o,o];case"week":return[a,a];case"month":case"year":return[s,s]}}renderTooltip(){const{duration:e,tooltip:t,tooltip_adaptive_color:n,color:i}=this.config;if(null==this.tooltip)return ce``;const r=this._hass.language,[o,a]=this.durationToFormatOptions(e,t.hour24),s=new Date(this.tooltip.period.from).toLocaleString(r,o),c=new Date(this.tooltip.period.to).toLocaleString(r,a),l=this.tooltip.repartition.ok.toFixed(2),u=Ut(t.template,{from_date:s,to_date:c,average:l},this.config,this.sensor);let d=i.tooltip;return n&&(d=100==this.tooltip.repartition.ok?i.ok:100==this.tooltip.repartition.ko?i.ko:100==this.tooltip.repartition.none?i.none:i.half),ce` + ${u} + `}renderIcon(){var e;const{icon:t,ko_icon:n,none_icon:i,show:r,icon_adaptive_color:o,color:a}=this.config,s=this.isOk(this.getStatus()),c=void 0===s&&i?i:!1===s&&n?n:t,l=!1===s&&a.ko_icon?a.ko_icon:a.icon,u=c||(null===(e=this.sensor)||void 0===e?void 0:e.attributes.icon)||"mdi:heart",d=`background-image: url(${u}); background-size: cover;`,h=(null==u?void 0:u.startsWith("/local"))||(null==u?void 0:u.startsWith("http"))?ce`
`:ce` - `;return i.icon?ce` + `;return r.icon?ce`
${h}
- `:""}renderTimeline(e){const{show:t,bar:n,tooltip:r}=this.config,i=t.status&&r.animation,o=i?n.height+5:n.height,s=n.spacing*(n.amount-1),a=Math.floor((500-s)/n.amount),c=500-s-a*n.amount;if(0==t.timeline)return"";const l=e.map((e,t)=>{var r;const o=this.computeBarColor(e.repartition),s=(null===(r=this.tooltip)||void 0===r?void 0:r.index)==t&&i,l=s?n.height+5:n.height,u=i?s?0:5:0;return this.renderBar(t,t*(a+n.spacing)+c/2,u,a,l,n.amount,o,n.round,e)});return ce` + `:""}renderTimeline(e){const{show:t,bar:n,tooltip:i}=this.config,r=t.status&&i.animation,o=r?n.height+5:n.height,a=n.spacing*(n.amount-1),s=Math.floor((500-a)/n.amount),c=500-a-s*n.amount;if(0==t.timeline)return"";const l=e.map((e,t)=>{var i;const o=this.computeBarColor(e.repartition),a=(null===(i=this.tooltip)||void 0===i?void 0:i.index)==t&&r,l=a?n.height+5:n.height,u=r?a?0:5:0;return this.renderBar(t,t*(s+n.spacing)+c/2,u,s,l,n.amount,o,n.round,e)});return ce`
${l}
- `}getInitAnimationCss(e,t,n,r){const i="cubic-bezier(0.11, 0.95, 0.66, 1)";if("none"==n)return"";if("raise"==n)return`\n transform: scaleY(0);\n animation: raise ${r}s ${i} forwards;\n `;if("reveal"==n)return`\n opacity: 0;\n animation: reveal ${r}s ${i} forwards;\n `;const o=r/t;return`\n opacity: 0;\n animation: reveal ${o}s ${i} forwards;\n animation-delay: ${e*o}s;\n `}renderBar(e,t,n,r,i,o,s,a,c){const{init:l}=this.config,u=this.getInitAnimationCss(e,o,l.animation,l.duration);return le` + `}getInitAnimationCss(e,t,n,i){const r="cubic-bezier(0.11, 0.95, 0.66, 1)";if("none"==n)return"";if("raise"==n)return`\n transform: scaleY(0);\n animation: raise ${i}s ${r} forwards;\n `;if("reveal"==n)return`\n opacity: 0;\n animation: reveal ${i}s ${r} forwards;\n `;const o=i/t;return`\n opacity: 0;\n animation: reveal ${o}s ${r} forwards;\n animation-delay: ${e*o}s;\n `}renderBar(e,t,n,i,r,o,a,s,c){const{init:l}=this.config,u=this.getInitAnimationCss(e,o,l.animation,l.duration);return le` this.tooltip=c} @mouseout=${()=>this.tooltip=void 0}> - >`}renderFooter(e){const{show:t,color:n}=this.config,r=this.generateMinimalDate()||"The future";return t.footer&&t.timeline&&r?ce` + >`}renderFooter(e){const{show:t,color:n}=this.config,i=this.generateMinimalDate();return t.footer&&t.timeline&&i?ce` - `:ce``}renderAverage(e){const{show:t,average_template:n}=this.config,r=e.reduce((e,t)=>e+t.ok,0)/e.length,i=zt(n,{uptime:r},this.config,this.sensor);return t.average?ce` - - `:ce``}generateMinimalDate(){const{hours_to_show:e}=this.config;if(0==e)return"Now";if(e%168==0){const t=e/168;return 1==t?"1 week ago":t+" weeks ago"}if(e%24==0){const t=e/24;return 1==t?"1 day ago":t+" days ago"}if(e>=1)return 1==e?"1 hour ago":e+" hours ago";if(e>0){const t=Math.round(60*e);return 1==t?"1 min ago":t+" mins ago"}return null}renderLine(e){return ce` + `:ce``}renderAverage(e){const{show:t,average_template:n}=this.config,i=e.reduce((e,t)=>e+t.ok,0)/e.length,r=Ut(n,{uptime:i},this.config,this.sensor);return t.average?ce` + + `:ce``}generateMinimalDate(){const{duration:e}=this.config;if(e.quantity<=0)return"Now";switch(e.unit){case"minute":return 1==e.quantity?"1 min ago":e.quantity+" mins ago";case"hour":return 1==e.quantity?"1 hour ago":e.quantity+" hours ago";case"day":return 1==e.quantity?"1 day ago":e.quantity+" days ago";case"week":return 1==e.quantity?"1 week ago":e.quantity+" weeks ago";case"month":return 1==e.quantity?"1 month ago":e.quantity+" months ago";case"year":return 1==e.quantity?"1 year ago":e.quantity+" years ago"}}renderLine(e){return ce`
- `}static get styles(){return Rt}};e([Se({attribute:!1})],Ut.prototype,"_hass",void 0),e([xe()],Ut.prototype,"config",void 0),e([xe()],Ut.prototype,"sensor",void 0),e([xe()],Ut.prototype,"interval",void 0),e([xe()],Ut.prototype,"cache",void 0),e([xe()],Ut.prototype,"tooltip",void 0),e([xe()],Ut.prototype,"lastUpdate",void 0),Ut=e([_e("uptime-card")],Ut);export{Ut as UptimeCard}; + `}static get styles(){return Bt}};e([Se({attribute:!1})],Vt.prototype,"_hass",void 0),e([xe()],Vt.prototype,"config",void 0),e([xe()],Vt.prototype,"sensor",void 0),e([xe()],Vt.prototype,"interval",void 0),e([xe()],Vt.prototype,"cache",void 0),e([xe()],Vt.prototype,"tooltip",void 0),e([xe()],Vt.prototype,"lastUpdate",void 0),Vt=e([_e("uptime-card")],Vt);export{Vt as UptimeCard}; diff --git a/www/community/uptime-card/uptime-card.js.gz b/www/community/uptime-card/uptime-card.js.gz index 34da0a91..cd70553e 100644 Binary files a/www/community/uptime-card/uptime-card.js.gz and b/www/community/uptime-card/uptime-card.js.gz differ