Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

home-assistant-javascript-templates

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

home-assistant-javascript-templates - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

2

dist/esm/index.js

@@ -1,1 +0,1 @@

var e,t,s=/^([a-z]+)\.(\w+)$/;!function(e){e.UNKNOWN="unknown",e.UNAVAILABLE="unavailable"}(e||(e={})),function(e){e.AREA_ID="area_id",e.NAME="name"}(t||(t={}));var i=function(e){return e.includes(".")};function r(r){var a=function(){return Object.entries(r.hass.areas)};return{get hass(){return r.hass},states:new Proxy((function(e){var t;if(i(e))return null===(t=r.hass.states[e])||void 0===t?void 0:t.state;throw SyntaxError("".concat("[home-assistant-javascript-templates]",": states method cannot be used with a domain, use it as an object instead."))}),{get:function(e,t){return i(t)?r.hass.states[t]:Object.entries(r.hass.states).filter((function(e){return e[0].startsWith(t)})).reduce((function(e,t){var i=t[0],r=t[1];return e[i.replace(s,"$2")]=r,e}),{})}}),is_state:function(e,t){var s;return(null===(s=r.hass.states[e])||void 0===s?void 0:s.state)===t},state_attr:function(e,t){var s,i;return null===(i=null===(s=r.hass.states[e])||void 0===s?void 0:s.attributes)||void 0===i?void 0:i[t]},is_state_attr:function(e,t,s){return this.state_attr(e,t)===s},has_value:function(t){return!!this.states(t)&&!(this.is_state(t,e.UNKNOWN)||this.is_state(t,e.UNAVAILABLE))},device_attr:function(e,t){var s;return null===(s=r.hass.devices[e])||void 0===s?void 0:s[t]},is_device_attr:function(e,t,s){return this.device_attr(e,t)===s},device_id:function(e){var t;return null===(t=r.hass.entities[e])||void 0===t?void 0:t.device_id},areas:function(){return a().map((function(e){return e[1].area_id}))},area_id:function(e){var s;if(e in r.hass.devices)return this.device_attr(e,t.AREA_ID);var i=this.device_id(e);if(i)return this.device_attr(i,t.AREA_ID);var n=a().find((function(t){return t[1].name===e}));return null===(s=null==n?void 0:n[1])||void 0===s?void 0:s.area_id},area_name:function(e){var s,i;e in r.hass.devices&&(i=this.device_attr(e,t.AREA_ID));var n=this.device_id(e);n&&(i=this.device_attr(n,t.AREA_ID));var d=a().find((function(t){var s=t[1];return s.area_id===e||s.area_id===i}));return null===(s=null==d?void 0:d[1])||void 0===s?void 0:s.name},area_entities:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.entities).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[0]})):[]},area_devices:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.devices).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[1].id})):[]},get user_name(){return r.hass.user.name},get user_is_admin(){return r.hass.user.is_admin},get user_is_owner(){return r.hass.user.is_owner}}}var a=function(){function e(e,t){void 0===t&&(t=!1),this._scopped=r(e),this._errors=t}return e.prototype.renderTemplate=function(e){var t=e.includes("return")?e:"return ".concat(e),s=new Function("hass","states","is_state","state_attr","is_state_attr","has_value","device_attr","is_device_attr","device_id","areas","area_id","area_name","area_entities","area_devices","user_name","user_is_admin","user_is_owner","".concat('"use strict";'," ").concat(t));try{return s(this._scopped.hass,this._scopped.states,this._scopped.is_state.bind(this._scopped),this._scopped.state_attr.bind(this._scopped),this._scopped.is_state_attr.bind(this._scopped),this._scopped.has_value.bind(this._scopped),this._scopped.device_attr.bind(this._scopped),this._scopped.is_device_attr.bind(this._scopped),this._scopped.device_id.bind(this._scopped),this._scopped.areas.bind(this._scopped),this._scopped.area_id.bind(this._scopped),this._scopped.area_name.bind(this._scopped),this._scopped.area_entities.bind(this._scopped),this._scopped.area_devices.bind(this._scopped),this._scopped.user_name,this._scopped.user_is_admin,this._scopped.user_is_owner)}catch(e){if(this._errors)throw e;return void console.warn(e)}},e}();export{a as default};
var e,t,s=/^([a-z_]+)\.(\w+)$/;!function(e){e.UNKNOWN="unknown",e.UNAVAILABLE="unavailable"}(e||(e={})),function(e){e.AREA_ID="area_id",e.NAME="name"}(t||(t={}));var i=function(e){return e.includes(".")};function r(r){var a=function(){return Object.entries(r.hass.areas)};return{get hass(){return r.hass},states:new Proxy((function(e){var t;if(i(e))return null===(t=r.hass.states[e])||void 0===t?void 0:t.state;throw SyntaxError("".concat("[home-assistant-javascript-templates]",": states method cannot be used with a domain, use it as an object instead."))}),{get:function(e,t){return i(t)?r.hass.states[t]:Object.entries(r.hass.states).filter((function(e){return e[0].startsWith(t)})).reduce((function(e,t){var i=t[0],r=t[1];return e[i.replace(s,"$2")]=r,e}),{})}}),is_state:function(e,t){var s;return(null===(s=r.hass.states[e])||void 0===s?void 0:s.state)===t},state_attr:function(e,t){var s,i;return null===(i=null===(s=r.hass.states[e])||void 0===s?void 0:s.attributes)||void 0===i?void 0:i[t]},is_state_attr:function(e,t,s){return this.state_attr(e,t)===s},has_value:function(t){return!!this.states(t)&&!(this.is_state(t,e.UNKNOWN)||this.is_state(t,e.UNAVAILABLE))},device_attr:function(e,t){var s;return null===(s=r.hass.devices[e])||void 0===s?void 0:s[t]},is_device_attr:function(e,t,s){return this.device_attr(e,t)===s},device_id:function(e){var t;return null===(t=r.hass.entities[e])||void 0===t?void 0:t.device_id},areas:function(){return a().map((function(e){return e[1].area_id}))},area_id:function(e){var s;if(e in r.hass.devices)return this.device_attr(e,t.AREA_ID);var i=this.device_id(e);if(i)return this.device_attr(i,t.AREA_ID);var n=a().find((function(t){return t[1].name===e}));return null===(s=null==n?void 0:n[1])||void 0===s?void 0:s.area_id},area_name:function(e){var s,i;e in r.hass.devices&&(i=this.device_attr(e,t.AREA_ID));var n=this.device_id(e);n&&(i=this.device_attr(n,t.AREA_ID));var d=a().find((function(t){var s=t[1];return s.area_id===e||s.area_id===i}));return null===(s=null==d?void 0:d[1])||void 0===s?void 0:s.name},area_entities:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.entities).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[0]})):[]},area_devices:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.devices).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[1].id})):[]},get user_name(){return r.hass.user.name},get user_is_admin(){return r.hass.user.is_admin},get user_is_owner(){return r.hass.user.is_owner}}}var a=function(){function e(e,t){void 0===t&&(t=!1),this._scopped=r(e),this._errors=t}return e.prototype.renderTemplate=function(e){var t=e.includes("return")?e:"return ".concat(e),s=new Function("hass","states","is_state","state_attr","is_state_attr","has_value","device_attr","is_device_attr","device_id","areas","area_id","area_name","area_entities","area_devices","user_name","user_is_admin","user_is_owner","".concat('"use strict";'," ").concat(t));try{return s(this._scopped.hass,this._scopped.states,this._scopped.is_state.bind(this._scopped),this._scopped.state_attr.bind(this._scopped),this._scopped.is_state_attr.bind(this._scopped),this._scopped.has_value.bind(this._scopped),this._scopped.device_attr.bind(this._scopped),this._scopped.is_device_attr.bind(this._scopped),this._scopped.device_id.bind(this._scopped),this._scopped.areas.bind(this._scopped),this._scopped.area_id.bind(this._scopped),this._scopped.area_name.bind(this._scopped),this._scopped.area_entities.bind(this._scopped),this._scopped.area_devices.bind(this._scopped),this._scopped.user_name,this._scopped.user_is_admin,this._scopped.user_is_owner)}catch(e){if(this._errors)throw e;return void console.warn(e)}},e}();export{a as default};

@@ -1,1 +0,1 @@

"use strict";var e,t,s=/^([a-z]+)\.(\w+)$/;!function(e){e.UNKNOWN="unknown",e.UNAVAILABLE="unavailable"}(e||(e={})),function(e){e.AREA_ID="area_id",e.NAME="name"}(t||(t={}));var i=function(e){return e.includes(".")};function r(r){var a=function(){return Object.entries(r.hass.areas)};return{get hass(){return r.hass},states:new Proxy((function(e){var t;if(i(e))return null===(t=r.hass.states[e])||void 0===t?void 0:t.state;throw SyntaxError("".concat("[home-assistant-javascript-templates]",": states method cannot be used with a domain, use it as an object instead."))}),{get:function(e,t){return i(t)?r.hass.states[t]:Object.entries(r.hass.states).filter((function(e){return e[0].startsWith(t)})).reduce((function(e,t){var i=t[0],r=t[1];return e[i.replace(s,"$2")]=r,e}),{})}}),is_state:function(e,t){var s;return(null===(s=r.hass.states[e])||void 0===s?void 0:s.state)===t},state_attr:function(e,t){var s,i;return null===(i=null===(s=r.hass.states[e])||void 0===s?void 0:s.attributes)||void 0===i?void 0:i[t]},is_state_attr:function(e,t,s){return this.state_attr(e,t)===s},has_value:function(t){return!!this.states(t)&&!(this.is_state(t,e.UNKNOWN)||this.is_state(t,e.UNAVAILABLE))},device_attr:function(e,t){var s;return null===(s=r.hass.devices[e])||void 0===s?void 0:s[t]},is_device_attr:function(e,t,s){return this.device_attr(e,t)===s},device_id:function(e){var t;return null===(t=r.hass.entities[e])||void 0===t?void 0:t.device_id},areas:function(){return a().map((function(e){return e[1].area_id}))},area_id:function(e){var s;if(e in r.hass.devices)return this.device_attr(e,t.AREA_ID);var i=this.device_id(e);if(i)return this.device_attr(i,t.AREA_ID);var n=a().find((function(t){return t[1].name===e}));return null===(s=null==n?void 0:n[1])||void 0===s?void 0:s.area_id},area_name:function(e){var s,i;e in r.hass.devices&&(i=this.device_attr(e,t.AREA_ID));var n=this.device_id(e);n&&(i=this.device_attr(n,t.AREA_ID));var d=a().find((function(t){var s=t[1];return s.area_id===e||s.area_id===i}));return null===(s=null==d?void 0:d[1])||void 0===s?void 0:s.name},area_entities:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.entities).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[0]})):[]},area_devices:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.devices).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[1].id})):[]},get user_name(){return r.hass.user.name},get user_is_admin(){return r.hass.user.is_admin},get user_is_owner(){return r.hass.user.is_owner}}}var a=function(){function e(e,t){void 0===t&&(t=!1),this._scopped=r(e),this._errors=t}return e.prototype.renderTemplate=function(e){var t=e.includes("return")?e:"return ".concat(e),s=new Function("hass","states","is_state","state_attr","is_state_attr","has_value","device_attr","is_device_attr","device_id","areas","area_id","area_name","area_entities","area_devices","user_name","user_is_admin","user_is_owner","".concat('"use strict";'," ").concat(t));try{return s(this._scopped.hass,this._scopped.states,this._scopped.is_state.bind(this._scopped),this._scopped.state_attr.bind(this._scopped),this._scopped.is_state_attr.bind(this._scopped),this._scopped.has_value.bind(this._scopped),this._scopped.device_attr.bind(this._scopped),this._scopped.is_device_attr.bind(this._scopped),this._scopped.device_id.bind(this._scopped),this._scopped.areas.bind(this._scopped),this._scopped.area_id.bind(this._scopped),this._scopped.area_name.bind(this._scopped),this._scopped.area_entities.bind(this._scopped),this._scopped.area_devices.bind(this._scopped),this._scopped.user_name,this._scopped.user_is_admin,this._scopped.user_is_owner)}catch(e){if(this._errors)throw e;return void console.warn(e)}},e}();module.exports=a;
"use strict";var e,t,s=/^([a-z_]+)\.(\w+)$/;!function(e){e.UNKNOWN="unknown",e.UNAVAILABLE="unavailable"}(e||(e={})),function(e){e.AREA_ID="area_id",e.NAME="name"}(t||(t={}));var i=function(e){return e.includes(".")};function r(r){var a=function(){return Object.entries(r.hass.areas)};return{get hass(){return r.hass},states:new Proxy((function(e){var t;if(i(e))return null===(t=r.hass.states[e])||void 0===t?void 0:t.state;throw SyntaxError("".concat("[home-assistant-javascript-templates]",": states method cannot be used with a domain, use it as an object instead."))}),{get:function(e,t){return i(t)?r.hass.states[t]:Object.entries(r.hass.states).filter((function(e){return e[0].startsWith(t)})).reduce((function(e,t){var i=t[0],r=t[1];return e[i.replace(s,"$2")]=r,e}),{})}}),is_state:function(e,t){var s;return(null===(s=r.hass.states[e])||void 0===s?void 0:s.state)===t},state_attr:function(e,t){var s,i;return null===(i=null===(s=r.hass.states[e])||void 0===s?void 0:s.attributes)||void 0===i?void 0:i[t]},is_state_attr:function(e,t,s){return this.state_attr(e,t)===s},has_value:function(t){return!!this.states(t)&&!(this.is_state(t,e.UNKNOWN)||this.is_state(t,e.UNAVAILABLE))},device_attr:function(e,t){var s;return null===(s=r.hass.devices[e])||void 0===s?void 0:s[t]},is_device_attr:function(e,t,s){return this.device_attr(e,t)===s},device_id:function(e){var t;return null===(t=r.hass.entities[e])||void 0===t?void 0:t.device_id},areas:function(){return a().map((function(e){return e[1].area_id}))},area_id:function(e){var s;if(e in r.hass.devices)return this.device_attr(e,t.AREA_ID);var i=this.device_id(e);if(i)return this.device_attr(i,t.AREA_ID);var n=a().find((function(t){return t[1].name===e}));return null===(s=null==n?void 0:n[1])||void 0===s?void 0:s.area_id},area_name:function(e){var s,i;e in r.hass.devices&&(i=this.device_attr(e,t.AREA_ID));var n=this.device_id(e);n&&(i=this.device_attr(n,t.AREA_ID));var d=a().find((function(t){var s=t[1];return s.area_id===e||s.area_id===i}));return null===(s=null==d?void 0:d[1])||void 0===s?void 0:s.name},area_entities:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.entities).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[0]})):[]},area_devices:function(e){var t=a().find((function(t){var s=t[1];return s.area_id===e||s.name===e}));return t?Object.entries(r.hass.devices).filter((function(e){return e[1].area_id===t[1].area_id})).map((function(e){return e[1].id})):[]},get user_name(){return r.hass.user.name},get user_is_admin(){return r.hass.user.is_admin},get user_is_owner(){return r.hass.user.is_owner}}}var a=function(){function e(e,t){void 0===t&&(t=!1),this._scopped=r(e),this._errors=t}return e.prototype.renderTemplate=function(e){var t=e.includes("return")?e:"return ".concat(e),s=new Function("hass","states","is_state","state_attr","is_state_attr","has_value","device_attr","is_device_attr","device_id","areas","area_id","area_name","area_entities","area_devices","user_name","user_is_admin","user_is_owner","".concat('"use strict";'," ").concat(t));try{return s(this._scopped.hass,this._scopped.states,this._scopped.is_state.bind(this._scopped),this._scopped.state_attr.bind(this._scopped),this._scopped.is_state_attr.bind(this._scopped),this._scopped.has_value.bind(this._scopped),this._scopped.device_attr.bind(this._scopped),this._scopped.is_device_attr.bind(this._scopped),this._scopped.device_id.bind(this._scopped),this._scopped.areas.bind(this._scopped),this._scopped.area_id.bind(this._scopped),this._scopped.area_name.bind(this._scopped),this._scopped.area_entities.bind(this._scopped),this._scopped.area_devices.bind(this._scopped),this._scopped.user_name,this._scopped.user_is_admin,this._scopped.user_is_owner)}catch(e){if(this._errors)throw e;return void console.warn(e)}},e}();module.exports=a;
{
"name": "home-assistant-javascript-templates",
"version": "3.0.0",
"version": "3.0.1",
"description": "A JavaScript utility to render Home Assistant JavaScript templates",

@@ -49,4 +49,4 @@ "keywords": [

"@rollup/plugin-terser": "^0.4.4",
"@types/jest": "^29.5.11",
"@types/node": "^20.11.9",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.16",
"jest": "^29.7.0",

@@ -53,0 +53,0 @@ "rollup": "^4.9.6",

@@ -57,3 +57,3 @@ # home-assistant-javascript-templates

The package exposes a class that needs to be instantiated and is this isntance the one that you need to use in your code.
The package exposes a class that needs to be instantiated and is this instance the one that you need to use in your code.

@@ -60,0 +60,0 @@ ### HomeAssistantJavaScriptTemplates class

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc