author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
748,240 | 30.04.2018 01:17:19 | 14,400 | 7600a3aa5ae91082a00f7b3552f8cfa4e806cbed | docker npm scripts changed to reflect last commits directory name change | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"docker:down\": \"npm run docker -- down -vt5 && npm run docker -- rm -fv\",\n\"docker:restart\": \"npm run docker -- restart\",\n\"docker:logs\": \"npm run docker -- logs -f && true\",\n- \"docker\": \"docker-compose -f _docker/docker-compose.yml\",\n- \"docker-map\": \"docker-compose -f _docker/docker-compose.mapped.yml\"\n+ \"docker\": \"docker-compose -f docker/docker-compose.yml\",\n+ \"docker-map\": \"docker-compose -f docker/docker-compose.mapped.yml\",\n+ \"clean\": \"npm run docker:down\"\n},\n\"repository\": {\n\"type\": \"git\",\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | docker npm scripts changed to reflect last commits directory name change |
748,240 | 02.05.2018 01:27:49 | 14,400 | 174c195179028c1ec424e60613708e25971f5646 | Added some pass/fail tests to flows.json | [
{
"change_type": "MODIFY",
"old_path": "docker/node-red/root-fs/data/flows.json",
"new_path": "docker/node-red/root-fs/data/flows.json",
"diff": "\"data\": \"{ \\\"entity_id\\\": \\\" input_select.time_of_day\\\" }\",\n\"mergecontext\": \"\",\n\"x\": 530,\n- \"y\": 160,\n+ \"y\": 100,\n\"wires\": [\n[\n- \"385c435d.e8072c\"\n+ \"ea2f46e7.871258\"\n]\n]\n},\n- {\n- \"id\": \"385c435d.e8072c\",\n- \"type\": \"debug\",\n- \"z\": \"63d2914d.5ea9b\",\n- \"name\": \"log data sent to ha\",\n- \"active\": false,\n- \"tosidebar\": false,\n- \"console\": false,\n- \"tostatus\": true,\n- \"complete\": \"payload\",\n- \"x\": 770,\n- \"y\": 160,\n- \"wires\": []\n- },\n{\n\"id\": \"fdd917f1.fb3a08\",\n\"type\": \"inject\",\n\"y\": 160,\n\"wires\": [\n[\n- \"4ef7a108.d71d6\"\n+ \"eba49a.66b6cb68\"\n]\n]\n},\n\"entityidfilter\": \"input_select.time_of_day\",\n\"entityidfiltertype\": \"substring\",\n\"haltifstate\": \"\",\n- \"x\": 1210,\n- \"y\": 60,\n+ \"x\": 1410,\n+ \"y\": 80,\n\"wires\": [\n[\n\"8544614e.23128\"\n\"console\": false,\n\"tostatus\": true,\n\"complete\": \"payload\",\n- \"x\": 1440,\n- \"y\": 60,\n+ \"x\": 1640,\n+ \"y\": 80,\n\"wires\": []\n},\n{\n\"y\": 220,\n\"wires\": [\n[\n- \"4ef7a108.d71d6\"\n+ \"f59a907f.7f08b8\"\n]\n]\n},\n\"y\": 400,\n\"wires\": [\n[\n- \"a6459db0.df6ab\"\n+ \"9175adc1.7cf5c\"\n]\n]\n},\n- {\n- \"id\": \"a6459db0.df6ab\",\n- \"type\": \"debug\",\n- \"z\": \"63d2914d.5ea9b\",\n- \"name\": \"log data sent to ha\",\n- \"active\": true,\n- \"tosidebar\": true,\n- \"console\": false,\n- \"tostatus\": false,\n- \"complete\": \"payload\",\n- \"x\": 1250,\n- \"y\": 400,\n- \"wires\": []\n- },\n{\n\"id\": \"79d6048a.91be0c\",\n\"type\": \"inject\",\n\"y\": 440,\n\"wires\": [\n[\n- \"70a67972.83cc58\"\n+ \"2517417.5e2073e\"\n]\n]\n},\n\"x\": 1020,\n\"y\": 660,\n\"wires\": [\n- []\n+ [\n+ \"85b385c4.952628\"\n+ ]\n]\n},\n{\n\"name\": \"Get Time of Day\",\n\"server\": \"4780c192.bc0f2\",\n\"halt_if\": \"\",\n+ \"override_topic\": true,\n+ \"override_payload\": true,\n\"entity_id\": \"input_select.time_of_day\",\n- \"x\": 320,\n+ \"x\": 360,\n\"y\": 120,\n\"wires\": [\n[\n\"name\": \"Get Time of Day, Halt if 'Morning'\",\n\"server\": \"4780c192.bc0f2\",\n\"halt_if\": \"Morning\",\n+ \"override_topic\": true,\n+ \"override_payload\": true,\n\"entity_id\": \"input_select.time_of_day\",\n\"x\": 380,\n\"y\": 260,\n\"z\": \"ae2a9159.be871\",\n\"name\": \"Get History\",\n\"server\": \"4780c192.bc0f2\",\n- \"startdate\": \"2018-02-14T13:00:00+00:00\",\n+ \"startdate\": \"2018-05-02T20:00:00+00:00\",\n\"x\": 290,\n\"y\": 80,\n\"wires\": [\n\"x\": 960,\n\"y\": 520,\n\"wires\": []\n+ },\n+ {\n+ \"id\": \"ea2f46e7.871258\",\n+ \"type\": \"function\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"[TEST] API payload data is correct\",\n+ \"func\": \"const testStatus = msg.testStatus = { passed: true, text: 'Test Passed', datetime: new Date(), shape: 'dot', fill: 'green' };\\n\\nconst { domain, service, data } = msg.payload;\\n\\n// FIXME: entity_id is getting an extra space at start from somewhere? API call still works but this should be cleaned up\\nif (domain !== 'input_select' || service !== 'select_next' || !data || data.entity_id !== ' input_select.time_of_day' ) {\\n testStatus.passed = false; \\n testStatus.text = 'Test Failed';\\n testStatus.fill = 'red';\\n}\\n\\nnode.status(testStatus);\\nreturn msg;\\n\",\n+ \"outputs\": 1,\n+ \"noerr\": 0,\n+ \"x\": 820,\n+ \"y\": 100,\n+ \"wires\": [\n+ [\n+ \"a5ae821e.65219\"\n+ ]\n+ ]\n+ },\n+ {\n+ \"id\": \"9175adc1.7cf5c\",\n+ \"type\": \"function\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"[TEST] state === 'Afternoon'\",\n+ \"func\": \"// Test that state is actually changed withing home assistant\\n\\nsetTimeout(() => {\\n const haCtx = global.get('homeassistant').homeAssistant;\\n const inputState = haCtx.states['input_select.time_of_day'];\\n\\n if (inputState.state !== 'Afternoon') {\\n const text = 'Test Failed: Expected \\\"Afternoon\\\"';\\n node.status({ shape: 'dot', fill: 'red', text })\\n throw new Error(text);\\n } else {\\n const text = 'Test Passed';\\n node.status({ shape: 'dot', fill: 'green', text })\\n node.send(msg);\\n }\\n}, 100);\\n\\nreturn;\\n\",\n+ \"outputs\": 1,\n+ \"noerr\": 0,\n+ \"x\": 1280,\n+ \"y\": 380,\n+ \"wires\": [\n+ []\n+ ]\n+ },\n+ {\n+ \"id\": \"2517417.5e2073e\",\n+ \"type\": \"api-call-service\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"time of day: select option using context\",\n+ \"server\": \"4780c192.bc0f2\",\n+ \"service_domain\": \"input_select\",\n+ \"service\": \"select_option\",\n+ \"data\": \"{ \\\"entity_id\\\": \\\" input_select.time_of_day\\\" }\",\n+ \"mergecontext\": \"timeOfDayOption\",\n+ \"x\": 960,\n+ \"y\": 440,\n+ \"wires\": [\n+ [\n+ \"978dccc.f7e38b\"\n+ ]\n+ ]\n+ },\n+ {\n+ \"id\": \"978dccc.f7e38b\",\n+ \"type\": \"function\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"[TEST] state === 'Morning'\",\n+ \"func\": \"// Test that state is actually changed withing home assistant\\n\\nsetTimeout(() => {\\n const haCtx = global.get('homeassistant').homeAssistant;\\n const inputState = haCtx.states['input_select.time_of_day'];\\n\\n if (inputState.state !== 'Morning') {\\n const text = 'Test Failed: Expected \\\"Afternoon\\\"';\\n node.status({ shape: 'dot', fill: 'red', text })\\n throw new Error(text);\\n } else {\\n const text = 'Test Passed';\\n node.status({ shape: 'dot', fill: 'green', text })\\n node.send(msg);\\n }\\n}, 100);\\n\\nreturn;\\n\",\n+ \"outputs\": 1,\n+ \"noerr\": 0,\n+ \"x\": 1280,\n+ \"y\": 460,\n+ \"wires\": [\n+ []\n+ ]\n+ },\n+ {\n+ \"id\": \"85b385c4.952628\",\n+ \"type\": \"function\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"[TEST] state === 'Morning'\",\n+ \"func\": \"// Test that state is actually changed withing home assistant\\n\\nsetTimeout(() => {\\n const haCtx = global.get('homeassistant').homeAssistant;\\n const inputState = haCtx.states['input_select.time_of_day'];\\n\\n if (inputState.state !== 'Morning') {\\n const text = 'Test Failed: Expected \\\"Afternoon\\\"';\\n node.status({ shape: 'dot', fill: 'red', text })\\n throw new Error(text);\\n } else {\\n const text = 'Test Passed';\\n node.status({ shape: 'dot', fill: 'green', text })\\n node.send(msg);\\n }\\n}, 100);\\n\\nreturn;\\n\",\n+ \"outputs\": 1,\n+ \"noerr\": 0,\n+ \"x\": 1360,\n+ \"y\": 660,\n+ \"wires\": [\n+ []\n+ ]\n+ },\n+ {\n+ \"id\": \"a5ae821e.65219\",\n+ \"type\": \"debug\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"log result\",\n+ \"active\": true,\n+ \"tosidebar\": true,\n+ \"console\": false,\n+ \"tostatus\": true,\n+ \"complete\": \"true\",\n+ \"x\": 1120,\n+ \"y\": 160,\n+ \"wires\": []\n+ },\n+ {\n+ \"id\": \"eba49a.66b6cb68\",\n+ \"type\": \"api-call-service\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"Time of Day: Select Next\",\n+ \"server\": \"4780c192.bc0f2\",\n+ \"service_domain\": \"input_select\",\n+ \"service\": \"select_next\",\n+ \"data\": \"{ \\\"entity_id\\\": \\\" input_select.time_of_day\\\" }\",\n+ \"mergecontext\": \"\",\n+ \"x\": 530,\n+ \"y\": 160,\n+ \"wires\": [\n+ [\n+ \"4b8fe84d.98e11\"\n+ ]\n+ ]\n+ },\n+ {\n+ \"id\": \"4b8fe84d.98e11\",\n+ \"type\": \"function\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"[TEST] API payload data is correct\",\n+ \"func\": \"const testStatus = msg.testStatus = { passed: true, text: 'Test Passed', datetime: new Date(), shape: 'dot', fill: 'green' };\\nconst { domain, service, data } = msg.payload;\\n\\n// FIXME: entity_id is getting an extra space at start from somewhere? API call still works but this should be cleaned up\\nif (domain !== 'input_select' || service !== 'select_previous' || !data || data.entity_id !== ' input_select.time_of_day' ) {\\n testStatus.passed = false; \\n testStatus.text = 'Test Failed';\\n testStatus.fill = 'red';\\n}\\n\\nnode.status(testStatus);\\nreturn msg;\\n\",\n+ \"outputs\": 1,\n+ \"noerr\": 0,\n+ \"x\": 820,\n+ \"y\": 160,\n+ \"wires\": [\n+ [\n+ \"a5ae821e.65219\"\n+ ]\n+ ]\n+ },\n+ {\n+ \"id\": \"f59a907f.7f08b8\",\n+ \"type\": \"api-call-service\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"Time of Day: Select Next\",\n+ \"server\": \"4780c192.bc0f2\",\n+ \"service_domain\": \"input_select\",\n+ \"service\": \"select_next\",\n+ \"data\": \"{ \\\"entity_id\\\": \\\" input_select.time_of_day\\\" }\",\n+ \"mergecontext\": \"\",\n+ \"x\": 530,\n+ \"y\": 220,\n+ \"wires\": [\n+ [\n+ \"d3e9c8b5.ea3958\"\n+ ]\n+ ]\n+ },\n+ {\n+ \"id\": \"d3e9c8b5.ea3958\",\n+ \"type\": \"function\",\n+ \"z\": \"63d2914d.5ea9b\",\n+ \"name\": \"[TEST] API payload data is correct\",\n+ \"func\": \"const testStatus = msg.testStatus = { passed: true, text: 'Test Passed', datetime: new Date(), shape: 'dot', fill: 'green' };\\n\\nconst { domain, service, data } = msg.payload;\\n\\n// FIXME: entity_id is getting an extra space at start from somewhere? API call still works but this should be cleaned up\\nif (domain !== 'input_select' || service !== 'select_option' || !data || data.entity_id !== ' input_select.time_of_day' || data.option !== 'Party Time' ) {\\n testStatus.passed = false; \\n testStatus.text = 'Test Failed';\\n testStatus.fill = 'red';\\n}\\n\\nnode.status(testStatus);\\nreturn msg;\\n\",\n+ \"outputs\": 1,\n+ \"noerr\": 0,\n+ \"x\": 820,\n+ \"y\": 220,\n+ \"wires\": [\n+ [\n+ \"a5ae821e.65219\"\n+ ]\n+ ]\n}\n]\n\\ No newline at end of file\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added some pass/fail tests to flows.json |
748,240 | 03.05.2018 14:43:59 | 14,400 | 26d32ac3cd525b69c9e41212918041c8bae6084d | Added enddate & entityid options for history node | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_get-history/api_get-history.html",
"new_path": "nodes/api_get-history/api_get-history.html",
"diff": "defaults: {\nname: { value: '' },\nserver: { value: '', type: 'server', required: true },\n- startdate: { value: '' }\n+ startdate: { value: '' },\n+ enddate: { value: '' },\n+ entityid: { value: '' }\n},\ninputs: 1,\noutputs: 1,\n</script>\n-<script type=\"text/x-red\" data-template-name=\"api-get-history\">\n+<script type=\"text/html\" data-template-name=\"api-get-history\">\n<div class=\"form-row\">\n<label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n<input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n<input type=\"text\" id=\"node-input-startdate\" autofocus=\"autofocus\" />\n</div>\n+ <div class=\"form-row\">\n+ <label for=\"node-input-enddate\"><i class=\"fa fa-date\"></i> End Date</label>\n+ <input type=\"text\" id=\"node-input-enddate\" />\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-entityid\"><i class=\"fa fa-date\"></i> Entity ID</label>\n+ <input type=\"text\" id=\"node-input-entityid\" />\n+ </div>\n+\n<div class=\"form-tips\">\n<ul>\n<li>\n- <code>startdate</code> must be in ISO format, example: \"2018-01-27T13:00:00+00:00\"\n+ dates must be in ISO format, example: \"2018-01-27T13:00:00+00:00\"\n</li>\n</ul>\n</div>\n</script>\n-<script type=\"text/x-red\" data-help-name=\"api-get-history\">\n+<script type=\"text/html\" data-help-name=\"api-get-history\">\n<p>Fetches history from Home Assistant (all history for the past day by default)</p>\n<h3>Inputs</h3>\nstartdate <span class=\"property-type\">string | date</span>\n</dt>\n<dd>Date to start fetching history from. Will override the nodes configuration if passed in</dd>\n+\n+ <dt class=\"optional\">\n+ enddate <span class=\"property-type\">string | date</span>\n+ </dt>\n+ <dd>Date to fetch history to. Will override the nodes configuration if passed in</dd>\n+\n+ <dt class=\"optional\">\n+ entityid <span class=\"property-type\">string</span>\n+ </dt>\n+ <dd>Exact entity_id to fetch history for, must be an exact match as is passed directly to the home-assistant api</dd>\n</dl>\n<h3>Outputs</h3>\nstartdate <span class=\"property-type\">string</span>\n</dt>\n<dd>ISO date string used to fetch history</dd>\n+ <dt>\n+ enddate <span class=\"property-type\">string</span>\n+ </dt>\n+ <dd>ISO date string used to fetch history</dd>\n+ <dt>\n+ entityid <span class=\"property-type\">string</span>\n+ </dt>\n+ <dd>entityid string used during fetch history call</dd>\n</dl>\n<h3>Details</h3>\n<h3>References</h3>\n<ul>\n<li><a href=\"https://home-assistant.io/components/history\">HA History Component</a></li>\n- <li><a href=\"https://home-assistant.io/developers/rest_api\">HA API: /api/history/period</a></li>\n+ <li><a href=\"https://developers.home-assistant.io/docs/en/external_api_rest.html#get-api-history-period-lt-timestamp\">HA API: /api/history/period</a></li>\n</ul>\n</script>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/api_get-history/api_get-history.js",
"new_path": "nodes/api_get-history/api_get-history.js",
"diff": "@@ -5,9 +5,11 @@ module.exports = function(RED) {\nconst nodeOptions = {\ndebug: true,\nconfig: {\n- startdate: {},\nname: {},\n- server: { isNode: true }\n+ server: { isNode: true },\n+ startdate: {},\n+ enddate: {},\n+ entityid: {}\n},\ninput: {\nstartdate: {\n@@ -19,6 +21,15 @@ module.exports = function(RED) {\nreturn yesterday.toISOString();\n},\nvalidation: { haltOnFail: true, schema: Joi.date().optional().allow('') }\n+ },\n+ enddate: {\n+ messageProp: 'enddate',\n+ configProp: 'enddate',\n+ validation: { haltOnFail: true, schema: Joi.date().optional().allow('') }\n+ },\n+ entityid: {\n+ messageProp: 'entityid',\n+ configProp: 'entityid'\n}\n}\n};\n@@ -29,12 +40,16 @@ module.exports = function(RED) {\n}\nonInput({ parsedMessage, message }) {\n- let { startdate } = parsedMessage;\n+ let { startdate, enddate, entityid } = parsedMessage;\nstartdate = startdate.value;\n+ enddate = enddate.value;\n+ entityid = entityid.value;\n- return this.nodeConfig.server.api.getHistory(startdate)\n+ return this.nodeConfig.server.api.getHistory(startdate, entityid, enddate)\n.then(res => {\nmessage.startdate = startdate;\n+ message.enddate = enddate || null;\n+ message.entityid = entityid || null;\nmessage.payload = res;\nthis.send(message);\n})\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added enddate & entityid options for history node |
748,247 | 03.05.2018 13:51:22 | 25,200 | 33974af33365eb0f7fa2de2f07b3f5daaa1ad403 | Update api_call-service.js | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_call-service/api_call-service.js",
"new_path": "nodes/api_call-service/api_call-service.js",
"diff": "@@ -49,6 +49,8 @@ module.exports = function(RED) {\nif (!apiService) throw new Error('call service node is missing api \"service\" property, not found in config or payload');\nthis.debug(`Calling Service: ${apiDomain}:${apiService} -- ${JSON.stringify(apiData || {})}`);\n+ var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n+ this.status({fill:\"green\",shape:\"dot\",text:`${apiDomain}.${apiService} called at: ${prettyDate}`});\nthis.send({\npayload: {\n@@ -62,6 +64,7 @@ module.exports = function(RED) {\n.catch(err => {\nthis.warn('Error calling service, home assistant api error', err);\nthis.error('Error calling service, home assistant api error', message);\n+ this.status({fill:\"red\",shape:\"ring\",text:`API Error at: ${prettyDate}`});\n});\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Update api_call-service.js |
748,240 | 03.05.2018 20:54:41 | 14,400 | 9880a932ca6c97d28884498704816a59ca244546 | Fix for getting RED.settings.userDir | [
{
"change_type": "MODIFY",
"old_path": "lib/base-node.js",
"new_path": "lib/base-node.js",
"diff": "@@ -69,7 +69,7 @@ class BaseNode {\ntry {\nif (DB) return DB;\n- let dbLocation = this.RED.settings.get('userDir');\n+ let dbLocation = this.RED.settings.userDir;\nif (!dbLocation) throw new Error('Could not find userDir to use for database store');\ndbLocation += '/node-red-contrib-home-assistant.json';\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | #45 - Fix for getting RED.settings.userDir |
748,240 | 04.05.2018 22:55:32 | 14,400 | c6719c08d79cbdf9867ca93da0052322181a25bb | History node now supports end date and entity id filtering | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_get-history/api_get-history.html",
"new_path": "nodes/api_get-history/api_get-history.html",
"diff": "server: { value: '', type: 'server', required: true },\nstartdate: { value: '' },\nenddate: { value: '' },\n- entityid: { value: '' }\n+ entityid: { value: '' },\n+ entityidtype: { value: '' }\n},\ninputs: 1,\noutputs: 1,\noneditprepare: function() {\nconst NODE = this;\nconst $server = $('#node-input-server');\n+ NODE.entityidtype = NODE.entityidtype || 'is';\n+ $('#node-input-entityidtype').val(NODE.entityidtype);\n+\nconst utils = {\nsetDefaultServerSelection: function () {\nlet defaultServer;\n<input type=\"text\" id=\"node-input-enddate\" />\n</div>\n+ <!-- Comparator Selection -->\n<div class=\"form-row\">\n<label for=\"node-input-entityid\"><i class=\"fa fa-date\"></i> Entity ID</label>\n- <input type=\"text\" id=\"node-input-entityid\" />\n+\n+ <select type=\"text\" id=\"node-input-entityidtype\" style=\"width: 80px;\">\n+ <option value=\"is\">Is</option>\n+ <option value=\"includes\">Includes</option>\n+ </select>\n+\n+ <input type=\"text\" id=\"node-input-entityid\" style=\"width: 52%;\"/>\n</div>\n<div class=\"form-tips\">\npayload <span class=\"property-type\">array</span>\n</dt>\n<dd>The history returned by home-assistant, which is an array of arrays where each array entry contains history objects for one particular entity</dd>\n+\n<dt>\nstartdate <span class=\"property-type\">string</span>\n</dt>\n<dd>ISO date string used to fetch history</dd>\n+\n<dt>\nenddate <span class=\"property-type\">string</span>\n</dt>\n<dd>ISO date string used to fetch history</dd>\n+\n<dt>\nentityid <span class=\"property-type\">string</span>\n</dt>\n<dd>entityid string used during fetch history call</dd>\n+\n+ <dt>\n+ entityidtype <span class=\"property-type\">string</span>\n+ </dt>\n+ <dd>'is' or 'includes' depending on match type. NOTE: 'includes' fetches all history for time period then filters according to value, this will be less performant than exact ('is') matching</dd>\n</dl>\n<h3>Details</h3>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/api_get-history/api_get-history.js",
"new_path": "nodes/api_get-history/api_get-history.js",
"diff": "@@ -9,7 +9,8 @@ module.exports = function(RED) {\nserver: { isNode: true },\nstartdate: {},\nenddate: {},\n- entityid: {}\n+ entityid: {},\n+ entityidtype: {}\n},\ninput: {\nstartdate: {\n@@ -30,6 +31,10 @@ module.exports = function(RED) {\nentityid: {\nmessageProp: 'entityid',\nconfigProp: 'entityid'\n+ },\n+ entityidtype: {\n+ messageProp: 'entityidtype',\n+ configProp: 'entityidtype'\n}\n}\n};\n@@ -40,12 +45,16 @@ module.exports = function(RED) {\n}\nonInput({ parsedMessage, message }) {\n- let { startdate, enddate, entityid } = parsedMessage;\n+ let { startdate, enddate, entityid, entityidtype } = parsedMessage;\nstartdate = startdate.value;\nenddate = enddate.value;\nentityid = entityid.value;\n- return this.nodeConfig.server.api.getHistory(startdate, entityid, enddate)\n+ let apiRequest = (entityidtype.value === 'includes' && entityid)\n+ ? this.nodeConfig.server.api.getHistory(startdate, null, enddate, { include: new RegExp(entityid) })\n+ : this.nodeConfig.server.api.getHistory(startdate, entityid, enddate);\n+\n+ return apiRequest\n.then(res => {\nmessage.startdate = startdate;\nmessage.enddate = enddate || null;\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | #11 - History node now supports end date and entity id filtering |
748,240 | 04.05.2018 22:55:51 | 14,400 | dd901a64b11d931b06926ba4e66c691efa1365ad | Cleaned up some more docker dev env configuration for home assistant | [
{
"change_type": "MODIFY",
"old_path": "docker/home-assistant/root-fs/config/configuration.yaml",
"new_path": "docker/home-assistant/root-fs/config/configuration.yaml",
"diff": "@@ -14,25 +14,18 @@ logger:\ndefault: !env_var HA_LOGGER_DEFAULT\nrecorder:\n- purge_interval: 2\n- purge_keep_days: 1\n-\n+logbook:\nfrontend:\nconfig:\nhistory:\nmap:\nsun:\n-weblink:\n- entities:\n- - name: Node Red\n- url: !env_var NODE_RED_URL\n-\npanel_iframe:\nnode_red:\ntitle: Node Red\nurl: !env_var NODE_RED_URL\n- icon: mdi:grid-on\n+ icon: mdi:sitemap\nalarm_control_panel:\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Cleaned up some more docker dev env configuration for home assistant |
748,247 | 16.05.2018 15:52:10 | 25,200 | a02503ba5174eba24fc39b9c1beb7bbd1d9809a4 | fixed status for api-current-state and server state changed nodes | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -40,18 +40,14 @@ module.exports = function(RED) {\nif (!states) return logAndContinueEmpty('local state cache missing, sending empty payload');\nconst currentState = states[entity_id];\n- var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"green\",shape:\"dot\",text:`${currentState.state} at: ${prettyDate}`});\n- if (!currentState) return {\n- logAndContinueEmpty(`entity could not be found in cache for entity_id: ${entity_id}, sending empty payload`);\n- this.status({fill:\"yellow\",shape:\"dot\",text:`Entity not found! Continuing. at: ${prettyDate}`});\n+ if (!currentState) return logAndContinueEmpty(`entity could not be found in cache for entity_id: ${entity_id}, sending empty payload`);\nconst shouldHaltIfState = this.nodeConfig.halt_if && (currentState.state === this.nodeConfig.halt_if);\nif (shouldHaltIfState) {\nconst debugMsg = `Get current state: halting processing due to current state of ${entity_id} matches \"halt if state\" option`;\nthis.debug(debugMsg);\nthis.debugToClient(debugMsg);\n- this.status({fill:\"yellow\",shape:\"ring\",text:`halted: ${currentState.state} at: ${prettyDate}`});\n+ this.status({fill:\"yellow\",shape:\"ring\",text:`Halted: ${currentState.state} at: ${prettyDate}`});\nreturn null;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/server-events-state-changed/server-events-state-changed.js",
"new_path": "nodes/server-events-state-changed/server-events-state-changed.js",
"diff": "@@ -32,7 +32,7 @@ module.exports = function(RED) {\nif (shouldHaltIfState) {\nthis.debug('flow halted due to \"halt if state\" setting');\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"yellow\",shape:\"ring\",text:`Halted: Event: ${event} at: ${prettyDate}'});\n+ this.status({fill:\"yellow\",shape:\"ring\",text:`halted: Event: ${event} at: ${prettyDate}`});\nreturn null;\n}\n@@ -49,7 +49,7 @@ module.exports = function(RED) {\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"green\",shape:\"dot\",text:`Event: ${event} at: ${prettyDate}'});\n+ this.status({fill:\"green\",shape:\"dot\",text:`Event: ${event} at: ${prettyDate}`});\nreturn this.send(msg);\n}\nreturn null;\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | fixed status for api-current-state and server state changed nodes |
748,247 | 16.05.2018 15:58:34 | 25,200 | 3050a471ad1dd26222756ae969f535a116d41b41 | re-add success status to api-call-service | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -59,7 +59,8 @@ module.exports = function(RED) {\n} else {\nRED.util.setMessageProperty(message, this.nodeConfig.property, currentState);\n}\n-\n+ var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n+ this.status({fill:\"green\",shape:\"dot\",text:`${currentState.state} at: ${prettyDate}`});\nthis.node.send(message);\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | re-add success status to api-call-service |
748,247 | 17.05.2018 13:55:41 | 25,200 | 8a83733078f20e83311b1a6a9a4ccdd7fce17879 | fixed state changed errors | [
{
"change_type": "MODIFY",
"old_path": "nodes/server-events-state-changed/server-events-state-changed.js",
"new_path": "nodes/server-events-state-changed/server-events-state-changed.js",
"diff": "@@ -29,10 +29,11 @@ module.exports = function(RED) {\nconst shouldHaltIfState = this.shouldHaltIfState(event);\nconst shouldIncludeEvent = this.shouldIncludeEvent(entity_id);\n+ if (shouldIncludeEvent) {\nif (shouldHaltIfState) {\nthis.debug('flow halted due to \"halt if state\" setting');\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"yellow\",shape:\"ring\",text:`halted: Event: ${event} at: ${prettyDate}`});\n+ this.status({fill:\"yellow\",shape:\"ring\",text:`${event.new_state.state} at: ${prettyDate}`});\nreturn null;\n}\n@@ -42,14 +43,13 @@ module.exports = function(RED) {\ndata: event\n};\n- if (shouldIncludeEvent) {\n+ var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n+ this.status({fill:\"green\",shape:\"dot\",text:`${event.new_state.state} at: ${prettyDate}`});\n(event.old_state)\n? this.debug(`Incoming state event: entity_id: ${event.entity_id}, new_state: ${event.new_state.state}, old_state: ${event.old_state.state}`)\n: this.debug(`Incoming state event: entity_id: ${event.entity_id}, new_state: ${event.new_state.state}`);\n- var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"green\",shape:\"dot\",text:`Event: ${event} at: ${prettyDate}`});\nreturn this.send(msg);\n}\nreturn null;\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | fixed state changed errors |
748,247 | 17.05.2018 15:26:47 | 25,200 | 977780d700ef722e0181ad6a9ec5662b8cbd1e59 | prioritised config over input for api-current-state | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -31,7 +31,7 @@ module.exports = function(RED) {\n/* eslint-disable camelcase */\nonInput({ parsedMessage, message }) {\n- const entity_id = parsedMessage.entity_id.value;\n+ const entity_id = this.nodeConfig.entity_id ? this.nodeConfig.entity_id : parsedMessage.entity_id.value;\nconst logAndContinueEmpty = (logMsg) => { this.node.warn(logMsg); return ({ payload: {}}) };\nif (!entity_id) return logAndContinueEmpty('entity ID not set, cannot get current state, sending empty payload');\n@@ -47,7 +47,8 @@ module.exports = function(RED) {\nconst debugMsg = `Get current state: halting processing due to current state of ${entity_id} matches \"halt if state\" option`;\nthis.debug(debugMsg);\nthis.debugToClient(debugMsg);\n- this.status({fill:\"yellow\",shape:\"ring\",text:`Halted: ${currentState.state} at: ${prettyDate}`});\n+ var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n+ this.status({fill:\"red\",shape:\"ring\",text:`${currentState.state} at: ${prettyDate}`});\nreturn null;\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | prioritised config over input for api-current-state |
748,247 | 17.05.2018 15:33:29 | 25,200 | 8c06e2d5ca86662cc164333cde669b42d774a1ed | change stop color to red | [
{
"change_type": "MODIFY",
"old_path": "nodes/server-events-state-changed/server-events-state-changed.js",
"new_path": "nodes/server-events-state-changed/server-events-state-changed.js",
"diff": "@@ -33,7 +33,7 @@ module.exports = function(RED) {\nif (shouldHaltIfState) {\nthis.debug('flow halted due to \"halt if state\" setting');\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"yellow\",shape:\"ring\",text:`${event.new_state.state} at: ${prettyDate}`});\n+ this.status({fill:\"red\",shape:\"ring\",text:`${event.new_state.state} at: ${prettyDate}`});\nreturn null;\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | change stop color to red |
748,247 | 18.05.2018 09:48:22 | 25,200 | f4ba56b8333d12aacbf8d075de09367e2b24260f | poll-state cleanup | [
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -50,7 +50,7 @@ module.exports = function(RED) {\nconst state = await this.getState(this.nodeConfig.entity_id);\nif (!state) {\nthis.warn(`could not find state with entity_id \"${this.nodeConfig.entity_id}\"`);\n- this.status(fill:\"red\",shape:\"ring\",text:`no state found for \"${this.nodeConfig.entity_id}\"`);\n+ this.status({fill:\"red\",shape:\"ring\",text:`no state found for ${this.nodeConfig.entity_id}`});\nreturn;\n}\n@@ -62,6 +62,8 @@ module.exports = function(RED) {\ntopic: this.nodeConfig.entity_id,\npayload: { timeSinceChanged, timeSinceChangedMs, dateChanged, data: state }\n});\n+ var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n+ this.status({fill:\"green\",shape:\"dot\",text:`${state} at: ${prettyDate}`});\n} else {\nthis.warn(`could not calculate time since changed for entity_id \"${this.nodeConfig.entity_id}\"`);\n}\n@@ -80,7 +82,7 @@ module.exports = function(RED) {\n}\nreturn state;\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status(fill:\"green\",shape:\"dot\",text:`${state} at: ${prettyDate}`);\n+ this.status({fill:\"green\",shape:\"dot\",text:`${state} at: ${prettyDate}`});\n}\n}\nRED.nodes.registerType('poll-state', TimeSinceStateNode);\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | poll-state cleanup |
748,260 | 13.07.2018 13:44:26 | 21,600 | d685062a03c32363645335ae89e6421f321befef | Current State Node: Preserve original message with option to override payload | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -7,6 +7,7 @@ module.exports = function(RED) {\nconfig: {\nname: {},\nhalt_if: {},\n+ override_payload: {},\nentity_id: {},\npropertyType: {},\nproperty: {},\n@@ -52,17 +53,24 @@ module.exports = function(RED) {\nreturn null;\n}\n+ // default switch to true if undefined (backward compatibility\n+ const override_payload = this.nodeConfig.override_payload !== false;\n+\n// Output the currentState Object to the destination specified\nif (this.nodeConfig.propertyType == 'flow') {\nthis.context().flow.set(this.nodeConfig.property, currentState);\n} else if (this.nodeConfig.propertyType == 'global') {\nthis.context().global.set(this.nodeConfig.property, currentState);\n} else {\n+ if (override_payload) {\nRED.util.setMessageProperty(message, this.nodeConfig.property, currentState);\n+ this.node.send(message);\n+ } else {\n+ this.node.send(message);\n+ }\n}\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\nthis.status({fill:\"green\",shape:\"dot\",text:`${currentState.state} at: ${prettyDate}`});\n- this.node.send(message);\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Current State Node: Preserve original message with option to override payload |
748,260 | 13.07.2018 13:45:12 | 21,600 | e84bedcbcb1408a434dca7837e74aefe0d912d84 | Give option to override payload | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.html",
"new_path": "nodes/api_current-state/api_current-state.html",
"diff": "name: { value: '' },\nserver: { value: '', type: 'server', required: true },\nhalt_if: { value: '' },\n+ override_payload: { value: true },\nentity_id: { value: '', required: true },\npropertyType: { value: 'msg', required: true },\nproperty: { value: 'payload', required: true }\n<input type=\"text\" id=\"node-input-property\" style=\"width:70%;\" />\n</div>\n+ <div class=\"form-row\">\n+ <label for=\"node-input-override_payload\"> </label>\n+ <input type=\"checkbox\" id=\"node-input-override_payload\" checked style=\"display:inline-block; width:15px; vertical-align:baseline;\"> \n+ <span>Override Payload</span>\n+ </div>\n+\n<div class=\"form-row\">\n<label for=\"node-input-halt_if\"><i class=\"fa fa-hand-paper-o\"></i> Halt If</label>\n<input type=\"text\" id=\"node-input-halt_if\" placeholder=\"off\" />\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Give option to override payload |
748,247 | 18.07.2018 09:11:23 | 25,200 | cf68d0af14132c431a7188779a1cb55ddc6d687f | Fixing current_state node | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.html",
"new_path": "nodes/api_current-state/api_current-state.html",
"diff": "server: { value: '', type: 'server', required: true },\nhalt_if: { value: '' },\noverride_payload: { value: true },\n+ override_object: { value: true },\nentity_id: { value: '', required: true },\npropertyType: { value: 'msg', required: true },\nproperty: { value: 'payload', required: true }\n<span>Override Payload</span>\n</div>\n+ <div class=\"form-row\">\n+ <label for=\"node-input-override_object\"> </label>\n+ <input type=\"checkbox\" id=\"node-input-override_object\" checked style=\"display:inline-block; width:15px; vertical-align:baseline;\"> \n+ <span>Override Object</span>\n+ </div>\n+\n<div class=\"form-row\">\n<label for=\"node-input-halt_if\"><i class=\"fa fa-hand-paper-o\"></i> Halt If</label>\n<input type=\"text\" id=\"node-input-halt_if\" placeholder=\"off\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -8,6 +8,7 @@ module.exports = function(RED) {\nname: {},\nhalt_if: {},\noverride_payload: {},\n+ override_object: {},\nentity_id: {},\npropertyType: {},\nproperty: {},\n@@ -55,6 +56,7 @@ module.exports = function(RED) {\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\n+ const override_object = this.nodeConfig.override_object !== false;\n// Output the currentState Object to the destination specified\nif (this.nodeConfig.propertyType == 'flow') {\n@@ -63,7 +65,13 @@ module.exports = function(RED) {\nthis.context().global.set(this.nodeConfig.property, currentState);\n} else {\nif (override_payload) {\n- RED.util.setMessageProperty(message, this.nodeConfig.property, currentState);\n+ //RED.util.setMessageProperty(message, this.nodeConfig.property, currentState.state);\n+ message.payload = currentState.state;\n+ message.topic = entity_id;\n+ if (override_object) {\n+ message.old_object = message.object;\n+ message.object = currentState;\n+ }\nthis.node.send(message);\n} else {\nthis.node.send(message);\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fixing current_state node |
748,238 | 19.07.2018 10:21:08 | -43,200 | e58591e197386a058e395f9e23b46f589f3e30e1 | Fix/Adjust outputs to make sense | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -58,6 +58,7 @@ module.exports = function(RED) {\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\nconst override_object = this.nodeConfig.override_object !== false;\n+ const override_topic = this.nodeConfig.override_topic !== false;\n// Output the currentState Object to the destination specified\nif (this.nodeConfig.propertyType == 'flow') {\n@@ -69,12 +70,13 @@ module.exports = function(RED) {\nif (override_topic) { message.topic = entity_id; }\nif (override_object) {\nmessage.old_object = message.object;\n- message.object = currentState;\n+ RED.util.setMessageProperty(message, this.nodeConfig.property, currentState);\n+ //message.object = currentState;\n}\n- this.node.send(message);\n}\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\nthis.status({fill:\"green\",shape:\"dot\",text:`${currentState.state} at: ${prettyDate}`});\n+ this.node.send(message);\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fix/Adjust outputs to make sense |
748,238 | 19.07.2018 10:59:21 | -43,200 | ef60b29e510446ca2a56d5543467b670f1ae1be2 | If override Object is disabled, return the current state inside the data property (As per previous behaviour) | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.html",
"new_path": "nodes/api_current-state/api_current-state.html",
"diff": "halt_if: { value: '' },\noverride_topic: { value: true },\noverride_payload: { value: true },\n- override_object: { value: true },\n+ override_property:{ value: false },\nentity_id: { value: '', required: true },\npropertyType: { value: 'msg', required: true },\nproperty: { value: 'payload', required: true }\n<input type=\"text\" id=\"entity_id\">\n</div>\n+ <div class=\"form-row\">\n+ <label for=\"node-input-override_property\"> </label>\n+ <input type=\"checkbox\" id=\"node-input-override_property\" checked style=\"display:inline-block; width:15px; vertical-align:baseline;\"> \n+ <span>Override Property</span>\n+ </div>\n+\n<div class=\"form-row\">\n<label for=\"node-input-property\"><i class=\"fa fa-ellipsis-h\"></i> <span data-i18n=\"node-red:common.label.property\"></span></label>\n<input type=\"hidden\" id=\"node-input-propertyType\">\n<span>Override Payload</span>\n</div>\n- <div class=\"form-row\">\n- <label for=\"node-input-override_object\"> </label>\n- <input type=\"checkbox\" id=\"node-input-override_object\" checked style=\"display:inline-block; width:15px; vertical-align:baseline;\"> \n- <span>Override Object</span>\n- </div>\n-\n<div class=\"form-row\">\n<label for=\"node-input-halt_if\"><i class=\"fa fa-hand-paper-o\"></i> Halt If</label>\n<input type=\"text\" id=\"node-input-halt_if\" placeholder=\"off\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -9,7 +9,7 @@ module.exports = function(RED) {\nhalt_if: {},\noverride_topic: {},\noverride_payload: {},\n- override_object: {},\n+ override_property: {},\nentity_id: {},\npropertyType: {},\nproperty: {},\n@@ -57,7 +57,7 @@ module.exports = function(RED) {\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\n- const override_object = this.nodeConfig.override_object !== false;\n+ const override_property = this.nodeConfig.override_property !== false;\nconst override_topic = this.nodeConfig.override_topic !== false;\n// Output the currentState Object to the destination specified\n@@ -66,12 +66,12 @@ module.exports = function(RED) {\n} else if (this.nodeConfig.propertyType == 'global') {\nthis.context().global.set(this.nodeConfig.property, currentState);\n} else {\n- if (override_payload) { message.payload = currentState.state; }\n- if (override_topic) { message.topic = entity_id; }\n- if (override_object) {\n- message.old_object = message.object;\n+ if (override_topic) message.topic = entity_id;\n+ if (override_payload) message.payload = currentState.state;\n+ if (override_property) {\nRED.util.setMessageProperty(message, this.nodeConfig.property, currentState);\n- //message.object = currentState;\n+ } else {\n+ message.data = currentState;\n}\n}\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | If override Object is disabled, return the current state inside the data property (As per previous behaviour) |
748,247 | 19.07.2018 08:16:02 | 25,200 | bd49063efe459992cd5794430f80b97918ec4b32 | refactor api_current_state | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.html",
"new_path": "nodes/api_current-state/api_current-state.html",
"diff": "halt_if: { value: '' },\noverride_topic: { value: true },\noverride_payload: { value: true },\n- override_property:{ value: false },\nentity_id: { value: '', required: true },\n- propertyType: { value: 'msg', required: true },\n- property: { value: 'payload', required: true }\n},\noneditprepare: function () {\nconst $entityIdField = $('#entity_id');\nif (!isConfigValid) { $entityIdField.addClass('disabled'); }\nelse { $entityIdField.removeClass('disabled'); }\n- //Default the output property to msg.payload\n- if (this.property === undefined) {\n- $(\"#node-input-property\").val(\"payload\");\n- }\n- $(\"#node-input-property\").typedInput({\n- default: 'msg',\n- typeField: $(\"#node-input-propertyType\"),\n- types: ['msg', 'flow', 'global']\n- });\n-\n-\n$.get('/homeassistant/entities')\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\n},\noneditsave: function () {\nthis.entity_id = $(\"#entity_id\").val();\n- this.propertyType = $(\"#node-input-property\").typedInput('type');\n- this.property = $(\"#node-input-property\").typedInput('value');\n}\n});\n</script>\n<input type=\"text\" id=\"entity_id\">\n</div>\n- <div class=\"form-row\">\n- <label for=\"node-input-override_property\"> </label>\n- <input type=\"checkbox\" id=\"node-input-override_property\" checked style=\"display:inline-block; width:15px; vertical-align:baseline;\"> \n- <span>Override Property</span>\n- </div>\n-\n- <div class=\"form-row\">\n- <label for=\"node-input-property\"><i class=\"fa fa-ellipsis-h\"></i> <span data-i18n=\"node-red:common.label.property\"></span></label>\n- <input type=\"hidden\" id=\"node-input-propertyType\">\n- <input type=\"text\" id=\"node-input-property\" style=\"width:70%;\" />\n- </div>\n-\n<div class=\"form-row\">\n<label for=\"node-input-override_topic\"> </label>\n<input type=\"checkbox\" id=\"node-input-override_topic\" checked style=\"display:inline-block; width:15px; vertical-align:baseline;\"> \n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/api_current-state/api_current-state.js",
"new_path": "nodes/api_current-state/api_current-state.js",
"diff": "@@ -9,10 +9,7 @@ module.exports = function(RED) {\nhalt_if: {},\noverride_topic: {},\noverride_payload: {},\n- override_property: {},\nentity_id: {},\n- propertyType: {},\n- property: {},\nserver: { isNode: true }\n},\ninput: {\n@@ -57,23 +54,13 @@ module.exports = function(RED) {\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\n- const override_property = this.nodeConfig.override_property !== false;\nconst override_topic = this.nodeConfig.override_topic !== false;\n- // Output the currentState Object to the destination specified\n- if (this.nodeConfig.propertyType == 'flow') {\n- this.context().flow.set(this.nodeConfig.property, currentState);\n- } else if (this.nodeConfig.propertyType == 'global') {\n- this.context().global.set(this.nodeConfig.property, currentState);\n- } else {\nif (override_topic) message.topic = entity_id;\nif (override_payload) message.payload = currentState.state;\n- if (override_property) {\n- RED.util.setMessageProperty(message, this.nodeConfig.property, currentState);\n- } else {\n+\nmessage.data = currentState;\n- }\n- }\n+\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\nthis.status({fill:\"green\",shape:\"dot\",text:`${currentState.state} at: ${prettyDate}`});\nthis.node.send(message);\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | refactor api_current_state |
748,234 | 12.08.2018 23:57:13 | 25,200 | 768b34772783f2f03c2ae1be0d9e2aa3f35a3da4 | added <= and >= to comparison, fixed label that showed undefined string, added status for allowed and blocked outputs | [
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "<option value=\"is\">Is</option>\n<option value=\"is_not\">Is Not</option>\n- <option value=\"greater_than\">Greater Than</option>\n- <option value=\"less_than\">Less Than</option>\n+ <option value=\">\">></option>\n+ <option value=\">=\">>=</option>\n+ <option value=\"<\"><</option>\n+ <option value=\"<=\"><=</option>\n<option value=\"includes\">Includes</option>\n<option value=\"does_not_include\">Does Not Include</option>\n<option value=\"is\"> Is </option>\n<option value=\"is_not\"> Is Not </option>\n- <option value=\"greater_than\"> Greater Than </option>\n- <option value=\"less_than\"> Less Than </option>\n+ <option value=\">\">></option>\n+ <option value=\">=\">>=</option>\n+ <option value=\"<\"><</option>\n+ <option value=\"<=\"><=</option>\n<option value=\"includes\">Includes</option>\n<option value=\"does_not_include\">Does Not Include</option>\nconst co = this.customoutputs[index - NUM_DEFAULT_OUTPUTS];\nlet label;\nif (co.comparatorPropertyType === 'always') {\n- label += 'always sent'\n+ label = 'always sent'\n} else {\n- label += `sent when ${co.comparatorPropertyType.replace('_', ' ')} ${co.comparatorType.replace('_', '')} ${co.comparatorValue}`;\n+ label = `${co.comparatorPropertyType.replace('_', ' ')} ${co.comparatorType.replace('_', '')} ${co.comparatorValue}`;\n}\nreturn label;\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -59,11 +59,18 @@ module.exports = function(RED) {\ntry {\nconst constraintComparatorResults = await this.getConstraintComparatorResults(this.nodeConfig.constraints, eventMessage);\n+ const state = eventMessage.event.new_state.state;\n+ const prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\nlet outputs = this.getDefaultMessageOutputs(constraintComparatorResults, eventMessage);\n+ let status = { fill: \"green\", shape: \"dot\", text: `${state} at: ${prettyDate}` };\n// If a constraint comparator failed we're done, also if no custom outputs to look at\nif (constraintComparatorResults.failed.length || !this.nodeConfig.customoutputs.length) {\n+ if (constraintComparatorResults.failed.length) {\n+ status = { fill: \"red\", shape: \"ring\", text: `${state} at: ${prettyDate}` };\n+ }\nthis.debugToClient('done processing sending messages: ', outputs);\n+ this.status(status);\nreturn this.send(outputs);\n}\n@@ -72,6 +79,7 @@ module.exports = function(RED) {\noutputs = outputs.concat(customOutputMessages);\nthis.debugToClient('done processing sending messages: ', outputs);\n+ this.status(status);\nthis.send(outputs);\n} catch (e) {\nthis.error(e);\n@@ -181,10 +189,16 @@ module.exports = function(RED) {\ncase 'does_not_include':\nconst isIncluded = cValue.includes(actualValue);\nreturn (comparatorType === 'includes') ? isIncluded : !isIncluded;\n- case 'greater_than':\n+ case 'greater_than': // here for backwards compatibility\n+ case '>':\nreturn actualValue > cValue;\n- case 'less_than':\n+ case '>=':\n+ return actualValue >= cValue;\n+ case 'less_than': // here for backwards compatibility\n+ case '<':\nreturn actualValue < cValue;\n+ case '<=':\n+ return actualValue <= cValue;\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | added <= and >= to comparison, fixed label that showed undefined string, added status for allowed and blocked outputs |
748,234 | 13.08.2018 00:02:23 | 25,200 | 128884994e839ab6344ddd2da372477d9ef40c49 | Making poll-state more like the output of current-state | [
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -47,23 +47,24 @@ module.exports = function(RED) {\nasync onTimer() {\ntry {\n- const state = await this.getState(this.nodeConfig.entity_id);\n- if (!state) {\n+ const pollState = await this.getState(this.nodeConfig.entity_id);\n+ if (!pollState) {\nthis.warn(`could not find state with entity_id \"${this.nodeConfig.entity_id}\"`);\nthis.status({fill:\"red\",shape:\"ring\",text:`no state found for ${this.nodeConfig.entity_id}`});\nreturn;\n}\n- const dateChanged = this.calculateTimeSinceChanged(state);\n+ const dateChanged = this.calculateTimeSinceChanged(pollState);\nif (dateChanged) {\n- const timeSinceChanged = ta.ago(dateChanged);\n- const timeSinceChangedMs = Date.now() - dateChanged.getTime();\n+ pollState.timeSinceChanged = ta.ago(dateChanged);\n+ pollState.timeSinceChangedMs = Date.now() - dateChanged.getTime();\nthis.send({\ntopic: this.nodeConfig.entity_id,\n- payload: { timeSinceChanged, timeSinceChangedMs, dateChanged, data: state }\n+ payload: pollState.state,\n+ data: pollState\n});\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"green\",shape:\"dot\",text:`${state} at: ${prettyDate}`});\n+ this.status({fill:\"green\",shape:\"dot\",text:`${pollState.state} at: ${prettyDate}`});\n} else {\nthis.warn(`could not calculate time since changed for entity_id \"${this.nodeConfig.entity_id}\"`);\n}\n@@ -81,8 +82,6 @@ module.exports = function(RED) {\nstate = await this.nodeConfig.server.homeAssistant.getStates(this.nodeConfig.entity_id, true);\n}\nreturn state;\n- var prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\n- this.status({fill:\"green\",shape:\"dot\",text:`${state} at: ${prettyDate}`});\n}\n}\nRED.nodes.registerType('poll-state', TimeSinceStateNode);\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Making poll-state more like the output of current-state |
748,234 | 26.08.2018 21:58:29 | 25,200 | 725ada305ea85e75a99f0ec2c056048cbe36e877 | Fix for call-service node replacing msg object | [
{
"change_type": "MODIFY",
"old_path": "nodes/api_call-service/api_call-service.js",
"new_path": "nodes/api_call-service/api_call-service.js",
"diff": "@@ -51,13 +51,13 @@ module.exports = function(RED) {\nthis.debug(`Calling Service: ${apiDomain}:${apiService} -- ${JSON.stringify(apiData || {})}`);\nvar prettyDate = new Date().toLocaleDateString(\"en-US\",{month: 'short', day: 'numeric', hour12: false, hour: 'numeric', minute: 'numeric'});\nthis.status({fill:\"green\",shape:\"dot\",text:`${apiDomain}.${apiService} called at: ${prettyDate}`});\n- this.send({\n- payload: {\n+\n+ message.payload = {\ndomain: apiDomain,\nservice: apiService,\ndata: apiData || null\n- }\n- });\n+ };\n+ this.send(message);\nreturn this.nodeConfig.server.api.callService(apiDomain, apiService, apiData)\n.catch(err => {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fix for call-service node replacing msg object |
748,234 | 01.09.2018 01:21:40 | 25,200 | 4b75d3e31558cd2d8cc469803cde441762bd42ea | Added files from node-home-assistant | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/ha-api.js",
"diff": "+'use strict';\n+const axios = require('axios');\n+const utils = require('./utils');\n+const debug = require('debug')('home-assistant:api');\n+\n+class HaApi {\n+ constructor(config) {\n+ this.config = config;\n+\n+ const apiOpts = { baseURL: config.baseUrl + '/api' };\n+ apiOpts.headers = (config.apiPass)\n+ ? { 'x-ha-access': config.apiPass }\n+ : {};\n+\n+ this.client = axios.create(apiOpts);\n+ }\n+\n+ callService(domain, service, data) {\n+ return this._post(`/services/${domain}/${service}`, data);\n+ }\n+\n+ getServices() {\n+ return this._get('services');\n+ }\n+\n+ getEvents() {\n+ return this._get('events');\n+ }\n+\n+ getStates (entity_id, { include, exclude } = {}) {\n+ const path = (entity_id) ? `states/${entity_id}` : 'states';\n+\n+ return this._get(path)\n+ .then(states => {\n+ // If passing in an entity_id will only have one result, just return formatted\n+ if (!states.length) { return { [states.entity_id]: states } }\n+\n+ return states.reduce((acc, state) => {\n+ if (utils.shouldInclude(state.entity_id, include, exclude)) {\n+ acc[state.entity_id] = state;\n+ }\n+ return acc;\n+ }, {});\n+ });\n+ }\n+\n+ getEntities(entity_id, { include, exclude } = {}) {\n+ return this.getStates(entity_id, { include, exclude })\n+ .then(states => {\n+ const entities = Object.keys(states);\n+\n+ return entities.sort()\n+ });\n+ }\n+\n+ getHistory(timestamp, filterEntityId, endTimestamp, { include, exclude, flatten } = {}) {\n+ let path = 'history/period';\n+\n+ if (timestamp) { path = path + `/${timestamp}`; }\n+ let params = {};\n+ if (filterEntityId) { params.filter_entity_id = filterEntityId; }\n+ if (endTimestamp) { params.end_time = endTimestamp; }\n+\n+ // History returns an array for each entity_id and that array containes objects for each history item\n+ return this._get(path, params)\n+ .then(result => {\n+ if (!include && !exclude && !flatten) { return result; }\n+\n+ // Filter out results by regex, include/exclude should already be an instance of RegEx\n+ if (include || exclude) {\n+ result = result.reduce((acc, entityArr) => {\n+ const entityId = (entityArr && entityArr.length > 0) ? entityArr[0].entity_id : null;\n+\n+ if (entityId && utils.shouldInclude(entityId, include, exclude)) { acc.push(entityArr); }\n+ return acc;\n+ }, []);\n+ }\n+\n+ // Instead of returning the data from home assistant ( array for each entity_id ) return one flattened array\n+ // of one item per history entry\n+ if (flatten) {\n+ result = result\n+ .reduce((acc, entityArray) => {\n+ acc = acc.concat(entityArray);\n+ return acc;\n+ }, [])\n+ .sort((a,b) => {\n+ if (a.last_updated < b.last_updated) { return -1; }\n+ if (a.last_updated > b.last_updated) { return 1; }\n+ return 0;\n+ });\n+ }\n+\n+ return result;\n+ });\n+ }\n+\n+ getConfig(){\n+ return this._get('config');\n+ }\n+ getDiscoveryInfo(){\n+ return this._get('discovery_info');\n+ }\n+ getErrorLog(){\n+ return this._get('error_log');\n+ }\n+ // TODO: Test, entity_id should be `camera.some_cam_entity`\n+ getCameraImage(cameraEntityId) {\n+ return this._get(`camera_proxy/${cameraEntityId}`);\n+ }\n+\n+ renderTemplate(templateString) {\n+ return this._post('template', { template: templateString });\n+ }\n+\n+ _post(path, data = {}) {\n+ debug(`POST: ${this.config.baseUrl}/${path}`);\n+\n+ return this.client.post(path, data)\n+ .then(res => res.data || res)\n+ .catch(err => {\n+ debug(`POST: request errror: ${err.toString()}`);\n+ throw err;\n+ });\n+ }\n+\n+ _get(path, params = {}) {\n+ debug(`GET: ${this.config.baseUrl}/${path}`);\n+\n+ return this.client.request({ url: path, params: params })\n+ .then(res => res.data || res)\n+ .catch(err => {\n+ debug(`GET: request errror: ${err.toString()}`);\n+ throw err;\n+ });\n+ }\n+}\n+\n+module.exports = HaApi;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/ha-events.js",
"diff": "+\n+'use strict';\n+const utils = require('./utils');\n+const EventEmitter = require('events').EventEmitter;\n+const EventSource = require('eventsource');\n+const debug = require('debug')('home-assistant:events');\n+\n+class HaEvents extends EventEmitter {\n+ constructor(config) {\n+ super();\n+ this.config = config;\n+ this.streamUrl = `${config.baseUrl}/api/stream`;\n+ this.esOptions = (config.apiPass)\n+ ? { headers: { 'x-ha-access': config.apiPass }}\n+ : {};\n+ this.connected = false;\n+\n+ this.setMaxListeners(0);\n+ }\n+\n+ startListening(eventOpts = {}) {\n+ if (this.config.events.transport !== 'sse') { throw new Error('Unsupported transport type'); }\n+ this.config.events.includeRegex = eventOpts.includeRegex || this.config.events.includeRegex;\n+ this.config.events.excludeRegex = eventOpts.excludeRegex || this.config.events.excludeRegex;\n+\n+ this.client = new EventSource(this.streamUrl, this.esOptions);\n+ this.client.on('message', (evt) => this.onClientMessage(evt));\n+\n+ this.client.on('open', () => this.onClientOpen());\n+ this.client.on('close', () => this.onClientClose());\n+ this.client.on('error', (err) => this.onClientError(err));\n+ }\n+\n+ onClientMessage(msg) {\n+ if (!msg || !msg.data || msg.data === 'ping') { return; }\n+\n+ let event;\n+ try { event = JSON.parse(msg.data); }\n+ catch (e) { this.emit('ha_events:error', e); }\n+\n+ if (event) {\n+ const eventType = event.event_type;\n+ const entityId = (event.data) ? event.data.entity_id : null;\n+ const { excludeRegex, includeRegex } = this.config.events;\n+\n+ const emitEvent = { event_type: eventType, entity_id: entityId, event: event.data };\n+\n+ // If entity_id was found but is excluded by configured filter then stop further processing\n+ if (entityId && !(utils.shouldInclude(entityId, includeRegex, excludeRegex))) {\n+ debug('Skipping entity as entityId was excluded by includeRegex or excludeRegex config option');\n+ return;\n+ }\n+\n+ // Emit on all channel\n+ this.emit('ha_events:all', emitEvent);\n+\n+ // Emit on the event type channel\n+ if (emitEvent.event_type) {\n+ this.emit(`ha_events:${event.event_type}`, emitEvent);\n+ }\n+\n+ // Most specific emit for event_type and entity_id\n+ if (emitEvent.event_type && emitEvent.entity_id) {\n+ this.emit(`ha_events:${event.event_type}:${emitEvent.entity_id}`, emitEvent);\n+ }\n+ }\n+ }\n+\n+ onClientOpen() {\n+ debug('events connection open');\n+ this.connected = true;\n+ this.emit('ha_events:open');\n+ }\n+\n+ onClientClose() {\n+ this.closeClient(null, 'events connection closed, cleaning up connection');\n+ }\n+\n+ onClientError(err) {\n+ this.closeClient(err, 'events connection error, cleaning up connection');\n+ }\n+\n+ closeClient(err, logMsg) {\n+ if (logMsg) { debug(logMsg); }\n+ if (err) {\n+ debug(err);\n+ this.emit('ha_events:error', err);\n+ }\n+\n+ if (this.client && this.client.close) {\n+ this.connected = false;\n+ this.client.close();\n+ this.emit('ha_events:close');\n+ }\n+\n+ // TODO: Put in proper exponential retries\n+ setTimeout(() => this.startListening(), 2000);\n+ }\n+}\n+\n+module.exports = HaEvents;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/logger.js",
"diff": "+'use strict';\n+const prettyPrint = true;\n+\n+const pinoOpts = {\n+ level: 'trace',\n+ name: 'node-home-assistant',\n+ safe: true,\n+ prettyPrint: prettyPrint\n+};\n+module.exports = require('pino')(pinoOpts);\n+\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/node-home-assistant.js",
"diff": "+'use strict';\n+const debug = require('debug')('home-assistant');\n+const HaEvents = require('./ha-events');\n+const HaApi = require('./ha-api');\n+\n+const DEFAULTS = {\n+ baseUrl: null,\n+ apiPass: null,\n+ api: {},\n+ events: {\n+ includeRegex: null, // Include/Exclude allows for suppressing events by regex matches\n+ excludeRegex: null,\n+ transport: 'sse', // For future support of websockets\n+ retries: {\n+ maxAttempts: 10, // How many times to retry connection\n+ delay: 5000 // Delay this long before retry (in ms)\n+ }\n+ }\n+};\n+\n+class HomeAssistant {\n+ constructor(config, { startListening } = {}) {\n+ debug('Instantiating HomeAssistant');\n+ this.config = Object.assign({}, DEFAULTS, config);\n+ this.api = new HaApi(this.config);\n+ this.events = new HaEvents(this.config);\n+\n+ if (startListening) { this.startListening(); }\n+ }\n+\n+ static async testConnection({ baseUrl, apiPass }) {\n+ const apiTest = new HaApi({ baseUrl, apiPass });\n+ try {\n+ await apiTest.getConfig();\n+ return true;\n+ } catch (e) {\n+ return false;\n+ }\n+ }\n+\n+ async startListening ({ includeRegex, excludeRegex } = {}) {\n+ if (!this.config.baseUrl) { throw new Error ('Home Assistant URL not set'); }\n+ this.config.events.includeRegex = includeRegex;\n+ this.config.events.excludeRegex = excludeRegex;\n+\n+ const isConnectionWorking = await HomeAssistant.testConnection(this.config);\n+ if (!isConnectionWorking) {\n+ throw new Error(`Connection to home assistant could not be established with config: ${this.config.baseUrl} ${(this.config.apiPass) ? '<password redacted>' : '<password not used>'}`);\n+ }\n+\n+ this.events.startListening();\n+ this.events.on('ha_events:state_changed', (evt) => this._onStateChanged(evt));\n+ return this;\n+ }\n+\n+ async getStates (entityId, forceRefresh = false) {\n+ if (!this.states || forceRefresh) {\n+ this.states = await this.api.getStates();\n+ }\n+ return (entityId)\n+ ? this.states[entityId] || null\n+ : this.states;\n+ }\n+\n+ async getServices (forceRefresh = false) {\n+ if (!this.availableServices || forceRefresh) { this.availableServices = await this.api.getServices(); }\n+ return this.availableServices;\n+ }\n+\n+ async getEvents (forceRefresh) {\n+ if (!this.availableEvents || forceRefresh) { this.availableEvents = await this.api.getEvents(); }\n+ return this.availableEvents;\n+ }\n+\n+ // Caches state changes for entities\n+ async _onStateChanged (changedEntity) {\n+ try {\n+ const states = await this.getStates();\n+ states[changedEntity.entity_id] = changedEntity.event.new_state;\n+ } catch (e) {\n+ throw e;\n+ }\n+ }\n+}\n+\n+\n+\n+\n+module.exports = HomeAssistant;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/utils.js",
"diff": "+'use strict';\n+const utils = module.exports = {};\n+\n+utils.shouldInclude = (targetString, includeRegex, excludeRegex) => {\n+ if (!targetString || (!includeRegex && !excludeRegex)) { return true; }\n+\n+ // If include regex isn't passed then include everything since test will be skipped\n+ // otherwise default to false and set in regex test\n+ let shouldIncludeTest = (includeRegex) ? false : true;\n+ let shouldExcludeTest = false;\n+\n+ if (includeRegex && includeRegex.test(targetString)) { shouldIncludeTest = true; }\n+ if (excludeRegex && excludeRegex.test(targetString)) { shouldExcludeTest = true; }\n+\n+ return shouldIncludeTest && !shouldExcludeTest;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "}\n},\n\"dependencies\": {\n+ \"axios\": \"^0.17.1\",\n+ \"blessed\": \"^0.1.81\",\n+ \"blessed-contrib\": \"^4.8.5\",\n+ \"chalk\": \"^2.3.0\",\n+ \"chrono-node\": \"^1.3.5\",\n\"clone-deep\": \"^3.0.1\",\n+ \"commander\": \"^2.12.2\",\n+ \"dateformat\": \"^3.0.2\",\n\"date-fns\": \"^1.28.5\",\n- \"debug\": \"^2.6.3\",\n+ \"debounce\": \"^1.1.0\",\n+ \"debug\": \"^3.1.0\",\n+ \"dotenv\": \"^4.0.0\",\n\"is-string\": \"^1.0.4\",\n\"joi\": \"^13.1.1\",\n\"lodash.merge\": \"^4.6.0\",\n\"lowdb\": \"^1.0.0\",\n+ \"merge\": \"^1.2.0\",\n\"node-red\": \"node-red/node-red#0.18.2\",\n+ \"object-merge\": \"^2.5.1\",\n\"selectn\": \"^1.1.2\",\n\"serialize-javascript\": \"^1.4.0\",\n- \"time-ago\": \"^0.2.1\"\n+ \"time-ago\": \"^0.2.1\",\n+ \"timeago.js\": \"^3.0.2\",\n+ \"tty-table\": \"^2.5.5\"\n},\n\"devDependencies\": {\n\"eslint\": \"^4.8.0\",\n\"eslint-plugin-node\": \"^6.0.0\",\n\"eslint-plugin-promise\": \"^3.6.0\",\n\"eslint-plugin-standard\": \"^3.0.1\",\n+ \"mocha\": \"^4.0.1\",\n+ \"nock\": \"^9.1.4\",\n\"nodemon\": \"^1.14.12\",\n\"should\": \"^13.2.1\",\n+ \"simple-mock\": \"^0.8.0\",\n\"sinon\": \"^4.2.2\",\n\"supertest\": \"^3.0.0\",\n+ \"table\": \"^4.0.2\",\n\"tap-min\": \"^1.2.2\",\n\"tape\": \"^4.8.0\"\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added files from node-home-assistant |
748,234 | 20.09.2018 02:44:42 | 25,200 | 8a2d87c3022130d569424a8b81f93467b960cb32 | Added ability to filter event type within the 'events: all' node | [
{
"change_type": "MODIFY",
"old_path": "nodes/events-all/events-all.html",
"new_path": "nodes/events-all/events-all.html",
"diff": "color: '#038FC7',\ndefaults: {\nname: { value: '' },\n- server: { value: '', type: 'server', required: true }\n+ server: { value: '', type: 'server', required: true },\n+ event_type: { value: '', required: false },\n},\ninputs: 0,\noutputs: 1,\nicon: \"arrow-right-bold.png\",\npaletteLabel: 'events: all',\n- label: function() { return this.name || `events_all: ${this.eventtypefilter}` },\n+ label: function() { return this.name || `events: ${this.event_type || 'all'}` },\noneditprepare: function() {\nconst NODE = this;\nconst $server = $('#node-input-server');\n<label for=\"node-input-server\"><i class=\"fa fa-dot-circle-o\"></i> Server</label>\n<input type=\"text\" id=\"node-input-server\" />\n</div>\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-event_type\"><i class=\"fa fa-tag\"></i> Event Type</label>\n+ <input type=\"text\" id=\"node-input-event_type\" placeholder=\"leave empty for all events\" />\n+ </div>\n</script>\n<script type=\"text/x-red\" data-help-name=\"server-events\">\n- <p>Outputs events received from the home assistant server.</p>\n-\n+ <h3>Outputs</h3>\n<p>The outputted message object contains the following data, underscored values are straight from home assistant</p>\n- <table style=\"width: 100%;\" border=\"1\" cellpadding=\"10\">\n- <tbody>\n- <tr> <td>topic</td> <td>event_type</td> </tr>\n- <tr> <td>payload</td> <td>original event</td> </tr>\n- <tr> <td>event_type</td> <td>event_type</td> </tr>\n- </tbody>\n- </table>\n+ <dl class=\"message-properties\">\n+ <dt>topic <span class=\"property-type\">string</span></dt>\n+ <dd>event_type</dd>\n+ <dt>event_type <span class=\"property-type\">string</span></dt>\n+ <dd>event_type</dd>\n+ <dt>payload <span class=\"property-type\">object</span></dt>\n+ <dd>original event object</dd>\n+ </dl>\n+\n+ <h3>Configuration</h3>\n+\n+ <dl class=\"message-properties\">\n+ <dt>Name <span class=\"property-type\">string</span></dt>\n+ <dd>the name of the node</dd>\n+ <dt>Event Type <span class=\"property-type\">string</span></dt>\n+ <dd>filter by event type or leave blank for all events</dd>\n+ </dl>\n+\n</script>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-all/events-all.js",
"new_path": "nodes/events-all/events-all.js",
"diff": "const EventsNode = require('../../lib/events-node');\nmodule.exports = function(RED) {\n+ const nodeOptions = {\n+ config: {\n+ event_type: {}\n+ }\n+ };\n+\nclass ServerEventsNode extends EventsNode {\nconstructor(nodeDefinition) {\n- super(nodeDefinition, RED);\n- this.addEventClientListener({ event: 'ha_events:all', handler: this.onHaEventsAll.bind(this) });\n+ super(nodeDefinition, RED, nodeOptions);\n+ this.addEventClientListener({\n+ event: 'ha_events:' + (this.nodeConfig.event_type || 'all'),\n+ handler: this.onHaEventsAll.bind(this) }\n+ );\n}\nonHaEventsAll(evt) {\nthis.send({ event_type: evt.event_type, topic: evt.event_type, payload: evt });\n- this.status({fill: 'green', shape: 'dot', text: `${evt.event_type}`});\n+ this.status({ fill: 'green', shape: 'dot', text: `${evt.event_type} at: ${this.getPrettyDate()}` });\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added ability to filter event type within the 'events: all' node |
748,234 | 20.09.2018 19:20:16 | 25,200 | cf2a4ad5df8772a0fb508debe946ce39bccd9141 | Fix for it ignoring custom paths in node-red
AYapejian/node-red-contrib-home-assistant/issues/41 | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "// Calls the custom api backend defined in the config-server.js node\n// TODO: Not sure how this works with node-red if auth is enabled\nfunction setServicesAndDomains(node) {\n- return $.get('/homeassistant/services')\n+ return $.get(`${RED.settings.pollStateAdminPrefix}homeassistant/services`)\n.then(services => {\nnode.allServices = JSON.parse(services);\nnode.allDomains = Object.keys(node.allServices);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "if (!isConfigValid) { $entityIdField.addClass('disabled'); }\nelse { $entityIdField.removeClass('disabled'); }\n- $.get('/homeassistant/entities')\n+ $.get(`${RED.settings.apiCurrentState}homeassistant/entities`)\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -65,5 +65,12 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('api-current-state', CurrentStateNode);\n+ RED.nodes.registerType('api-current-state', CurrentStateNode, {\n+ settings: {\n+ apiCurrentState: {\n+ value: RED.settings.httpAdminRoot,\n+ exportable: true\n+ }\n+ }\n+ });\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "// A home assistant server is selected in the node config\nif (node.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get('/homeassistant/entities').done((entities) => {\n+ $.get(`${RED.settings.serverStateChangedAdminPrefix}homeassistant/entities`).done((entities) => {\nnode.availableEntities = JSON.parse(entities);\n$entityidfilter.autocomplete({ source: node.availableEntities, minLength: 0 });\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -86,5 +86,12 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('server-state-changed', ServerStateChangedNode);\n+ RED.nodes.registerType('server-state-changed', ServerStateChangedNode, {\n+ settings: {\n+ serverStateChangedAdminPrefix: {\n+ value: RED.settings.httpAdminRoot,\n+ exportable: true\n+ }\n+ }\n+ });\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "if (!isConfigValid) { $entityIdField.addClass('disabled'); }\nelse { $entityIdField.removeClass('disabled'); }\n- $.get('/homeassistant/entities')\n+ $.get(`${RED.settings.pollStateAdminPrefix}homeassistant/entities`)\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -84,5 +84,12 @@ module.exports = function(RED) {\nreturn state;\n}\n}\n- RED.nodes.registerType('poll-state', TimeSinceStateNode);\n+ RED.nodes.registerType('poll-state', TimeSinceStateNode, {\n+ settings: {\n+ pollStateAdminPrefix: {\n+ value: RED.settings.httpAdminRoot,\n+ exportable: true\n+ }\n+ }\n+ });\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "// A home assistant server is selected in the node config\nif (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get('/homeassistant/entities').done((entities) => {\n+ $.get(`${RED.settings.triggerState}homeassistant/entities`).done((entities) => {\nNODE.availableEntities = JSON.parse(entities);\n$entityid.autocomplete({ source: NODE.availableEntities, minLength: 0 });\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -239,5 +239,12 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('trigger-state', TriggerState);\n+ RED.nodes.registerType('trigger-state', TriggerState, {\n+ settings: {\n+ triggerState: {\n+ value: RED.settings.httpAdminRoot,\n+ exportable: true\n+ }\n+ }\n+ });\n};\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fix for it ignoring custom paths in node-red
AYapejian/node-red-contrib-home-assistant/issues/41 |
748,234 | 22.09.2018 23:12:09 | 25,200 | 3775fa89c34c06a9895a5299d9edda1084396d6f | Added better error reporting
For refused connection and incorrect access token | [
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -132,7 +132,7 @@ class HaWebsocket extends EventEmitter {\ndebug(err);\nthis.emit('ha_events:error', err);\n}\n- debug(this.client);\n+\nif (this.client && this.client.readyState === this.client.CLOSED) {\nthis.connected = false;\nthis.emit('ha_events:close');\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/node-home-assistant.js",
"new_path": "lib/node-home-assistant.js",
"diff": "@@ -40,7 +40,7 @@ class HomeAssistant {\nawait apiTest.getConfig();\nreturn true;\n} catch (e) {\n- return false;\n+ return e;\n}\n}\n@@ -51,18 +51,23 @@ class HomeAssistant {\nthis.config.websocket.includeRegex = includeRegex;\nthis.config.websocket.excludeRegex = excludeRegex;\n+ const isConnectionWorking = await HomeAssistant.testConnection(this.config);\n+ if (isConnectionWorking !== true) {\n+ if (isConnectionWorking.code && isConnectionWorking.code === 'ECONNREFUSED') {\n+ debug(isConnectionWorking.toString());\n+ throw new Error(`Connection refused by ${isConnectionWorking.address}:${isConnectionWorking.port}`);\n+ }\n+\n+ debug('Invalid access token or password for http');\n+ throw new Error('[Home Assistant] Invalid access token or password.');\n+ }\n+\nconst isWebsocketConnected = await this.websocket.startListening();\nif (!isWebsocketConnected) {\ndebug('Invalid access token or password for websocket');\nthrow new Error('[Home Assistant] Invalid access token or password.');\n};\n- const isConnectionWorking = await HomeAssistant.testConnection(this.config);\n- if (!isConnectionWorking) {\n- debug('Invalid access token or password for http');\n- throw new Error('[Home Assistant] Invalid access token or password.');\n- }\n-\nreturn this;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -87,6 +87,7 @@ module.exports = function(RED) {\nthis.setOnContext('isConnected', true);\n+ this.log(`New connection ${this.nodeConfig.url}`);\nthis.debug('config server event listener connected');\n} catch (e) {\nthis.error(e);\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added better error reporting
For refused connection and incorrect access token |
748,234 | 23.09.2018 00:33:12 | 25,200 | bbc9d11ce8ddd0a837c588907ab1c89405b63427 | Updated to home-assistant 0.78.3 and node 8.12.0 for docker
Fixed a couple of the test flows | [
{
"change_type": "MODIFY",
"old_path": "docker/home-assistant/Dockerfile",
"new_path": "docker/home-assistant/Dockerfile",
"diff": "-FROM homeassistant/home-assistant:0.77.3\n+FROM homeassistant/home-assistant:0.78.3\nENV HA_HOME_ASSISTANT_TIME_ZONE=America/New_York \\\nHA_HOME_ASSISTANT_LATITUDE=42.360082 \\\n"
},
{
"change_type": "MODIFY",
"old_path": "docker/node-red/Dockerfile",
"new_path": "docker/node-red/Dockerfile",
"diff": "-FROM node:8.9.4\n+FROM node:8.12.0\nCOPY root-fs /\nRUN chown -R node:node /data /app\n@@ -11,8 +11,7 @@ RUN npm install\n# Install Useful Home Automation Nodes\nRUN npm install \\\n- node-red-contrib-bigstatus \\\n- home-assistant-js-websocket\n+ node-red-contrib-bigstatus\n# User configuration directory volume\nEXPOSE 1880\n"
},
{
"change_type": "MODIFY",
"old_path": "docker/node-red/root-fs/data/flows.json",
"new_path": "docker/node-red/root-fs/data/flows.json",
"diff": "\"z\": \"\",\n\"name\": \"Home Assistant\",\n\"url\": \"http://home-assistant:8123\",\n- \"pass\": \"password\"\n+ \"pass\": \"password\",\n+ \"legacy\": true\n},\n{\n\"id\": \"f31326a2.18c1e8\",\n\"tosidebar\": false,\n\"console\": false,\n\"tostatus\": true,\n- \"complete\": \"payload.timeSinceChanged\",\n+ \"complete\": \"data.timeSinceChanged\",\n\"x\": 380,\n\"y\": 120,\n\"wires\": []\n\"tosidebar\": false,\n\"console\": false,\n\"tostatus\": true,\n- \"complete\": \"payload.timeSinceChanged\",\n+ \"complete\": \"data.timeSinceChanged\",\n\"x\": 480,\n\"y\": 280,\n\"wires\": []\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Updated to home-assistant 0.78.3 and node 8.12.0 for docker
Fixed a couple of the test flows |
748,234 | 23.09.2018 01:08:49 | 25,200 | 04ad3984b326ea239de26eb4ffa8a168ad5b8d02 | More fixes for not ignoring custom paths in node-red.
Fix for Spartan-II-117/node-red-contrib-home-assistant/issues/25 | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "// Calls the custom api backend defined in the config-server.js node\n// TODO: Not sure how this works with node-red if auth is enabled\nfunction setServicesAndDomains(node) {\n- return $.get(`${RED.settings.pollStateAdminPrefix}homeassistant/services`)\n+ return $.get(`${RED.settings.apiCallServiceAdminPrefix}homeassistant/services`)\n.then(services => {\nnode.allServices = JSON.parse(services);\nnode.allDomains = Object.keys(node.allServices);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.js",
"new_path": "nodes/call-service/call-service.js",
"diff": "@@ -90,5 +90,12 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('api-call-service', CallServiceNode);\n+ RED.nodes.registerType('api-call-service', CallServiceNode, {\n+ settings: {\n+ apiCallServiceAdminPrefix: {\n+ value: RED.settings.httpAdminRoot,\n+ exportable: true\n+ }\n+ }\n+ });\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "if (!isConfigValid) { $entityIdField.addClass('disabled'); }\nelse { $entityIdField.removeClass('disabled'); }\n- $.get(`${RED.settings.apiCurrentState}homeassistant/entities`)\n+ $.get(`${RED.settings.apiCurrentStateAdminPrefix}homeassistant/entities`)\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -67,7 +67,7 @@ module.exports = function(RED) {\nRED.nodes.registerType('api-current-state', CurrentStateNode, {\nsettings: {\n- apiCurrentState: {\n+ apiCurrentStateAdminPrefix: {\nvalue: RED.settings.httpAdminRoot,\nexportable: true\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "// A home assistant server is selected in the node config\nif (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get(`${RED.settings.triggerState}homeassistant/entities`).done((entities) => {\n+ $.get(`${RED.settings.triggerStateAdminPrefix}homeassistant/entities`).done((entities) => {\nNODE.availableEntities = JSON.parse(entities);\n$entityid.autocomplete({ source: NODE.availableEntities, minLength: 0 });\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -241,7 +241,7 @@ module.exports = function(RED) {\nRED.nodes.registerType('trigger-state', TriggerState, {\nsettings: {\n- triggerState: {\n+ triggerStateAdminPrefix: {\nvalue: RED.settings.httpAdminRoot,\nexportable: true\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | More fixes for not ignoring custom paths in node-red.
Fix for Spartan-II-117/node-red-contrib-home-assistant/issues/25 |
748,234 | 23.09.2018 15:34:11 | 25,200 | 77752161b460fe04d5374804c4cbb6e3901f8e41 | Version Bump to 0.0.2 | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "-# v0.0.1\n-* Feat: Added <= and => comparison for Constraints and Outputs. Renamed greater_than and less_than to > and < but kept backwards compatibility\n+# Changelog\n+\n+All notable changes to this project will be documented in this file.\n+\n+## [0.0.2] - 2018.9.23\n+\n+### Added\n+\n+* Ability to filter event type from within the 'events: all' node\n+* Better error handling for refused connections and incorrect access token/password\n+\n+### Changed\n+\n+* Docker config you use Home Assistant 0.78.3 and node-red 8.12.0\n+\n+### Fixed\n+\n+* The ignoring of custom root path if set in node-red - [AYapejian/node-red-contrib-home-assistant/issues/41](https://github.com/AYapejian/node-red-contrib-home-assistant/issues/41)\n+\n+## [0.0.1] - 2018.9.20\n+\n+### Added\n+\n+* Integrated [AYapejian/node-home-assistant](https://github.com/AYapejian/node-home-assistant) minus the CLI\n+* Ability to use Home Assistant long-lived access tokens\n+\n+### Changed\n+\n+* 'events: all', 'events: state', and 'trigger: state' to use websocket instead of the events stream\n+* 'poll state', 'call service', and 'current state' to use websocket instead of REST API\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -27,28 +27,28 @@ For flow examples checkout the [flows here](https://raw.githubusercontent.com/za\n## Included Nodes\nThe installed nodes have more detailed information in the node-red info pane shown when the node is selected. Below is a quick summary\n-### All Events\n+### All Events - `websocket`\nListens for all types of events from home assistant\n-### State Changed Event\n+### State Changed Event - `websocket`\nListens for only `state_changed` events from home assistant\n-### State Trigger\n+### State Trigger - `websocket`\nMuch like the `State Changed Ndoe` however provides some advanced functionality around common automation use cases.\n-### Poll State\n+### Poll State - `websocket`\nOutputs the state of an entity at regular intervals, optionally also at startup and every time the entity changes if desired\n-### Call Service\n+### Call Service - `websocket`\nSends a request to home assistant for any domain and service available ( `light/turn_on`, `input_select/select_option`, etc..)\n-### Get Current State\n+### Get Current State - `websocket`\nFetches the last known state for any entity on input\n-### Get History\n+### Get History - `rest api`\nFetches HomeAssistant history on input\n-### Get Template\n+### Get Template - `rest api`\nAllows rendering of templates on input\n## Development\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n- \"description\": \"node-red nodes to visually construct home automation with home assistant\",\n- \"version\": \"0.0.1\",\n+ \"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n+ \"version\": \"0.0.2\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n\"node-red\",\n\"home-assistant\",\n\"home assistant\",\n- \"home automation\"\n+ \"home automation\",\n+ \"websocket\"\n],\n\"node-red\": {\n\"nodes\": {\n\"lodash.merge\": \"^4.6.0\",\n\"lowdb\": \"^1.0.0\",\n\"merge\": \"^1.2.0\",\n- \"node-red\": \"node-red/node-red#0.18.2\",\n+ \"node-red\": \"node-red/node-red#0.19.4\",\n\"selectn\": \"^1.1.2\",\n\"serialize-javascript\": \"^1.4.0\",\n\"time-ago\": \"^0.2.1\",\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Version Bump to 0.0.2 |
748,234 | 26.09.2018 22:05:16 | 25,200 | 43a5ca90f1ce0806f355d3cd4f1770a37e585f2d | Fix for autocomplete xhr call showing undefined for httpAdminRoot.
* not going to assume that httpAdminRoot is defined
zachowj/node-red-contrib-home-assistant-websocket/issues/2 | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.js",
"new_path": "nodes/call-service/call-service.js",
"diff": "@@ -93,7 +93,7 @@ module.exports = function(RED) {\nRED.nodes.registerType('api-call-service', CallServiceNode, {\nsettings: {\napiCallServiceAdminPrefix: {\n- value: RED.settings.httpAdminRoot,\n+ value: RED.settings.httpAdminRoot || '/',\nexportable: true\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -68,7 +68,7 @@ module.exports = function(RED) {\nRED.nodes.registerType('api-current-state', CurrentStateNode, {\nsettings: {\napiCurrentStateAdminPrefix: {\n- value: RED.settings.httpAdminRoot,\n+ value: RED.settings.httpAdminRoot || '/',\nexportable: true\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -89,7 +89,7 @@ module.exports = function(RED) {\nRED.nodes.registerType('server-state-changed', ServerStateChangedNode, {\nsettings: {\nserverStateChangedAdminPrefix: {\n- value: RED.settings.httpAdminRoot,\n+ value: RED.settings.httpAdminRoot || '/',\nexportable: true\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -87,7 +87,7 @@ module.exports = function(RED) {\nRED.nodes.registerType('poll-state', TimeSinceStateNode, {\nsettings: {\npollStateAdminPrefix: {\n- value: RED.settings.httpAdminRoot,\n+ value: RED.settings.httpAdminRoot || '/',\nexportable: true\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -242,7 +242,7 @@ module.exports = function(RED) {\nRED.nodes.registerType('trigger-state', TriggerState, {\nsettings: {\ntriggerStateAdminPrefix: {\n- value: RED.settings.httpAdminRoot,\n+ value: RED.settings.httpAdminRoot || '/',\nexportable: true\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fix for autocomplete xhr call showing undefined for httpAdminRoot.
* not going to assume that httpAdminRoot is defined
zachowj/node-red-contrib-home-assistant-websocket/issues/2 |
748,234 | 26.09.2018 22:13:50 | 25,200 | 104fd72223891989c8eab3bddd37170102855445 | Version Bump to 0.0.3 | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [0.0.3] - 2018.9.26\n+\n+### Fixed\n+\n+* Fix for autocomplete xhr call showing undefined for httpAdminRoot. Not going to assume that httpAdminRoot is defined. [zachowj/node-red-contrib-home-assistant-websocket/issues/2](https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues/2)\n+\n## [0.0.2] - 2018.9.23\n### Added\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.0.2\",\n+ \"version\": \"0.0.3\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Version Bump to 0.0.3 |
748,234 | 27.09.2018 18:44:00 | 25,200 | 6e7a3b5ef752db0abb79afad7f5065159e16f414 | Added json editor to call-service node data field | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "$domainField.val(node.service_domain);\n$serviceField.val(node.service);\nsetServicesAndDomains(node);\n+ $('#node-input-data').typedInput({\n+ 'types': ['json']\n+ });\nconst utils = {\nsetDefaultServerSelection: function () {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added json editor to call-service node data field |
748,234 | 29.09.2018 22:58:51 | 25,200 | 938a14e72178dd385a6d7e87473543189bc96d2f | Server URL and access token/password credentials are now encrypted
and stored in the node-red cred file.
This also stops them from being exported in flows. | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [Unreleased]\n+\n+### Added\n+\n+* json editor to call-service node data input\n+\n+### Changed\n+\n+* host and access token/password credentials are now encrypted and stored in the node-red cred file. This also stops them from being exported in flows.\n+\n## [0.0.3] - 2018.9.26\n### Fixed\n@@ -17,7 +27,7 @@ All notable changes to this project will be documented in this file.\n### Changed\n-* Docker config you use Home Assistant 0.78.3 and node-red 8.12.0\n+* Docker config to use Home Assistant 0.78.3 and node-red 8.12.0\n### Fixed\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.html",
"new_path": "nodes/config-server/config-server.html",
"diff": "category: 'config',\ndefaults: {\nname: { value: 'Home Assistant', required: false },\n- url: { value: '', required: true },\n- pass: { value: '', required: false },\nlegacy: { value: false }\n},\n+ credentials: {\n+ host: { value: '', required: true },\n+ access_token: { value: '', required: false }\n+ },\nicon: \"home.png\",\nlabel: function() { return this.name || this.url }\n});\n</div>\n<div class=\"form-row\">\n- <label for=\"node-config-input-url\"><i class=\"fa fa-link\"></i> Base URL</label>\n- <input type=\"text\" id=\"node-config-input-url\" placeholder=\"http://localhost:8123\" />\n+ <label for=\"node-config-input-host\"><i class=\"fa fa-link\"></i> Base URL</label>\n+ <input type=\"text\" id=\"node-config-input-host\" placeholder=\"http://localhost:8123\" />\n</div>\n<div class=\"form-row\">\n- <label for=\"node-config-input-pass\"><i class=\"fa fa-user-secret\"></i> Access Token</label>\n- <input type=\"text\" id=\"node-config-input-pass\" placeholder=\"access token\" />\n+ <label for=\"node-config-input-access_token\"><i class=\"fa fa-user-secret\"></i> Access Token</label>\n+ <input type=\"text\" id=\"node-config-input-access_token\" placeholder=\"access token\" />\n</div>\n<div class=\"form-row\">\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -25,8 +25,6 @@ module.exports = function(RED) {\ndebug: true,\nconfig: {\nname: {},\n- url: {},\n- pass: {},\nlegacy: {}\n}\n};\n@@ -35,6 +33,14 @@ module.exports = function(RED) {\nconstructor(nodeDefinition) {\nsuper(nodeDefinition, RED, nodeOptions);\n+ // For backwards compatibility prior to v0.0.4 when loading url and pass from flow.json\n+ if (nodeDefinition.url) {\n+ this.credentials.host = this.credentials.host || nodeDefinition.url;\n+ this.credentials.access_token = this.credentials.access_token || nodeDefinition.pass;\n+\n+ this.RED.nodes.addCredentials(this.id, this.credentials);\n+ }\n+\nthis.RED.httpAdmin.get('/homeassistant/entities', httpHandlers.getEntities.bind(this));\nthis.RED.httpAdmin.get('/homeassistant/states', httpHandlers.getStates.bind(this));\nthis.RED.httpAdmin.get('/homeassistant/services', httpHandlers.getServices.bind(this));\n@@ -46,8 +52,8 @@ module.exports = function(RED) {\nthis.setOnContext('services', []);\nthis.setOnContext('isConnected', false);\n- if (this.nodeConfig.url && !this.homeAssistant) {\n- this.homeAssistant = new HomeAssistant({ baseUrl: this.nodeConfig.url, apiPass: this.nodeConfig.pass, legacy: this.nodeConfig.legacy });\n+ if (this.credentials.host && !this.homeAssistant) {\n+ this.homeAssistant = new HomeAssistant({ baseUrl: this.credentials.host, apiPass: this.credentials.access_token, legacy: this.nodeConfig.legacy });\nthis.api = this.homeAssistant.api;\nthis.websocket = this.homeAssistant.websocket;\n@@ -87,7 +93,7 @@ module.exports = function(RED) {\nthis.setOnContext('isConnected', true);\n- this.log(`New connection ${this.nodeConfig.url}`);\n+ this.log(`New connection ${this.credentials.host}`);\nthis.debug('config server event listener connected');\n} catch (e) {\nthis.error(e);\n@@ -113,5 +119,10 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('server', ConfigServerNode);\n+ RED.nodes.registerType('server', ConfigServerNode, {\n+ credentials: {\n+ host: { type: 'text' },\n+ access_token: { type: 'text' }\n+ }\n+ });\n};\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Server URL and access token/password credentials are now encrypted
and stored in the node-red cred file.
This also stops them from being exported in flows. |
748,234 | 30.09.2018 18:15:55 | 25,200 | 5b74391a2b4e89db730278b1f137374e51904937 | New Fire Event Node to send events to Home Assistant | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.\n### Added\n* json editor to call-service node data input\n+* Fire Event node to send events\n### Changed\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -12,12 +12,28 @@ This assumes you have [node-red](http://nodered.org/) already installed and work\n#### NOTE: node-red-contrib-home-assistant-websocket requires node.JS > 8.0 If you're running Node-Red in Docker you'll need to pull the -v8 image for this to work.\n+Install via Node-RED Manage Palette\n+\n+```shell\n+node-red-contrib-home-assistant-websocket\n+```\n+\n+Install via npm\n+\n```shell\n$ cd cd ~/.node-red\n$ npm install node-red-contrib-home-assistant-websocket\n# then restart node-red\n```\n+If you would like to try out the development branch\n+\n+```shell\n+$ cd cd ~/.node-red\n+$ npm install node-red-contrib-home-assistant-websocket#dev-master\n+# then restart node-red\n+```\n+\nIf you are running Node Red inside Hass.io addon/container you can use Hass.io API Proxy address `http://hassio/homeassistant` as Home Assistant server address (server node Base URL). This way you don't need any real network address.\n=======\n@@ -42,6 +58,9 @@ Outputs the state of an entity at regular intervals, optionally also at startup\n### Call Service - `websocket`\nSends a request to home assistant for any domain and service available ( `light/turn_on`, `input_select/select_option`, etc..)\n+### Fire Event - `rest api`\n+Fire an event on the event bus\n+\n### Get Current State - `websocket`\nFetches the last known state for any entity on input\n@@ -59,6 +78,7 @@ Check out the wiki page for setting up an environment with Home Assistant/Node R\n## Authors\n* **[@AYapejian](https://github.com/AYapejian)** - [node-red-contrib-home-assistant](https://github.com/AYapejian/node-red-contrib-home-assistant)\n* **[@AYapejian](https://github.com/AYapejian)** - [node-home-assistant](https://github.com/AYapejian/node-home-assistant)\n+* **[@zachowj](https://github.com/AYapejian)** - [node-red-contrib-home-assistant-websocket](https://github.com/AYapejian/node-home-assistant-websocket)\n## Acknowledgments\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ha-api.js",
"new_path": "lib/ha-api.js",
"diff": "@@ -58,12 +58,19 @@ class HaApi {\ngetConfig() {\nreturn this._get('config');\n}\n+\ngetDiscoveryInfo() {\nreturn this._get('discovery_info');\n}\n+\n+ fireEvent(event, data) {\n+ return this._post(`events/${event}`, data);\n+ }\n+\ngetErrorLog() {\nreturn this._get('error_log');\n}\n+\n// TODO: Test, entity_id should be `camera.some_cam_entity`\ngetCameraImage(cameraEntityId) {\nreturn this._get(`camera_proxy/${cameraEntityId}`);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "nodes/fire-event/fire-event.html",
"diff": "+<script type=\"text/javascript\">\n+ RED.nodes.registerType('ha-fire-event', {\n+ category: 'home_assistant',\n+ color: '#52C0F2',\n+ inputs: 1,\n+ outputs: 1,\n+ icon: 'feed.png',\n+ align: 'right',\n+ paletteLabel: 'fire event',\n+ label: function () {\n+ return this.name || `Event: ${this.event}`;\n+ },\n+ defaults: {\n+ name: {\n+ value: ''\n+ },\n+ server: {\n+ value: '',\n+ type: 'server',\n+ required: true\n+ },\n+ event: {\n+ value: ''\n+ },\n+ data: {\n+ value: '',\n+ validate: function (v) {\n+ // data isn't required since it could be either not needed or provided via payload\n+ if (!v) {\n+ return true;\n+ }\n+ try {\n+ JSON.parse(v);\n+ return true;\n+ } catch (e) {\n+ return false;\n+ }\n+ }\n+ },\n+ mergecontext: {\n+ value: null\n+ }\n+ },\n+ oneditprepare: function () {\n+ const NODE = this;\n+ const $server = $('#node-input-server');\n+\n+ const node = this;\n+ $('#node-input-data').typedInput({\n+ 'types': ['json']\n+ });\n+\n+ const utils = {\n+ setDefaultServerSelection: function () {\n+ let defaultServer;\n+ RED.nodes.eachConfig(n => {\n+ if (n.type === 'server' && !defaultServer) defaultServer = n.id;\n+ });\n+ if (defaultServer) $server.val(defaultServer);\n+ }\n+ };\n+\n+ if (!NODE.server) {\n+ utils.setDefaultServerSelection();\n+ }\n+ }\n+ });\n+</script>\n+\n+\n+<script type=\"text/x-red\" data-template-name=\"ha-fire-event\">\n+ <div class=\"form-row\">\n+ <label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n+ <input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n+ </div>\n+\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-server\"><i class=\"fa fa-dot-circle-o\"></i> Server</label>\n+ <input type=\"text\" id=\"node-input-server\" />\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-data\"><i class=\"fa fa-cube\"></i> Event</label>\n+ <input type=\"text\" id=\"node-input-event\">\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-data\"><i class=\"fa fa-dot-circle-o\"></i> Data</label>\n+ <input type=\"text\" id=\"node-input-data\" placeholder=\"{ }\"/>\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-mergecontext\"><i class=\"fa fa-dot-circle-o\"></i> Merge Context</label>\n+ <input type=\"text\" id=\"node-input-mergecontext\" placeholder=\"lightOptions\"/>\n+ </div>\n+</script>\n+\n+<script type=\"text/x-red\" data-help-name=\"ha-fire-event\">\n+ <p>Call a Home Assistant service</p>\n+\n+ <h3>Inputs</h3>\n+ <dl class=\"message-properties\">\n+ <dt class=\"optional\">\n+ payload.event <span class=\"property-type\">string</span>\n+ </dt>\n+ <dd>Event to fire</dd>\n+ <dt class=\"optional\">\n+ payload.data <span class=\"property-type\">object</span>\n+ </dt>\n+ <dd>Event data to send</dd>\n+ </dl>\n+\n+ <h3>Outputs</h3>\n+ <dl class=\"message-properties\">\n+ <dt>\n+ payload.event_type <span class=\"property-type\">string</span>\n+ </dt>\n+ <dd>Event Type that was fired</dd>\n+ <dt class=\"optional\">\n+ payload.data <span class=\"property-type\">object</span>\n+ </dt>\n+ <dd>Event <code>data</code> sent, if one was used</dd>\n+ </dl>\n+\n+ <h3>Details</h3>\n+ <p>If the incoming message has a <code>payload</code> property with <code>event</code> set it will override any config values if set.</p>\n+ <p>If the incoming message has a <code>payload.data</code> that is an object or parseable into an object these properties will be <strong>merged</strong> with any config values set.<p>\n+ <p>If the node has a property value in it's config for <code>Merge Context</code> then the <code>flow</code> and <code>global</code> contexts will be checked for this property which should be an object that will also be merged into the data payload.<p>\n+\n+ <h3>Merge Resolution</h3>\n+ <p>As seen above the <code>data</code> property has a lot going on in the way of data merging, in the end all of these are optional and the right most will win in the event that a property exists in multiple objects<p>\n+ <p>Config Data, Global Data, Flow Data, Payload Data ( payload data property always wins if provided )<p>\n+\n+ <h3>References</h3>\n+ <ul>\n+ <li><a href=\"https://developers.home-assistant.io/docs/en/dev_101_events.html#firing-events\">HA Events</a></li>\n+ </ul>\n+</script>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "nodes/fire-event/fire-event.js",
"diff": "+const BaseNode = require('../../lib/base-node');\n+\n+module.exports = function (RED) {\n+ const nodeOptions = {\n+ debug: true,\n+ config: {\n+ event: {},\n+ data: {},\n+ mergecontext: {},\n+ name: {},\n+ server: {\n+ isNode: true\n+ }\n+ }\n+ };\n+\n+ class FireEventNode extends BaseNode {\n+ constructor(nodeDefinition) {\n+ super(nodeDefinition, RED, nodeOptions);\n+ }\n+\n+ // Disable connection status for api node\n+ setConnectionStatus() {}\n+ tryToObject(v) {\n+ if (!v) return null;\n+ try {\n+ return JSON.parse(v);\n+ } catch (e) {\n+ return v;\n+ }\n+ }\n+\n+ onInput({\n+ message\n+ }) {\n+ let payload, payloadEvent;\n+\n+ if (message && message.payload) {\n+ payload = this.tryToObject(message.payload);\n+ payloadEvent = this.utils.reach('event', payload);\n+ }\n+ const configEvent = this.nodeConfig.event;\n+\n+ const eventType = payloadEvent || configEvent;\n+ const eventData = this.getEventData(payload);\n+ if (!eventType) throw new Error('fire event node is missing \"event\" property, not found in config or payload');\n+\n+ this.debug(`Fire Event: ${eventType} -- ${JSON.stringify({})}`);\n+ this.status({\n+ fill: 'green',\n+ shape: 'dot',\n+ text: `${eventType} at: ${this.getPrettyDate()}`\n+ });\n+\n+ message.payload = {\n+ event: eventType,\n+ data: eventData || null\n+ };\n+ this.send(message);\n+\n+ return this.nodeConfig.server.api.fireEvent(eventType, eventData)\n+ .catch(err => {\n+ this.error(`Error firing event, home assistant rest api error: ${err.message}`, message);\n+ this.status({fill: 'red', shape: 'ring', text: `API Error at: ${prettyDate}`});\n+ });\n+ }\n+\n+ getEventData(payload) {\n+ let eventData;\n+ let contextData = {};\n+\n+ let payloadData = this.utils.reach('data', payload);\n+ let configData = this.tryToObject(this.nodeConfig.data);\n+ payloadData = payloadData || {};\n+ configData = configData || {};\n+\n+ // Cacluate payload to send end priority ends up being 'Config, Global Ctx, Flow Ctx, Payload' with right most winning\n+ if (this.nodeConfig.mergecontext) {\n+ const ctx = this.node.context();\n+ let flowVal = ctx.flow.get(this.nodeConfig.mergecontext);\n+ let globalVal = ctx.global.get(this.nodeConfig.mergecontext);\n+ flowVal = flowVal || {};\n+ globalVal = globalVal || {};\n+ contextData = this.utils.merge({}, globalVal, flowVal);\n+ }\n+\n+ eventData = this.utils.merge({}, configData, contextData, payloadData);\n+ return eventData;\n+ }\n+ }\n+\n+ RED.nodes.registerType('ha-fire-event', FireEventNode);\n+};\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"api-call-service\": \"nodes/call-service/call-service.js\",\n\"api-current-state\": \"nodes/current-state/current-state.js\",\n\"api-get-history\": \"nodes/get-history/get-history.js\",\n- \"api-render-template\": \"nodes/render-template/render-template.js\"\n+ \"api-render-template\": \"nodes/render-template/render-template.js\",\n+ \"ha-fire-event\": \"nodes/fire-event/fire-event.js\"\n}\n},\n\"dependencies\": {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | New Fire Event Node to send events to Home Assistant |
748,234 | 30.09.2018 18:20:06 | 25,200 | 6ec2d893b2715ff32cbb48a182a666f3cf203a5c | Version Bump to 0.0.4 | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n-## [Unreleased]\n+## [0.0.4] - 2018.9.31\n### Added\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.0.3\",\n+ \"version\": \"0.0.4\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Version Bump to 0.0.4 |
748,234 | 01.10.2018 20:29:14 | 25,200 | 2c5d194eb957530789f2b40180191e233f67aca1 | fix for not referencing class in fire-event | [
{
"change_type": "MODIFY",
"old_path": "nodes/fire-event/fire-event.js",
"new_path": "nodes/fire-event/fire-event.js",
"diff": "@@ -61,7 +61,7 @@ module.exports = function (RED) {\nreturn this.nodeConfig.server.api.fireEvent(eventType, eventData)\n.catch(err => {\nthis.error(`Error firing event, home assistant rest api error: ${err.message}`, message);\n- this.status({fill: 'red', shape: 'ring', text: `API Error at: ${prettyDate}`});\n+ this.status({ fill: 'red', shape: 'ring', text: `API Error at: ${this.prettyDate}` });\n});\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | fix for not referencing class in fire-event |
748,234 | 02.10.2018 19:11:09 | 25,200 | ffd876a6e97adf91a08d29f19acdd8f42596cd2e | Fixed undefined string in call-server node | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "mergecontext: { value: null }\n},\noneditprepare: function () {\n- const NODE = this;\n+ const node = this;\nconst $server = $('#node-input-server');\nconst $domainField = $('#service_domain');\nconst $unknownServiceDiv = $('.unknown-service', $serviceDataDiv);\nconst $knownServiceDiv = $('.known-service', $serviceDataDiv);\n- const node = this;\n$domainField.val(node.service_domain);\n$serviceField.val(node.service);\nsetServicesAndDomains(node);\n}\n};\n- if (!NODE.server) {\n+ if (!node.server) {\nutils.setDefaultServerSelection();\n}\n// Add table and description for service and service fields\n$serviceDescDiv.html(serviceDesc);\n- $('#service-data-desc .title').html(node.selectedDomain.domain + '.' + selectedServiceText)\n+ $('#service-data-desc .title').html(node.selectedDomain.name + '.' + selectedServiceText)\nif (tableRows) {\n$(\"#service-data-table\").show();\n$serviceDataTableBody.html(tableRows);\n// Hide service data fields and desc\n$unknownServiceDiv.show();\n$knownServiceDiv.hide();\n+ $('#service-data-desc .title').val('');\n}\n} else {\n// Hide service data fields and desc\n$unknownServiceDiv.show();\n$knownServiceDiv.hide();\n+ $('#service-data-desc .title').val('');\n}\n}\nconst knownDomain = (node.allDomains.indexOf(selectedDomainText) > -1);\nnode.selectedDomain = knownDomain\n- ? { services: node.allServices[selectedDomainText] }\n+ ? { services: node.allServices[selectedDomainText], name: selectedDomainText }\n: node.selectedDomain = { services: {} };\n$serviceField.autocomplete({\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fixed undefined string in call-server node |
748,234 | 05.10.2018 05:05:32 | 25,200 | c6420c49216fae337d85ddefa437e4e77995a0dd | Added more testing and debugging to the connection to Home Assistant | [
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -290,6 +290,67 @@ class HaWebsocket extends EventEmitter {\n)\n);\n}\n+\n+ static async testConnection({ baseUrl, apiPass, legacy }) {\n+ debug('[Testing WS] WebSocket Connection');\n+ function connect(promResolve, promReject) {\n+ const url = `ws${baseUrl.substr(4)}/api/websocket`;\n+ debug(`[Testing WS] Testing ${url}`);\n+ const ws = new WebSocket(url);\n+\n+ ws.on('open', function open() {\n+ const authObj = {\n+ type: 'auth'\n+ };\n+\n+ const authType = legacy ? 'api_password' : 'access_token';\n+ authObj[authType] = apiPass;\n+\n+ try {\n+ ws.send(JSON.stringify(authObj));\n+ } catch (err) {\n+ ws.close();\n+ return promReject(err);\n+ }\n+ });\n+\n+ ws.on('message', function incoming(data) {\n+ const msg = JSON.parse(data);\n+\n+ switch (msg.type) {\n+ case MSG_TYPE_AUTH_INVALID:\n+ ws.close();\n+ return promReject(\n+ '[Home Assistant WS] Invalid access token or password.'\n+ );\n+\n+ case MSG_TYPE_AUTH_OK:\n+ ws.close();\n+ return promResolve(true);\n+\n+ default:\n+ if (msg.type !== MSG_TYPE_AUTH_REQUIRED) {\n+ return promReject(\n+ `[Home Assistant WS] Unhandled message recieved :: ${JSON.stringify(\n+ msg\n+ )}`\n+ );\n+ }\n+ }\n+ });\n+\n+ ws.on('error', function error(err) {\n+ ws.close();\n+ return promReject(err);\n+ });\n+ }\n+ return new Promise((resolve, reject) =>\n+ connect(\n+ resolve,\n+ reject\n+ )\n+ );\n+ }\n}\nmodule.exports = HaWebsocket;\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/node-home-assistant.js",
"new_path": "lib/node-home-assistant.js",
"diff": "@@ -33,7 +33,8 @@ class HomeAssistant {\nlegacy\n});\ntry {\n- await apiTest.getConfig();\n+ debug('[Testing REST] REST Connection');\n+ this.haConfig = await apiTest.getConfig();\nreturn true;\n} catch (e) {\nreturn e;\n@@ -47,33 +48,49 @@ class HomeAssistant {\nthis.config.websocket.includeRegex = includeRegex;\nthis.config.websocket.excludeRegex = excludeRegex;\n+ let isWebsocketConnected = await HaWebsocket.testConnection(\n+ this.config\n+ );\n+ if (isWebsocketConnected !== true) {\n+ if (isWebsocketConnected.code) {\n+ debug(`[Testing WS] ${isWebsocketConnected.toString()}`);\n+ throw new Error(\n+ `Connecting to ${isWebsocketConnected.address}:${\n+ isWebsocketConnected.port\n+ } - Code: ${isWebsocketConnected.code}`\n+ );\n+ }\n+\n+ debug('Invalid access token or password for websocket');\n+ throw new Error('[Testing WS] Invalid access token or password.');\n+ } else {\n+ debug('[Testing WS] WebSocket Connection Good');\n+ }\n+\nconst isConnectionWorking = await HomeAssistant.testConnection(\nthis.config\n);\nif (isConnectionWorking !== true) {\n- if (\n- isConnectionWorking.code &&\n- isConnectionWorking.code === 'ECONNREFUSED'\n- ) {\n- debug(isConnectionWorking.toString());\n+ if (isConnectionWorking.code) {\n+ debug(`[Testing REST] ${JSON.stringify(isConnectionWorking)}`);\nthrow new Error(\n- `Connection refused by ${isConnectionWorking.address}:${\n+ `Errpr connecting to ${isConnectionWorking.address}:${\nisConnectionWorking.port\n- }`\n+ } - Code: ${isConnectionWorking.code}`\n);\n}\ndebug('Invalid access token or password for http');\n- throw new Error(\n- '[Home Assistant] Invalid access token or password.'\n- );\n+ throw new Error('[Testing REST] Invalid access token or password.');\n+ } else {\n+ debug('[Testing REST] REST Connection Good');\n}\n- const isWebsocketConnected = await this.websocket.startListening();\n+ isWebsocketConnected = await this.websocket.startListening();\nif (!isWebsocketConnected) {\ndebug('Invalid access token or password for websocket');\nthrow new Error(\n- '[Home Assistant] Invalid access token or password.'\n+ '[Home Assistant WS] Invalid access token or password.'\n);\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added more testing and debugging to the connection to Home Assistant |
748,234 | 05.10.2018 05:10:31 | 25,200 | 55708d68e592f1cfc17da61e53248974fa6dbb63 | Changes to README and CHANGELOG | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "@@ -7,6 +7,13 @@ All notable changes to this project will be documented in this file.\n### Added\n- Linting and formating into pre-commit hooks using eslint and prettier\n+- More logging to the testing of the connection to Home Assistant\n+- Boilerplate for adding tests\n+\n+### Fixed\n+\n+- Undefined string in call-service node\n+- Forgot to reference class function in fire-event node\n## [0.0.4] - 2018.9.31\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "# Node Red Contrib Home Assistant Websocket\n+[](https://travis-ci.com/zachowj/node-red-contrib-home-assistant-websocket) [](https://coveralls.io/github/zachowj/node-red-contrib-home-assistant-websocket?branch=master)\n+\nVarious nodes to assist in setting up automation using [node-red](https://nodered.org/) communicating with [Home Assistant](https://home-assistant.io/).\n## Project status\n-Project is going through active development and as such will probably have a few 'growing pain' bugs as well as node type, input, output and functionality changes. At this stage backwards compatibility between versions is not a main concern and a new version __may mean you'll have to recreate certain nodes.__\n+Project is going through active development and as such will probably have a few 'growing pain' bugs as well as node type, input, output and functionality changes. At this stage backwards compatibility between versions is not a main concern and a new version **may mean you'll have to recreate certain nodes.**\n## Getting Started\n@@ -40,47 +42,60 @@ If you are running Node Red inside Hass.io addon/container you can use Hass.io A\nFor flow examples checkout the [flows here](https://raw.githubusercontent.com/zachowj/node-red-contrib-home-assistant-websocket/master/docker/node-red/root-fs/data/flows.json)\n---\n+\n## Included Nodes\n+\nThe installed nodes have more detailed information in the node-red info pane shown when the node is selected. Below is a quick summary\n### All Events - `websocket`\n+\nListens for all types of events from home assistant\n### State Changed Event - `websocket`\n+\nListens for only `state_changed` events from home assistant\n### State Trigger - `websocket`\n+\nMuch like the `State Changed Ndoe` however provides some advanced functionality around common automation use cases.\n### Poll State - `websocket`\n+\nOutputs the state of an entity at regular intervals, optionally also at startup and every time the entity changes if desired\n### Call Service - `websocket`\n+\nSends a request to home assistant for any domain and service available ( `light/turn_on`, `input_select/select_option`, etc..)\n### Fire Event - `rest api`\n+\nFire an event on the event bus\n### Get Current State - `websocket`\n+\nFetches the last known state for any entity on input\n### Get History - `rest api`\n+\nFetches HomeAssistant history on input\n### Get Template - `rest api`\n+\nAllows rendering of templates on input\n## Development\n+\nCheck out the wiki page for setting up an environment with Home Assistant/Node Red.\n[Development Wiki](https://github.com/zachowj/node-red-contrib-home-assistant-websocket/wiki/Development)\n## Authors\n-* **[@AYapejian](https://github.com/AYapejian)** - [node-red-contrib-home-assistant](https://github.com/AYapejian/node-red-contrib-home-assistant)\n-* **[@AYapejian](https://github.com/AYapejian)** - [node-home-assistant](https://github.com/AYapejian/node-home-assistant)\n-* **[@zachowj](https://github.com/AYapejian)** - [node-red-contrib-home-assistant-websocket](https://github.com/AYapejian/node-home-assistant-websocket)\n+\n+- **[@AYapejian](https://github.com/AYapejian)** - [node-red-contrib-home-assistant](https://github.com/AYapejian/node-red-contrib-home-assistant)\n+- **[@AYapejian](https://github.com/AYapejian)** - [node-home-assistant](https://github.com/AYapejian/node-home-assistant)\n+- **[@zachowj](https://github.com/AYapejian)** - [node-red-contrib-home-assistant-websocket](https://github.com/AYapejian/node-home-assistant-websocket)\n## Acknowledgments\n-* [home-assistant-js-websocket](https://github.com/home-assistant/home-assistant-js-websocket)\n-* [@Spartan-II-117](https://github.com/Spartan-II-117)\n\\ No newline at end of file\n+- [home-assistant-js-websocket](https://github.com/home-assistant/home-assistant-js-websocket)\n+- [@Spartan-II-117](https://github.com/Spartan-II-117)\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Changes to README and CHANGELOG |
748,234 | 05.10.2018 05:12:18 | 25,200 | abef18f56f57cf1c9bba74283dfd553643de8198 | Version Bump to 0.0.5 | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.0.4\",\n+ \"version\": \"0.0.5\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Version Bump to 0.0.5 |
748,234 | 06.10.2018 02:51:17 | 25,200 | 7f731c5109935c2d954ce1f50f543699b3cd2de9 | Close existing websocket on deploy | [
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -135,7 +135,7 @@ module.exports = function(RED) {\nthis.setOnContext('isConnected', true);\n- this.log(`New connection ${this.credentials.host}`);\n+ this.log(`New WebSocket ${this.credentials.host}`);\nthis.debug('config server event listener connected');\n} catch (e) {\nthis.error(e);\n@@ -159,6 +159,20 @@ module.exports = function(RED) {\nthis.setOnContext('isConnected', false);\nthis.debug(err);\n}\n+\n+ // Close WebSocket client on redeploy or node-RED shutdown\n+ async onClose(removed) {\n+ super.onClose();\n+ const webSocketClient = this.utils.reach(\n+ 'homeAssistant.websocket.client',\n+ this\n+ );\n+\n+ if (webSocketClient) {\n+ this.log(`Closing WebSocket ${this.credentials.host}`);\n+ webSocketClient.close();\n+ }\n+ }\n}\nRED.nodes.registerType('server', ConfigServerNode, {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Close existing websocket on deploy |
748,234 | 06.10.2018 05:21:15 | 25,200 | c73b226fe9a6998fc2616e5f7c5149c0a43b2c0a | Output Initially / On Deploy for trigger-state and events: state node
Poll state node to wait for a state before triggering
Spartan-II-117/node-red-contrib-home-assistant/issues/36 | [
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -16,6 +16,7 @@ class HaWebsocket extends EventEmitter {\nthis.connected = false;\nthis.states = {};\nthis.services = {};\n+ this.statesLoaded = false;\nthis.setMaxListeners(0);\n}\n@@ -73,6 +74,12 @@ class HaWebsocket extends EventEmitter {\n}\nthis.states = msg;\n+\n+ if (!this.statesLoaded) {\n+ debug('First load of states');\n+ this.statesLoaded = true;\n+ this.emit('ha_events:states_loaded');\n+ }\n}\nonClientServices(msg) {\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "server: { value: '', type: 'server', required: true },\nentityidfilter: { value: '', required: true },\nentityidfiltertype: { value: 'substring' },\n- haltifstate: { value: '' }\n+ haltifstate: { value: '' },\n+ outputinitially: { value: false }\n},\ninputs: 0,\noutputs: 1,\n<input type=\"text\" id=\"node-input-haltifstate\" />\n</div>\n+ <div class=\"form-row\">\n+ <input type=\"checkbox\" id=\"node-input-outputinitially\" style=\"display: inline-block; width: auto; vertical-align: top;\">\n+ <label for=\"node-input-outputinitially\" style=\"width: auto;\">Output Initially / On Deploy</label>\n+ </div>\n</script>\n<script type=\"text/x-red\" data-help-name=\"server-state-changed\">\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -15,7 +15,8 @@ module.exports = function(RED) {\n},\nentityidfiltertype: {},\nhaltIfState: nodeDef =>\n- nodeDef.haltifstate ? nodeDef.haltifstate.trim() : null\n+ nodeDef.haltifstate ? nodeDef.haltifstate.trim() : null,\n+ outputinitially: {}\n}\n};\n@@ -26,6 +27,13 @@ module.exports = function(RED) {\nevent: 'ha_events:state_changed',\nhandler: this.onHaEventsStateChanged.bind(this)\n});\n+\n+ if (this.nodeConfig.outputinitially) {\n+ this.addEventClientListener({\n+ event: 'ha_events:states_loaded',\n+ handler: this.onDeploy.bind(this)\n+ });\n+ }\n}\nonHaEventsStateChanged(evt) {\n@@ -90,6 +98,24 @@ module.exports = function(RED) {\n}\n}\n+ async onDeploy() {\n+ const entities = await this.nodeConfig.server.homeAssistant.getStates();\n+\n+ for (let entityId in entities) {\n+ let eventMessage = {\n+ event_type: 'state_changed',\n+ entity_id: entityId,\n+ event: {\n+ entity_id: entityId,\n+ old_state: entities[entityId],\n+ new_state: entities[entityId]\n+ }\n+ };\n+\n+ this.onHaEventsStateChanged(eventMessage);\n+ }\n+ }\n+\nshouldHaltIfState(haEvent, haltIfState) {\nif (!this.nodeConfig.haltIfState) return false;\nconst shouldHalt =\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "</div>\n<div class=\"form-row\">\n- <label for=\"node-input-outputonchanged\"><i class=\"fa fa-server\"></i> Output on Changed</label>\n- <input type=\"checkbox\" id=\"node-input-outputonchanged\" />\n+ <input type=\"checkbox\" id=\"node-input-outputonchanged\" style=\"display: inline-block; width: auto; vertical-align: top;\">\n+ <label for=\"node-input-outputonchanged\" style=\"width: auto;\">Output on Changed</label>\n</div>\n<div class=\"form-row\">\n- <label for=\"node-input-outputinitially\"><i class=\"fa fa-server\"></i> Output Initially</label>\n- <input type=\"checkbox\" id=\"node-input-outputinitially\" />\n+ <input type=\"checkbox\" id=\"node-input-outputinitially\" style=\"display: inline-block; width: auto; vertical-align: top;\">\n+ <label for=\"node-input-outputinitially\" style=\"width: auto;\">Output Initially / On Deploy</label>\n</div>\n</script>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -44,8 +44,9 @@ module.exports = function(RED) {\n}\nif (this.nodeConfig.outputinitially) {\n- process.nextTick(() => {\n- this.onTimer();\n+ this.addEventClientListener({\n+ event: 'ha_events:states_loaded',\n+ handler: this.onTimer.bind(this)\n});\n}\n}\n@@ -109,17 +110,12 @@ module.exports = function(RED) {\nconst entityLastChanged = entityState.last_changed;\nreturn new Date(entityLastChanged);\n}\n- // Try to fetch from cache, if not found then try and pull fresh\n+\nasync getState(entityId) {\nlet state = await this.nodeConfig.server.homeAssistant.getStates(\nthis.nodeConfig.entity_id\n);\n- if (!state) {\n- state = await this.nodeConfig.server.homeAssistant.getStates(\n- this.nodeConfig.entity_id,\n- true\n- );\n- }\n+\nreturn state;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "<input type=\"text\" id=\"node-input-entityid\" placeholder=\"binary_sensor\" style=\"width: 70%;\" />\n</div>\n+ <div class=\"form-row\">\n+ <input type=\"checkbox\" id=\"node-input-outputinitially\" style=\"display: inline-block; width: auto; vertical-align: top;\">\n+ <label for=\"node-input-outputinitially\" style=\"width: auto;\">Output Initially / On Deploy</label>\n+ </div>\n+\n<!-- -------------------------------------------------------------- -->\n<!-- Add Custom Constraints -->\n<!-- -------------------------------------------------------------- -->\nconstraints: { value: [] },\nconstraintsmustmatch: { value: 'all' },\noutputs: { value: 2 },\n- customoutputs: { value: [] }\n+ customoutputs: { value: [] },\n+ outputinitially: { value: false }\n},\ninputs: 1,\noutputs: 2,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -8,7 +8,8 @@ module.exports = function(RED) {\nentityid: {},\nisenabled: {},\nconstraints: {},\n- customoutputs: {}\n+ customoutputs: {},\n+ outputinitially: {}\n}\n};\n@@ -27,6 +28,13 @@ module.exports = function(RED) {\nthis.messageTimers = {};\nthis.loadPersistedData();\n+\n+ if (this.nodeConfig.outputinitially) {\n+ this.addEventClientListener({\n+ event: 'ha_events:states_loaded',\n+ handler: this.onDeploy.bind(this)\n+ });\n+ }\n}\nonInput({ message }) {\n@@ -55,6 +63,24 @@ module.exports = function(RED) {\n}\n}\n+ async onDeploy() {\n+ const entityState = await this.nodeConfig.server.homeAssistant.getStates(\n+ this.nodeConfig.entityid\n+ );\n+\n+ let eventMessage = {\n+ event_type: 'state_changed',\n+ entity_id: this.nodeConfig.entityid,\n+ event: {\n+ entity_id: this.nodeConfig.entityid,\n+ old_state: entityState,\n+ new_state: entityState\n+ }\n+ };\n+\n+ this.onEntityStateChanged(eventMessage);\n+ }\n+\nasync onEntityStateChanged(eventMessage) {\nif (this.isenabled === false) {\nthis.debugToClient(\n@@ -146,7 +172,11 @@ module.exports = function(RED) {\n);\nif (comparatorResult === false) {\n- this.debugToClient(`constraint comparator: failed entity \"${constraintTarget.entityid}\" property \"${propertyValue}\" with value ${actualValue} failed \"${comparatorType}\" check against (${comparatorValueDatatype}) ${comparatorValue}`); // eslint-disable-line\n+ this.debugToClient(\n+ `constraint comparator: failed entity \"${\n+ constraintTarget.entityid\n+ }\" property \"${propertyValue}\" with value ${actualValue} failed \"${comparatorType}\" check against (${comparatorValueDatatype}) ${comparatorValue}`\n+ ); // eslint-disable-line\n}\ncomparatorResults.push({\n@@ -313,7 +343,13 @@ module.exports = function(RED) {\n) {\n// If comparator did not match\nif (!comparatorMatched) {\n- this.debugToClient(`output comparator failed: property \"${output.comparatorPropertyValue}\" with value ${actualValue} failed \"${output.comparatorType}\" check against ${output.comparatorValue}`); // eslint-disable-line\n+ this.debugToClient(\n+ `output comparator failed: property \"${\n+ output.comparatorPropertyValue\n+ }\" with value ${actualValue} failed \"${\n+ output.comparatorType\n+ }\" check against ${output.comparatorValue}`\n+ ); // eslint-disable-line\nreturn null;\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Output Initially / On Deploy for trigger-state and events: state node
Poll state node to wait for a state before triggering
https://github.com/AYapejian/node-red-contrib-home-assistant/issues/64
Spartan-II-117/node-red-contrib-home-assistant/issues/36 |
748,234 | 06.10.2018 05:23:22 | 25,200 | b5a0eba7fbb596eab0c1fb154155c052d67e1f0f | Version Bump to 0.0.6 | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.0.5\",\n+ \"version\": \"0.0.6\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Version Bump to 0.0.6 |
748,234 | 06.10.2018 13:37:26 | 25,200 | 42a079e572ab1fb44475f014af85265512e68717 | Added checks to see if server is selected before calling get entities | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [Unreleased]\n+\n+### Fixed\n+\n+- Added more checks to see if server is selected before call \"GET /homeassistant/entities\"\n+\n## [0.0.6] 2018.10.6\n### Added\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "$domainField.val(node.service_domain);\n$serviceField.val(node.service);\n- setServicesAndDomains(node);\n+\n$('#node-input-data').typedInput({\n'types': ['json']\n});\nutils.setDefaultServerSelection();\n}\n+ // If a server is selected populate dropdowns\n+ const selectedServer = $server.val();\n+ if (node.server || (selectedServer && selectedServer !== '_ADD_')) {\n+ setServicesAndDomains(node);\n+ }\n+\n// Calls the custom api backend defined in the config-server.js node\n// TODO: Not sure how this works with node-red if auth is enabled\nfunction setServicesAndDomains(node) {\n+\nreturn $.get(`${RED.settings.apiCallServiceAdminPrefix}homeassistant/services`)\n.then(services => {\nnode.allServices = JSON.parse(services);\nreturn node;\n})\n.fail((err) => RED.notify(err.responseText, 'error'));\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "if (!isConfigValid) { $entityIdField.addClass('disabled'); }\nelse { $entityIdField.removeClass('disabled'); }\n+ const selectedServer = $server.val();\n+ if (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n$.get(`${RED.settings.apiCurrentStateAdminPrefix}homeassistant/entities`)\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\nelse { $entityIdField.addClass('input-error'); }\n})\n.fail((err) => RED.notify(err.responseText, 'error'));\n+ }\n},\noneditsave: function () {\nthis.entity_id = $(\"#entity_id\").val();\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "if (!isConfigValid) { $entityIdField.addClass('disabled'); }\nelse { $entityIdField.removeClass('disabled'); }\n+ const selectedServer = $server.val();\n+ if (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n$.get(`${RED.settings.pollStateAdminPrefix}homeassistant/entities`)\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\nelse { $entityIdField.addClass('input-error'); }\n})\n.fail((err) => RED.notify(err.responseText, 'error'));\n+ }\n},\noneditsave: function () { this.entity_id = $(\"#entity_id\").val(); }\n});\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added checks to see if server is selected before calling get entities |
748,234 | 06.10.2018 15:01:00 | 25,200 | 18b6809691c44c9584657d5a5c2c469b56facdb8 | README update for hass.io | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -23,7 +23,7 @@ node-red-contrib-home-assistant-websocket\nInstall via npm\n```shell\n-$ cd cd ~/.node-red\n+$ cd ~/.node-red\n$ npm install node-red-contrib-home-assistant-websocket\n# then restart node-red\n```\n@@ -31,12 +31,22 @@ $ npm install node-red-contrib-home-assistant-websocket\nIf you would like to try out the development branch\n```shell\n-$ cd cd ~/.node-red\n+$ cd ~/.node-red\n$ npm install node-red-contrib-home-assistant-websocket#dev-master\n# then restart node-red\n```\n-If you are running Node Red inside Hass.io addon/container you can use Hass.io API Proxy address `http://hassio/homeassistant` as Home Assistant server address (server node Base URL). This way you don't need any real network address.\n+For [Hass.io](https://hass.io/) add-on users:\n+\n+Use Hass.io API Proxy address `http://hassio/homeassistant` as Home Assistant server address (server node Base URL). This way you don't need any real network address.\n+\n+Add the following NPM package to the addon configuration:\n+\n+```\n+\"npm_packages\": [\n+\"git+https://github.com/zachowj/node-red-contrib-home-assistant-websocket\"\n+],\n+```\n=======\nFor flow examples checkout the [flows here](https://raw.githubusercontent.com/zachowj/node-red-contrib-home-assistant-websocket/master/docker/node-red/root-fs/data/flows.json)\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | README update for hass.io |
748,234 | 07.10.2018 00:29:16 | 25,200 | 05ece0329b8696ca030d038ae3e11e2a6cd4685a | Version Bump to 0.0.7 | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.0.6\",\n+ \"version\": \"0.0.7\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Version Bump to 0.0.7 |
748,234 | 08.10.2018 14:35:55 | 25,200 | 375d23bbc20d5768fdf980d5eef82fed18150f99 | Added support for reading the HASSIO_TOKEN for hass.io and using that in the server config if the server address is the hass.io proxy | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -38,14 +38,17 @@ $ npm install node-red-contrib-home-assistant-websocket#dev-master\nFor [Hass.io](https://hass.io/) add-on users:\n-Use Hass.io API Proxy address `http://hassio/homeassistant` as Home Assistant server address (server node Base URL). This way you don't need any real network address.\n+Use the Hass.io API Proxy address `http://hassio/homeassistant` as the Home Assistant server address (Base URL). The access token field can be left empty as the plugin will fill it in with the HASSIO_TOKEN when you deploy your flows.\n-Add the following NPM package to the addon configuration:\n+Add the following to the Node-RED addon configuration:\n```\n\"npm_packages\": [\n\"git+https://github.com/zachowj/node-red-contrib-home-assistant-websocket\"\n],\n+\"init_commands\": [\n+ \"npm uninstall node-red-contrib-home-assistant\"\n+],\n```\n=======\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -213,7 +213,11 @@ class HaWebsocket extends EventEmitter {\n}\n// Convert from http:// -> ws://, https:// -> wss://\n- const url = `ws${this.auth.baseUrl.substr(4)}/api/websocket`;\n+ const isHassio = this.auth.baseUrl === 'http://hassio/homeassistant';\n+ const url = `ws${this.auth.baseUrl.substr(4)}${\n+ isHassio ? '' : '/api'\n+ }/websocket`;\n+\nconst authObj = {\ntype: 'auth'\n};\n@@ -301,7 +305,10 @@ class HaWebsocket extends EventEmitter {\nstatic async testConnection({ baseUrl, apiPass, legacy }) {\ndebug('[Testing WS] WebSocket Connection');\nfunction connect(promResolve, promReject) {\n- const url = `ws${baseUrl.substr(4)}/api/websocket`;\n+ const isHassio = baseUrl === 'http://hassio/homeassistant';\n+ const url = `ws${baseUrl.substr(4)}${\n+ isHassio ? '' : '/api'\n+ }/websocket`;\ndebug(`[Testing WS] Testing ${url}`);\nconst ws = new WebSocket(url);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -45,6 +45,12 @@ module.exports = function(RED) {\nthis.RED.nodes.addCredentials(this.id, this.credentials);\n}\n+ // Check if using Hass.io URL and import proxy token\n+ if (this.credentials.host === 'http://hassio/homeassistant') {\n+ this.credentials.access_token = process.env.HASSIO_TOKEN;\n+\n+ this.RED.nodes.addCredentials(this.id, this.credentials);\n+ }\nthis.RED.httpAdmin.get(\n'/homeassistant/entities',\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added support for reading the HASSIO_TOKEN for hass.io and using that in the server config if the server address is the hass.io proxy |
748,234 | 08.10.2018 17:28:21 | 25,200 | 3aa3620e43e8701f4ed19aa0f6cacdfb95d8c53a | Version Bump to 0.1.0 and CHANGELOG | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [0.1.0] 2018.10.8\n+\n+### Added\n+\n+- Support for reading the HASSIO_TOKEN from hass.io and using that in the server config if the server URL is the hass.io proxy\n+\n+### Fixed\n+\n+- Use the correct hass.io proxy url for websockets\n+\n## [0.0.7] 2018.10.7\n### Fixed\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.0.7\",\n+ \"version\": \"0.1.0\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Version Bump to 0.1.0 and CHANGELOG |
748,234 | 09.10.2018 19:59:17 | 25,200 | 73f08cfd38bc075f0d688b1fd644fe2b76973856 | Stop poll-state node from firing if not connected to home assistant | [
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -60,6 +60,8 @@ module.exports = function(RED) {\n}\nasync onTimer() {\n+ if (!this.isConnected) return;\n+\ntry {\nconst pollState = await this.getState(\nthis.nodeConfig.entity_id\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Stop poll-state node from firing if not connected to home assistant |
748,234 | 10.10.2018 20:43:08 | 25,200 | f6c55473bdd2fdcf13616c1066d42226dd8ba9bd | Set full states object to the global Home Assistant context on load | [
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -76,9 +76,8 @@ class HaWebsocket extends EventEmitter {\nthis.states = msg;\nif (!this.statesLoaded) {\n- debug('First load of states');\nthis.statesLoaded = true;\n- this.emit('ha_events:states_loaded');\n+ this.emit('ha_events:states_loaded', this.states);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -109,6 +109,10 @@ module.exports = function(RED) {\n'ha_events:state_changed',\nthis.onHaStateChanged.bind(this)\n);\n+ this.websocket.addListener(\n+ 'ha_events:states_loaded',\n+ this.onHaStatesLoaded.bind(this)\n+ );\n}\n}\n@@ -156,6 +160,10 @@ module.exports = function(RED) {\n}\n}\n+ onHaStatesLoaded(states) {\n+ this.setOnContext('states', states);\n+ }\n+\nonHaEventsClose() {\nthis.setOnContext('isConnected', false);\nthis.debug('config server event listener closed');\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Set full states object to the global Home Assistant context on load |
748,234 | 11.10.2018 00:07:19 | 25,200 | 6ce93ad31019f2e7a07dd2a73c4fa96c1f8cb0a0 | Added fire-event tests | [
{
"change_type": "MODIFY",
"old_path": "test/fire-event_spec.js",
"new_path": "test/fire-event_spec.js",
"diff": "@@ -21,4 +21,151 @@ describe('fire-event node', function() {\ndone();\n});\n});\n+\n+ // Merge Context: Payload Data > Flow Data > Global Data > Config Data ( payload data property always wins if provided )\n+\n+ it('should pass config data through', function(done) {\n+ var flow = [\n+ {\n+ id: 'n1',\n+ type: 'ha-fire-event',\n+ name: 'fire-event',\n+ event: 'test',\n+ data: { foo: 'bar' },\n+ wires: [['n2']]\n+ },\n+ { id: 'n2', type: 'helper' }\n+ ];\n+\n+ helper.load(fireEvent, flow, function() {\n+ var n1 = helper.getNode('n1');\n+ var n2 = helper.getNode('n2');\n+\n+ n2.on('input', function(msg) {\n+ msg.payload.should.have.property('event', 'test');\n+ msg.payload.data.should.have.property('foo', 'bar');\n+ done();\n+ });\n+\n+ n1.receive({ payload: 'foo', topic: 'bar' });\n+ });\n+ });\n+\n+ it('should pass config event through but empty config data', function(done) {\n+ var flow = [\n+ {\n+ id: 'n1',\n+ type: 'ha-fire-event',\n+ name: 'fire-event',\n+ event: 'test',\n+ wires: [['n2']]\n+ },\n+ { id: 'n2', type: 'helper' }\n+ ];\n+\n+ helper.load(fireEvent, flow, function() {\n+ var n1 = helper.getNode('n1');\n+ var n2 = helper.getNode('n2');\n+\n+ n2.on('input', function(msg) {\n+ msg.payload.should.have.property('event', 'test');\n+ msg.payload.should.have.property('data', {});\n+ done();\n+ });\n+\n+ n1.receive({ payload: 'foo', topic: 'bar' });\n+ });\n+ });\n+\n+ it('should merge global data and pass through', function(done) {\n+ var flow = [\n+ {\n+ id: 'n1',\n+ type: 'ha-fire-event',\n+ name: 'fire-event',\n+ event: 'test',\n+ data: { foo: 'bar' },\n+ mergecontext: 'mergeName',\n+ z: 'flowA',\n+ wires: [['n2']]\n+ },\n+ { id: 'n2', type: 'helper', z: 'flowA' }\n+ ];\n+\n+ helper.load(fireEvent, flow, function() {\n+ var n1 = helper.getNode('n1');\n+ var n2 = helper.getNode('n2');\n+\n+ n1.context().global.set('mergeName', { foo: 'baz' });\n+\n+ n2.on('input', function(msg) {\n+ msg.payload.data.should.have.property('foo', 'baz');\n+ done();\n+ });\n+\n+ n1.receive({ payload: 'foo', topic: 'bar' });\n+ });\n+ });\n+\n+ it('should merge flow data and pass through', function(done) {\n+ var flow = [\n+ {\n+ id: 'n1',\n+ type: 'ha-fire-event',\n+ name: 'fire-event',\n+ event: 'test',\n+ data: { foo: 'bar' },\n+ mergecontext: 'mergeName',\n+ z: 'flowA',\n+ wires: [['n2']]\n+ },\n+ { id: 'n2', type: 'helper', z: 'flowA' }\n+ ];\n+\n+ helper.load(fireEvent, flow, function() {\n+ var n1 = helper.getNode('n1');\n+ var n2 = helper.getNode('n2');\n+\n+ n1.context().global.set('mergeName', { foo: 'baz' });\n+ n1.context().flow.set('mergeName', { foo: 'zxc' });\n+\n+ n2.on('input', function(msg) {\n+ msg.payload.data.should.have.property('foo', 'zxc');\n+ done();\n+ });\n+\n+ n1.receive({ payload: 'foo', topic: 'bar' });\n+ });\n+ });\n+\n+ it('should merge payload data and pass through', function(done) {\n+ var flow = [\n+ {\n+ id: 'n1',\n+ type: 'ha-fire-event',\n+ name: 'fire-event',\n+ event: 'test',\n+ data: { foo: 'bar' },\n+ mergecontext: 'mergeName',\n+ z: 'flowA',\n+ wires: [['n2']]\n+ },\n+ { id: 'n2', type: 'helper', z: 'flowA' }\n+ ];\n+\n+ helper.load(fireEvent, flow, function() {\n+ var n1 = helper.getNode('n1');\n+ var n2 = helper.getNode('n2');\n+\n+ n1.context().global.set('mergeName', { foo: 'baz' });\n+ n1.context().flow.set('mergeName', { foo: 'zxc' });\n+\n+ n2.on('input', function(msg) {\n+ msg.payload.data.should.have.property('foo', 'toto');\n+ done();\n+ });\n+\n+ n1.receive({ payload: { data: { foo: 'toto' } }, topic: 'bar' });\n+ });\n+ });\n});\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added fire-event tests |
748,234 | 12.10.2018 03:57:40 | 25,200 | 5024f2b2da29875fc657e8e3bd5f8607b87685ee | fix for test:watch to actually work from npm run test:watch | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"scripts\": {\n\"test\": \"mocha \\\"test/**/*_spec.js\\\"\",\n\"test-travis\": \"istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec test/**/*_spec.js\",\n- \"test:watch\": \"nodemon -w test/ -w lib/ -w nodes/ --exec 'node_modules/mocha/bin/mocha ./test/*'\",\n+ \"test:watch\": \"nodemon -w test/ -w lib/ -w nodes/ --exec ./node_modules/.bin/mocha test/*\",\n\"dev\": \"npm run docker:up\",\n\"dev:clean\": \"npm run docker:down\",\n\"docker:up\": \"npm run docker -- up --build --abort-on-container-exit --remove-orphans\",\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | fix for test:watch to actually work from npm run test:watch |
748,234 | 18.10.2018 03:18:41 | 25,200 | 3da9b9252cf00ac6ecf89afcd2b11110964d5128 | Add permissions check for the httpAdmin getsFixes | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [0.1.2] 2018.10.18\n+\n+### Security\n+\n+- Added permission checks for the httpAdmin endpoints for autocomplete [Fixes #7](https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues/7)\n+\n## [0.1.1] 2018.10.11\n### Added\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "// TODO: Not sure how this works with node-red if auth is enabled\nfunction setServicesAndDomains(node) {\n- return $.get(`${RED.settings.apiCallServiceAdminPrefix}homeassistant/services`)\n+ return $.get(`homeassistant/services`)\n.then(services => {\nnode.allServices = JSON.parse(services);\nnode.allDomains = Object.keys(node.allServices);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.js",
"new_path": "nodes/call-service/call-service.js",
"diff": "@@ -120,12 +120,5 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('api-call-service', CallServiceNode, {\n- settings: {\n- apiCallServiceAdminPrefix: {\n- value: RED.settings.httpAdminRoot || '/',\n- exportable: true\n- }\n- }\n- });\n+ RED.nodes.registerType('api-call-service', CallServiceNode);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -54,14 +54,17 @@ module.exports = function(RED) {\nthis.RED.httpAdmin.get(\n'/homeassistant/entities',\n+ RED.auth.needsPermission('server.read'),\nhttpHandlers.getEntities.bind(this)\n);\nthis.RED.httpAdmin.get(\n'/homeassistant/states',\n+ RED.auth.needsPermission('server.read'),\nhttpHandlers.getStates.bind(this)\n);\nthis.RED.httpAdmin.get(\n'/homeassistant/services',\n+ RED.auth.needsPermission('server.read'),\nhttpHandlers.getServices.bind(this)\n);\n@@ -69,12 +72,13 @@ module.exports = function(RED) {\nroot: require('path').join(__dirname, '..', '/_static'),\ndotfiles: 'deny'\n};\n- this.RED.httpAdmin.get('/homeassistant/static/*', function(\n- req,\n- res\n- ) {\n+ this.RED.httpAdmin.get(\n+ '/homeassistant/static/*',\n+ RED.auth.needsPermission('server.read'),\n+ function(req, res) {\nres.sendFile(req.params[0], HTTP_STATIC_OPTS);\n- });\n+ }\n+ );\nthis.setOnContext('states', []);\nthis.setOnContext('services', []);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get(`${RED.settings.apiCurrentStateAdminPrefix}homeassistant/entities`)\n+ $.get(`homeassistant/entities`)\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -89,12 +89,5 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('api-current-state', CurrentStateNode, {\n- settings: {\n- apiCurrentStateAdminPrefix: {\n- value: RED.settings.httpAdminRoot || '/',\n- exportable: true\n- }\n- }\n- });\n+ RED.nodes.registerType('api-current-state', CurrentStateNode);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "// A home assistant server is selected in the node config\nif (node.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get(`${RED.settings.serverStateChangedAdminPrefix}homeassistant/entities`).done((entities) => {\n+ $.get(`homeassistant/entities`).done((entities) => {\nnode.availableEntities = JSON.parse(entities);\n$entityidfilter.autocomplete({ source: node.availableEntities, minLength: 0 });\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -145,12 +145,5 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('server-state-changed', ServerStateChangedNode, {\n- settings: {\n- serverStateChangedAdminPrefix: {\n- value: RED.settings.httpAdminRoot || '/',\n- exportable: true\n- }\n- }\n- });\n+ RED.nodes.registerType('server-state-changed', ServerStateChangedNode);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get(`${RED.settings.pollStateAdminPrefix}homeassistant/entities`)\n+ $.get(`homeassistant/entities`)\n.done((entities) => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -121,12 +121,5 @@ module.exports = function(RED) {\nreturn state;\n}\n}\n- RED.nodes.registerType('poll-state', TimeSinceStateNode, {\n- settings: {\n- pollStateAdminPrefix: {\n- value: RED.settings.httpAdminRoot || '/',\n- exportable: true\n- }\n- }\n- });\n+ RED.nodes.registerType('poll-state', TimeSinceStateNode);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "// A home assistant server is selected in the node config\nif (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get(`${RED.settings.triggerStateAdminPrefix}homeassistant/entities`).done((entities) => {\n+ $.get(`homeassistant/entities`).done((entities) => {\nNODE.availableEntities = JSON.parse(entities);\n$entityid.autocomplete({ source: NODE.availableEntities, minLength: 0 });\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -388,12 +388,5 @@ module.exports = function(RED) {\n}\n}\n- RED.nodes.registerType('trigger-state', TriggerState, {\n- settings: {\n- triggerStateAdminPrefix: {\n- value: RED.settings.httpAdminRoot || '/',\n- exportable: true\n- }\n- }\n- });\n+ RED.nodes.registerType('trigger-state', TriggerState);\n};\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Add permissions check for the httpAdmin getsFixes #7 |
748,234 | 20.10.2018 21:54:08 | 25,200 | c62ed86b2ca80224109929fee609c7bb0463ea28 | Set service object to the global Home Assistant context on load
Only process state and service object if not empty | [
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -69,7 +69,7 @@ class HaWebsocket extends EventEmitter {\n}\nonClientStates(msg) {\n- if (!msg) {\n+ if (!msg || Object.keys(msg).length === 0) {\nreturn;\n}\n@@ -82,11 +82,16 @@ class HaWebsocket extends EventEmitter {\n}\nonClientServices(msg) {\n- if (!msg) {\n+ if (!msg || Object.keys(msg).length === 0) {\nreturn;\n}\nthis.services = msg;\n+\n+ if (!this.servicesLoaded) {\n+ this.servicesLoaded = true;\n+ this.emit('ha_events:services_loaded', this.services);\n+ }\n}\nonClientEvents(msg) {\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -117,6 +117,10 @@ module.exports = function(RED) {\n'ha_events:states_loaded',\nthis.onHaStatesLoaded.bind(this)\n);\n+ this.websocket.addListener(\n+ 'ha_events:services_loaded',\n+ this.onHaServicesLoaded.bind(this)\n+ );\n}\n}\n@@ -168,6 +172,10 @@ module.exports = function(RED) {\nthis.setOnContext('states', states);\n}\n+ onHaServicesLoaded(services) {\n+ this.setOnContext('services', services);\n+ }\n+\nonHaEventsClose() {\nthis.setOnContext('isConnected', false);\nthis.debug('config server event listener closed');\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Set service object to the global Home Assistant context on load
Only process state and service object if not empty |
748,248 | 30.10.2018 23:08:30 | 18,000 | 42e4a19719f16cd05880b3f34eb617c6a24184be | Added override data control to current-state node
Default should preserve current behavior
- The change allows the node to fully pass-thru the input
message to the output, but preserves the halt ability of the node | [
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "halt_if: { value: '' },\noverride_topic: { value: true },\noverride_payload: { value: true },\n+ override_data: { value: true },\nentity_id: { value: '' },\n},\noneditprepare: function () {\n<span>Override Payload</span>\n</div>\n+ <div class=\"form-row\">\n+ <label for=\"node-input-override_data\"> </label>\n+ <input type=\"checkbox\" id=\"node-input-override_data\" checked style=\"display:inline-block; width:15px; vertical-align:baseline;\"> \n+ <span>Override Data</span>\n+ </div>\n+\n<div class=\"form-row\">\n<label for=\"node-input-halt_if\"><i class=\"fa fa-hand-paper-o\"></i> Halt If</label>\n<input type=\"text\" id=\"node-input-halt_if\" placeholder=\"off\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -9,6 +9,7 @@ module.exports = function(RED) {\nhalt_if: {},\noverride_topic: {},\noverride_payload: {},\n+ override_data: {},\nentity_id: {},\nserver: { isNode: true }\n},\n@@ -74,11 +75,11 @@ module.exports = function(RED) {\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\nconst override_topic = this.nodeConfig.override_topic !== false;\n+ const override_data = this.nodeConfig.override_data !== false;\nif (override_topic) message.topic = entity_id;\nif (override_payload) message.payload = currentState.state;\n-\n- message.data = currentState;\n+ if (override_data) message.data = currentState;\nthis.status({\nfill: 'green',\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added override data control to current-state node (#20)
- Default should preserve current behavior
- The change allows the node to fully pass-thru the input
message to the output, but preserves the halt ability of the node
Signed-off-by: Jason Albert <[email protected]> |
748,234 | 08.11.2018 17:09:26 | 28,800 | 7ac3ae8bae7754226b66f42b76343344885945df | Updated status message for get-history to show timestamp | [
{
"change_type": "MODIFY",
"old_path": "nodes/get-history/get-history.js",
"new_path": "nodes/get-history/get-history.js",
"diff": "@@ -86,7 +86,7 @@ module.exports = function(RED) {\nthis.status({\nfill: 'green',\nshape: 'dot',\n- text: 'Success'\n+ text: `Success at: ${this.getPrettyDate()}`\n});\n})\n.catch(err => {\n@@ -98,7 +98,11 @@ module.exports = function(RED) {\n'Error calling service, home assistant api error',\nmessage\n);\n- this.status({ fill: 'red', shape: 'ring', text: 'Error' });\n+ this.status({\n+ fill: 'red',\n+ shape: 'ring',\n+ text: `Error at: ${this.getPrettyDate()}`\n+ });\n});\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Updated status message for get-history to show timestamp |
748,234 | 11.11.2018 23:11:45 | 28,800 | 5de04e9948b9c00cd1eaf25a6b87934c840619e3 | Added .eslintignore to .npmignore | [
{
"change_type": "MODIFY",
"old_path": ".npmignore",
"new_path": ".npmignore",
"diff": "@@ -2,6 +2,7 @@ coverage/\ntest/\n.vscode\n.eslintrc.js\n+.eslintignore\n.github\n.dockerignore\n.travis.yml\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "-# Node Red Contrib Home Assistant Websocket\n+# node-red-contrib-home-assistant-websocket\n[](https://travis-ci.com/zachowj/node-red-contrib-home-assistant-websocket) [](https://coveralls.io/github/zachowj/node-red-contrib-home-assistant-websocket?branch=master)\n@@ -47,7 +47,7 @@ The installed nodes have more detailed information in the node-red info pane sho\n### All Events - `websocket`\n-Listens for all types of events from home assistant\n+Listens for all types of events from home assistant with the ability to filter by event type\n### State Changed Event - `websocket`\n@@ -55,7 +55,7 @@ Listens for only `state_changed` events from home assistant\n### State Trigger - `websocket`\n-Much like the `State Changed Ndoe` however provides some advanced functionality around common automation use cases.\n+Much like the `State Changed Node` however provides some advanced functionality around common automation use cases.\n### Poll State - `websocket`\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added .eslintignore to .npmignore |
748,234 | 15.11.2018 22:32:48 | 28,800 | df8c0aed870644b0a2926bb6f20add8244fce15a | Don't send message until received result from server for call-service | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.js",
"new_path": "nodes/call-service/call-service.js",
"diff": "@@ -70,10 +70,10 @@ module.exports = function(RED) {\nservice: apiService,\ndata: apiData || null\n};\n- this.send(message);\nreturn this.nodeConfig.server.websocket\n.callService(apiDomain, apiService, apiData)\n+ .then(this.send(message))\n.catch(err => {\nthis.warn(\n'Error calling service, home assistant api error',\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Don't send message until received result from server for call-service |
748,234 | 16.11.2018 16:46:33 | 28,800 | c930340cb6362a362bb48e72ef3f929b0dbda287 | Entity Id in call-service node broken out from data
and has autocomplete enable on it | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "<script type=\"text/javascript\">\n- RED.nodes.registerType('api-call-service', {\n- category: 'home_assistant',\n- color: '#52C0F2',\n+ RED.nodes.registerType(\"api-call-service\", {\n+ category: \"home_assistant\",\n+ color: \"#52C0F2\",\ninputs: 1,\noutputs: 1,\n- icon: 'router-wireless.png',\n- align: 'right',\n- paletteLabel: 'call service',\n- label: function () { return this.name || `svc: ${this.service_domain}:${this.service}`; },\n+ icon: \"router-wireless.png\",\n+ align: \"right\",\n+ paletteLabel: \"call service\",\n+ label: function() {\n+ return this.name || `svc: ${this.service_domain}:${this.service}`;\n+ },\ndefaults: {\n- name: { value: '' },\n- server: { value: '', type: 'server', required: true },\n- service_domain: { value: '' },\n- service: { value: '' },\n+ name: { value: \"\" },\n+ server: { value: \"\", type: \"server\", required: true },\n+ service_domain: { value: \"\" },\n+ service: { value: \"\" },\ndata: {\n- value: '', validate: function (v) {\n+ value: \"\",\n+ validate: function(v) {\n// data isn't required since it could be either not needed or provided via payload\n- if (!v) { return true; }\n- try { JSON.parse(v); return true; }\n- catch (e) { return false; }\n+ if (!v) {\n+ return true;\n+ }\n+ try {\n+ JSON.parse(v);\n+ return true;\n+ } catch (e) {\n+ return false;\n+ }\n}\n},\nmergecontext: { value: null }\n},\noneditprepare: function() {\nconst node = this;\n- const $server = $('#node-input-server');\n-\n- const $domainField = $('#service_domain');\n- const $serviceField = $('#service');\n+ const $server = $(\"#node-input-server\");\n+ const $domainField = $(\"#service_domain\");\n+ const $serviceField = $(\"#service\");\n+ const $entityIdField = $(\"#entity_id\");\n+ const $data = $(\"#node-input-data\");\n- const $serviceDataDiv = $('#service-data-desc');\n- const $serviceDescDiv = $('.service-description', $serviceDataDiv);\n- const $serviceDataTableBody = $('tbody', $serviceDataDiv);\n- const $unknownServiceDiv = $('.unknown-service', $serviceDataDiv);\n- const $knownServiceDiv = $('.known-service', $serviceDataDiv);\n+ const $serviceDataDiv = $(\"#service-data-desc\");\n+ const $serviceDescDiv = $(\".service-description\", $serviceDataDiv);\n+ const $serviceDataTableBody = $(\"tbody\", $serviceDataDiv);\n+ const $unknownServiceDiv = $(\".unknown-service\", $serviceDataDiv);\n+ const $knownServiceDiv = $(\".known-service\", $serviceDataDiv);\n$domainField.val(node.service_domain);\n$serviceField.val(node.service);\n+ $entityIdField.val(node.entity_id);\n+\n+ // Extract entity_id from data and fill in the entity_id input\n+ try {\n+ const data = JSON.parse(node.data);\n+ if (data.entity_id) {\n+ $entityIdField.val(data.entity_id);\n+ delete data.entity_id;\n+ $data.val(!Object.keys(data).length ? \"\" : JSON.stringify(data));\n+ }\n+ } catch (e) {}\n- $('#node-input-data').typedInput({\n- 'types': ['json']\n+ $data.typedInput({\n+ types: [\"json\"]\n});\nconst utils = {\nsetDefaultServerSelection: function() {\nlet defaultServer;\nRED.nodes.eachConfig(n => {\n- if (n.type === 'server' && !defaultServer) defaultServer = n.id;\n+ if (n.type === \"server\" && !defaultServer) defaultServer = n.id;\n});\nif (defaultServer) $server.val(defaultServer);\n}\n// If a server is selected populate dropdowns\nconst selectedServer = $server.val();\n- if (node.server || (selectedServer && selectedServer !== '_ADD_')) {\n+ if (node.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nsetServicesAndDomains(node);\n+ $.get(`homeassistant/entities`)\n+ .done(entities => {\n+ this.availableEntities = JSON.parse(entities);\n+\n+ $entityIdField.autocomplete({\n+ source: this.availableEntities,\n+ minLength: 0\n+ });\n+ })\n+ .fail(err => RED.notify(err.responseText, \"error\"));\n}\n// Calls the custom api backend defined in the config-server.js node\n- // TODO: Not sure how this works with node-red if auth is enabled\nfunction setServicesAndDomains(node) {\n-\nreturn $.get(`homeassistant/services`)\n.then(services => {\nnode.allServices = JSON.parse(services);\nnode.allDomains = Object.keys(node.allServices);\n- $domainField.autocomplete({\n+ $domainField\n+ .autocomplete({\nsource: node.allDomains,\ncreate: (evt, ui) => updateDomainSelection({ event: evt }),\nchange: (evt, ui) => updateDomainSelection({ event: evt }),\nselect: (evt, ui) => updateDomainSelection({ event: evt }),\nminLength: 0\n- }).focus(function () {\n- $domainField.autocomplete('search');\n+ })\n+ .focus(function() {\n+ $domainField.autocomplete(\"search\");\n});\n- updateDomainSelection({ domainText: node.service_domain || '' });\n- updateServiceSelection({ serviceText: node.service || '' });\n+ updateDomainSelection({ domainText: node.service_domain || \"\" });\n+ updateServiceSelection({ serviceText: node.service || \"\" });\nreturn node;\n})\n- .fail((err) => RED.notify(err.responseText, 'error'));\n-\n+ .fail(err => RED.notify(err.responseText, \"error\"));\n}\n-\nfunction updateServiceSelection({ event, serviceText }) {\nlet selectedServiceText = serviceText;\nif (!selectedServiceText && event) {\n// If a value selected\nif (selectedServiceText) {\n-\n- node.selectedService = node.selectedDomain.services[selectedServiceText];\n+ node.selectedService =\n+ node.selectedDomain.services[selectedServiceText];\n// If a known service\nif (node.selectedService) {\n- const serviceDesc = node.selectedService.description ?\n- node.selectedService.description : 'No description provided by home assistant';\n+ const serviceDesc = node.selectedService.description\n+ ? node.selectedService.description\n+ : \"No description provided by home assistant\";\nconst fields = node.selectedService.fields;\nlet tableRows = Object.keys(fields).reduce((tRows, k) => {\nconst fieldData = fields[k];\n- if (!fieldData.description && !fieldData.example) { return; }\n- tRows.push(`\n- <tr>\n- <td><code>${k}</code></td>\n- <td>${fields[k].description || ''}</td>\n- <td>${fields[k].example || ''}</td>\n- </tr>`\n+ if (!fieldData.description && !fieldData.example) {\n+ return;\n+ }\n+ tRows.push(\n+ `<tr><td><code>${k}</code></td><td>${fields[k].description ||\n+ \"\"}</td><td>${fields[k].example || \"\"}</td></tr>`\n);\nreturn tRows;\n}, []);\n-\n- tableRows = (tableRows.length > 0)\n- ? tableRows.join('')\n- : '';\n+ tableRows = tableRows.length > 0 ? tableRows.join(\"\") : \"\";\n// Add table and description for service and service fields\n$serviceDescDiv.html(serviceDesc);\n- $('#service-data-desc .title').html(node.selectedDomain.name + '.' + selectedServiceText)\n+ $(\"#service-data-desc .title\").html(\n+ node.selectedDomain.name + \".\" + selectedServiceText\n+ );\nif (tableRows) {\n$(\"#service-data-table\").show();\n$serviceDataTableBody.html(tableRows);\n} else {\n$(\"#service-data-table\").hide();\n- $serviceDescDiv.append('<p>No fields documented by home-assistant<p>');\n+ $serviceDescDiv.append(\n+ \"<p>No fields documented by home-assistant<p>\"\n+ );\n}\n$unknownServiceDiv.hide();\n$knownServiceDiv.show();\n// Hide service data fields and desc\n$unknownServiceDiv.show();\n$knownServiceDiv.hide();\n- $('#service-data-desc .title').val('');\n+ $(\"#service-data-desc .title\").val(\"\");\n}\n} else {\n// Hide service data fields and desc\n$unknownServiceDiv.show();\n$knownServiceDiv.hide();\n- $('#service-data-desc .title').val('');\n+ $(\"#service-data-desc .title\").val(\"\");\n}\n}\nfunction updateDomainSelection({ event, domainText }) {\nlet selectedDomainText = domainText;\n- if (!selectedDomainText && event) { selectedDomainText = $(event.target).val(); }\n+ if (!selectedDomainText && event) {\n+ selectedDomainText = $(event.target).val();\n+ }\n- const knownDomain = (node.allDomains.indexOf(selectedDomainText) > -1);\n+ const knownDomain = node.allDomains.indexOf(selectedDomainText) > -1;\nnode.selectedDomain = knownDomain\n- ? { services: node.allServices[selectedDomainText], name: selectedDomainText }\n- : node.selectedDomain = { services: {} };\n+ ? {\n+ services: node.allServices[selectedDomainText],\n+ name: selectedDomainText\n+ }\n+ : (node.selectedDomain = { services: {} });\n- $serviceField.autocomplete({\n+ $serviceField\n+ .autocomplete({\nsource: Object.keys(node.selectedDomain.services),\ncreate: (evt, ui) => updateServiceSelection({ event: evt }),\nchange: (evt, ui) => updateServiceSelection({ event: evt }),\nminLength: 0\n})\n.focus(function() {\n- $serviceField.autocomplete('search');\n+ $serviceField.autocomplete(\"search\");\n});\n}\n},\noneditsave: function() {\n+ const entityId = $(\"#entity_id\").val();\n+\nthis.service_domain = $(\"#service_domain\").val();\nthis.service = $(\"#service\").val();\n+\n+ // Insert entity id into data object\n+ if (entityId.length) {\n+ const $nodeInputData = $(\"#node-input-data\");\n+ const dataString = $nodeInputData.val() || \"{}\";\n+\n+ try {\n+ const data = JSON.parse(dataString);\n+ const mergedData = Object.assign({ entity_id: entityId }, data);\n+ $nodeInputData.val(JSON.stringify(mergedData));\n+ } catch (e) {\n+ RED.notify(\"Error merging Entity Id into data.\", \"error\");\n+ }\n+ }\n}\n});\n</script>\n-\n<script type=\"text/x-red\" data-template-name=\"api-call-service\">\n<div class=\"form-row\">\n<label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n<input type=\"text\" id=\"service\">\n</div>\n+ <div class=\"form-row\">\n+ <label for=\"entity_id\"><i class=\"fa fa-cube\"></i> Entity Id</label>\n+ <input type=\"text\" id=\"entity_id\">\n+ </div>\n+\n<div class=\"form-row\">\n<label for=\"node-input-data\"><i class=\"fa fa-dot-circle-o\"></i> Data</label>\n- <input type=\"text\" id=\"node-input-data\" placeholder=\"{ "entity_id": "light.livingroom" }\"/>\n+ <input type=\"text\" id=\"node-input-data\" />\n</div>\n<div class=\"form-row\">\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Entity Id in call-service node broken out from data
and has autocomplete enable on it |
748,234 | 17.11.2018 01:35:24 | 28,800 | fa93052bf65ef47f10ce56baceff64329754a621 | Added substring/exact/regex to trigger node entity filter | [
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "-<script type=\"text/x-red\" data-template-name=\"trigger-state\">\n- <!-- Name -->\n- <div class=\"form-row\">\n- <label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n- <input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n- </div>\n-\n- <!-- Server -->\n- <div class=\"form-row\">\n- <label for=\"node-input-server\"><i class=\"fa fa-server\"></i> Server</label>\n- <input type=\"text\" id=\"node-input-server\" />\n- </div>\n-\n- <!-- Entity ID Filter and Filter Type -->\n- <div class=\"form-row\">\n- <label for=\"node-input-entityid\"><i class=\"fa fa-tag\"></i> Entity ID</label>\n- <input type=\"text\" id=\"node-input-entityid\" placeholder=\"binary_sensor\" style=\"width: 70%;\" />\n- </div>\n-\n- <div class=\"form-row\">\n- <input type=\"checkbox\" id=\"node-input-outputinitially\" style=\"display: inline-block; width: auto; vertical-align: top;\">\n- <label for=\"node-input-outputinitially\" style=\"width: auto;\">Output Initially / On Deploy</label>\n- </div>\n-\n- <!-- -------------------------------------------------------------- -->\n- <!-- Add Custom Constraints -->\n- <!-- -------------------------------------------------------------- -->\n- <div class=\"form-row\" id=\"add-constraint-container\">\n- <h3>Add Constraints</h3>\n- <div>\n- <!-- Target Selection -->\n- <div class=\"form-row\">\n- <!-- Type -->\n- <select type=\"text\" id=\"constraint-target-type\" style=\"width: 140px;\">\n- <option value=\"this_entity\">This Entity</option>\n- <option value=\"entity_id\">Entity ID</option>\n- </select>\n-\n- <!-- Value -->\n- <input type=\"text\" id=\"constraint-target-value\" style=\"width: 62%\" disabled />\n- </div>\n-\n- <!-- Property Selection -->\n- <div class=\"form-row\">\n- <!-- Type -->\n- <select type=\"text\" id=\"constraint-property-type\" style=\"width: 140px;\">\n- <option value=\"current_state\">Current State</option>\n- <option value=\"previous_state\">Previous State</option>\n- <option value=\"property\">Property</option>\n- </select>\n-\n- <!-- Value -->\n- <input type=\"text\" id=\"constraint-property-value\" style=\"width: 62%\" disabled />\n- </div>\n-\n-\n- <!-- Comparator Selection -->\n- <div class=\"form-row\">\n- <!-- Type -->\n- <select type=\"text\" id=\"constraint-comparator-type\" style=\"width: 140px;\">\n- <option value=\"is\">Is</option>\n- <option value=\"is_not\">Is Not</option>\n-\n- <option value=\">\">></option>\n- <option value=\">=\">>=</option>\n- <option value=\"<\"><</option>\n- <option value=\"<=\"><=</option>\n-\n- <option value=\"includes\">Includes</option>\n- <option value=\"does_not_include\">Does Not Include</option>\n- </select>\n-\n- <!-- Value -->\n- <input type=\"text\" id=\"constraint-comparator-value\" />\n- </div>\n-\n- <!-- Add Constraint Button -->\n- <button id=\"constraint-add-btn\" style=\"width: 100%\">Add Constraint</button>\n- </div>\n- </div>\n-\n- <!-- Constraints List -->\n- <div class=\"form-row\">\n- <ol id=\"constraint-list\"></ol>\n- </div>\n-\n- <!-- -------------------------------------------------------------- -->\n- <!-- Add Custom Outputs -->\n- <!-- -------------------------------------------------------------- -->\n- <div class=\"form-row\" id=\"add-output-container\">\n- <h3>Add Outputs</h3>\n- <div>\n- <div class=\"form-row\">\n- <!-- Type -->\n- <select type=\"text\" id=\"output-message-type\" style=\"width: 140px;\">\n- <option value=\"default\"> Default Msg </option>\n- <option value=\"custom\"> Custom Msg </option>\n- </select>\n-\n- <input type=\"text\" id=\"output-message-value\" style=\"width: 62%\" disabled/>\n- </div>\n-\n-\n- <!-- Output Comparator Selection -->\n- <div class=\"form-row\">\n- <select type=\"text\" id=\"output-comparator-property-type\" style=\"width: 140px\">\n- <option value=\"always\"> Send Always </option>\n- <option value=\"current_state\"> If State </option>\n- <option value=\"previous_state\"> If Prev State </option>\n- <option value=\"property\"> If Property </option>\n- </select>\n-\n- <input type=\"text\" id=\"output-comparator-property-value\" style=\"width: 62%\" disabled />\n- </div>\n-\n- <div class=\"form-row\">\n- <!-- Type -->\n- <select type=\"text\" id=\"output-comparator-type\" style=\"width: 140px;\" disabled>\n- <option value=\"is\"> Is </option>\n- <option value=\"is_not\"> Is Not </option>\n-\n- <option value=\">\">></option>\n- <option value=\">=\">>=</option>\n- <option value=\"<\"><</option>\n- <option value=\"<=\"><=</option>\n-\n- <option value=\"includes\">Includes</option>\n- <option value=\"does_not_include\">Does Not Include</option>\n- </select>\n-\n- <input type=\"text\" id=\"output-comparator-value\" style=\"width: 62%\" disabled />\n- </div>\n-\n- <!-- Add Output Button -->\n- <button id=\"output-add-btn\" style=\"width: 100%\">Add Output</button>\n- </div>\n- </div>\n-\n- <!-- Output List -->\n- <div class=\"form-row\">\n- <ol id=\"output-list\"></ol>\n- </div>\n-\n- <div class=\"form-row\">\n- <label for=\"node-input-debugenabled\"><i class=\"fa fa-server\"></i> Debug</label>\n- <input type=\"checkbox\" id=\"node-input-debugenabled\" />\n- </div>\n-\n-</script>\n-\n-\n<script type=\"text/javascript\">\n- RED.nodes.registerType('trigger-state', {\n- category: 'home_assistant',\n- color: '#038FC7',\n+ RED.nodes.registerType(\"trigger-state\", {\n+ category: \"home_assistant\",\n+ color: \"#038FC7\",\ndefaults: {\n- name: { value: '' },\n- server: { value: '', type: 'server', required: true },\n- entityid: { value: '', required: true },\n+ name: { value: \"\" },\n+ server: { value: \"\", type: \"server\", required: true },\n+ entityid: { value: \"\", required: true },\n+ entityidfiltertype: { value: \"exact\" },\ndebugenabled: { value: false },\nconstraints: { value: [] },\n- constraintsmustmatch: { value: 'all' },\n+ constraintsmustmatch: { value: \"all\" },\noutputs: { value: 2 },\ncustomoutputs: { value: [] },\noutputinitially: { value: false }\noutputLabels: function(index) {\nconst NUM_DEFAULT_OUTPUTS = 2;\n- if (index === 0) return 'allowed';\n- if (index === 1) return 'blocked';\n+ if (index === 0) return \"allowed\";\n+ if (index === 1) return \"blocked\";\n// Get custom output by length minus default outputs\nconst co = this.customoutputs[index - NUM_DEFAULT_OUTPUTS];\nlet label;\n- if (co.comparatorPropertyType === 'always') {\n- label = 'always sent'\n+ if (co.comparatorPropertyType === \"always\") {\n+ label = \"always sent\";\n} else {\n- label = `${co.comparatorPropertyType.replace('_', ' ')} ${co.comparatorType.replace('_', '')} ${co.comparatorValue}`;\n+ label = `${co.comparatorPropertyType.replace(\n+ \"_\",\n+ \" \"\n+ )} ${co.comparatorType.replace(\"_\", \"\")} ${co.comparatorValue}`;\n}\nreturn label;\n},\nicon: \"trigger.png\",\n- paletteLabel: 'trigger: state',\n- label: function () { return this.name || `trigger-state: ${this.entityid}` },\n+ paletteLabel: \"trigger: state\",\n+ label: function() {\n+ return this.name || `trigger-state: ${this.entityid}`;\n+ },\noneditprepare: function() {\n// Outputs List\nlet NODE = this;\nconst NUM_DEFAULT_OUTPUTS = 2;\n- const $entityid = $('#node-input-entityid');\n- const $server = $('#node-input-server');\n- const $outputs = $('#node-input-outputs');\n- const $accordionContraint = $('#add-constraint-container');\n- const $accordionOutput = $('#add-output-container');\n+ const $entityid = $(\"#node-input-entityid\");\n+ const $entityidfiltertype = $(\"#node-input-entityidfiltertype\");\n+ const $server = $(\"#node-input-server\");\n+ const $outputs = $(\"#node-input-outputs\");\n+ const $accordionContraint = $(\"#add-constraint-container\");\n+ const $accordionOutput = $(\"#add-output-container\");\n+\n+ this.entityidfiltertype = this.entityidfiltertype || \"exact\";\n+ $entityidfiltertype.val(this.entityidfiltertype);\nconst $constraints = {\n- list: $('#constraint-list'),\n- addBtn: $('#constraint-add-btn'),\n-\n- targetType: $('#constraint-target-type'),\n- targetValue: $('#constraint-target-value'),\n- propertyType: $('#constraint-property-type'),\n- propertyValue: $('#constraint-property-value'),\n- comparatorType: $('#constraint-comparator-type'),\n- comparatorValue: $('#constraint-comparator-value')\n+ list: $(\"#constraint-list\"),\n+ addBtn: $(\"#constraint-add-btn\"),\n+\n+ targetType: $(\"#constraint-target-type\"),\n+ targetValue: $(\"#constraint-target-value\"),\n+ propertyType: $(\"#constraint-property-type\"),\n+ propertyValue: $(\"#constraint-property-value\"),\n+ comparatorType: $(\"#constraint-comparator-type\"),\n+ comparatorValue: $(\"#constraint-comparator-value\")\n};\nconst $customoutputs = {\n- list: $('#output-list'),\n- addBtn: $('#output-add-btn'),\n+ list: $(\"#output-list\"),\n+ addBtn: $(\"#output-add-btn\"),\n- messageType: $('#output-message-type'),\n- messageValue: $('#output-message-value'),\n+ messageType: $(\"#output-message-type\"),\n+ messageValue: $(\"#output-message-value\"),\n- comparatorPropertyType: $('#output-comparator-property-type'),\n- comparatorPropertyValue: $('#output-comparator-property-value'),\n- comparatorType: $('#output-comparator-type'),\n- comparatorValue: $('#output-comparator-value')\n+ comparatorPropertyType: $(\"#output-comparator-property-type\"),\n+ comparatorPropertyValue: $(\"#output-comparator-property-value\"),\n+ comparatorType: $(\"#output-comparator-type\"),\n+ comparatorValue: $(\"#output-comparator-value\")\n};\nconst utils = {\n- getRandomId: () => Math.random().toString(36).slice(2),\n+ getRandomId: () =>\n+ Math.random()\n+ .toString(36)\n+ .slice(2),\nsetupAutocomplete: () => {\nconst selectedServer = $server.val();\n// A home assistant server is selected in the node config\n- if (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n- $.get(`homeassistant/entities`).done((entities) => {\n+ if (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n+ $.get(`homeassistant/entities`)\n+ .done(entities => {\nNODE.availableEntities = JSON.parse(entities);\n- $entityid.autocomplete({ source: NODE.availableEntities, minLength: 0 });\n+ $entityid.autocomplete({\n+ source: NODE.availableEntities,\n+ minLength: 0\n+ });\n})\n- .fail((err) => RED.notify(err.responseText, 'error'));\n+ .fail(err => RED.notify(err.responseText, \"error\"));\n}\n},\nsetDefaultServerSelection: function() {\nlet defaultServer;\nRED.nodes.eachConfig(n => {\n- if (n.type === 'server' && !defaultServer) defaultServer = n.id;\n+ if (n.type === \"server\" && !defaultServer) defaultServer = n.id;\n});\nif (defaultServer) $server.val(defaultServer);\n}\nconst constraintsHandler = {\nonTargetTypeChange: function(e) {\nconst val = e.target.value;\n- (val === 'this_entity')\n- ? $constraints.targetValue.attr('disabled', 'disabled')\n- : $constraints.targetValue.removeAttr('disabled')\n+ val === \"this_entity\"\n+ ? $constraints.targetValue.attr(\"disabled\", \"disabled\")\n+ : $constraints.targetValue.removeAttr(\"disabled\");\n},\nonPropertyTypeChange: function(e) {\nconst val = e.target.value;\n- (val === 'current_state' || val === 'previous_state')\n- ? $constraints.propertyValue.attr('disabled', 'disabled')\n- : $constraints.propertyValue.removeAttr('disabled');\n+ val === \"current_state\" || val === \"previous_state\"\n+ ? $constraints.propertyValue.attr(\"disabled\", \"disabled\")\n+ : $constraints.propertyValue.removeAttr(\"disabled\");\n},\nonComparatorTypeChange: function(e) {\nconst val = e.target.value; // Placeholder\npropertyType: $constraints.propertyType.val(),\npropertyValue: $constraints.propertyValue.val(),\ncomparatorType: $constraints.comparatorType.val(),\n- comparatorValueDatatype: $constraints.comparatorValue.typedInput('type'),\n- comparatorValue: $constraints.comparatorValue.typedInput('value')\n+ comparatorValueDatatype: $constraints.comparatorValue.typedInput(\n+ \"type\"\n+ ),\n+ comparatorValue: $constraints.comparatorValue.typedInput(\"value\")\n};\n- if (constraint.propertyType === 'current_state') constraint.propertyValue = 'new_state.state';\n- if (constraint.propertyType === 'previous_state') constraint.propertyValue = 'old_state.state';\n+ if (constraint.propertyType === \"current_state\")\n+ constraint.propertyValue = \"new_state.state\";\n+ if (constraint.propertyType === \"previous_state\")\n+ constraint.propertyValue = \"old_state.state\";\n- if (constraint.comparatorType === 'includes' || constraint.comparatorType === 'does_not_include') {\n- constraint.comparatorValueDatatype = 'list';\n+ if (\n+ constraint.comparatorType === \"includes\" ||\n+ constraint.comparatorType === \"does_not_include\"\n+ ) {\n+ constraint.comparatorValueDatatype = \"list\";\n}\n- $constraints.list.editableList('addItem', constraint);\n- $constraints.targetValue.val('');\n+ $constraints.list.editableList(\"addItem\", constraint);\n+ $constraints.targetValue.val(\"\");\n},\nonEditableListAdd: function(row, index, data) {\nconst $row = $(row);\n- const { targetType, targetValue, propertyType, propertyValue, comparatorType, comparatorValue, comparatorValueDatatype } = data;\n-\n- const entityText = (targetType === 'this_entity') ? '<strong>This entities</strong>' : `Entity ID <strong>${targetValue}</strong>`;\n- const propertyText = (propertyType === 'property') ? propertyValue : propertyType.replace('_', ' ');\n-\n- const comparatorTypeText = comparatorType.replace('_', ' ');\n+ const {\n+ targetType,\n+ targetValue,\n+ propertyType,\n+ propertyValue,\n+ comparatorType,\n+ comparatorValue,\n+ comparatorValueDatatype\n+ } = data;\n+\n+ const entityText =\n+ targetType === \"this_entity\"\n+ ? \"<strong>This entities</strong>\"\n+ : `Entity ID <strong>${targetValue}</strong>`;\n+ const propertyText =\n+ propertyType === \"property\"\n+ ? propertyValue\n+ : propertyType.replace(\"_\", \" \");\n+\n+ const comparatorTypeText = comparatorType.replace(\"_\", \" \");\nconst comparatorText = `${comparatorTypeText} <strong>${comparatorValue}</strong> (${comparatorValueDatatype})`;\nconst rowHtml = `${entityText} ${propertyText} ${comparatorText}`;\n};\n// Constraint select menu change handlers\n- $constraints.targetType.on('change', constraintsHandler.onTargetTypeChange);\n- $constraints.propertyType.on('change', constraintsHandler.onPropertyTypeChange);\n- $constraints.comparatorType.on('change', constraintsHandler.onComparatorTypeChange);\n-\n- $constraints.addBtn.on('click', constraintsHandler.onAddConstraintButton);\n+ $constraints.targetType.on(\n+ \"change\",\n+ constraintsHandler.onTargetTypeChange\n+ );\n+ $constraints.propertyType.on(\n+ \"change\",\n+ constraintsHandler.onPropertyTypeChange\n+ );\n+ $constraints.comparatorType.on(\n+ \"change\",\n+ constraintsHandler.onComparatorTypeChange\n+ );\n+\n+ $constraints.addBtn.on(\"click\", constraintsHandler.onAddConstraintButton);\n// Constraints List\n$constraints.list.editableList({\n});\n$constraints.comparatorValue.typedInput({\n- default: 'str',\n- types: ['str', 'num', 'bool', 're']\n+ default: \"str\",\n+ types: [\"str\", \"num\", \"bool\", \"re\"]\n});\n- $constraints.comparatorValue.typedInput('width', '100px');\n+ $constraints.comparatorValue.typedInput(\"width\", \"233px\");\n// **************************\n// * Add Custom Outputs\n} else {\nNODE.outputs = parseInt(NODE.outputs) + 1;\n}\n- $outputs.val(isNaN(NODE.outputs) ? JSON.stringify(NODE.outputs) : NODE.outputs);\n+ $outputs.val(\n+ isNaN(NODE.outputs) ? JSON.stringify(NODE.outputs) : NODE.outputs\n+ );\n- if (output.comparatorPropertyType === 'current_state') output.comparatorPropertyValue = 'new_state.state';\n- if (output.comparatorPropertyType === 'previous_state') output.comparatorPropertyValue = 'old_state.state';\n+ if (output.comparatorPropertyType === \"current_state\")\n+ output.comparatorPropertyValue = \"new_state.state\";\n+ if (output.comparatorPropertyType === \"previous_state\")\n+ output.comparatorPropertyValue = \"old_state.state\";\nNODE.customoutputs.push(output);\n- $customoutputs.list.editableList('addItem', output);\n+ $customoutputs.list.editableList(\"addItem\", output);\n},\nonEditableListAdd: function(row, index, d) {\nconst $row = $(row);\n- const messageText = (d.messageType === 'default')\n- ? 'default message'\n- : d.messageValue;\n+ const messageText =\n+ d.messageType === \"default\" ? \"default message\" : d.messageValue;\n- const sendWhenText = (d.comparatorPropertyType === 'always')\n- ? 'always'\n- : `${d.comparatorPropertyValue} ${d.comparatorType.replace('_', '')} ${d.comparatorValue}`\n+ const sendWhenText =\n+ d.comparatorPropertyType === \"always\"\n+ ? \"always\"\n+ : `${d.comparatorPropertyValue} ${d.comparatorType.replace(\n+ \"_\",\n+ \"\"\n+ )} ${d.comparatorValue}`;\nconst html = `Send <strong>${messageText}</strong>, if <strong>${sendWhenText}</strong>`;\n// links between nodes. If new index is -1 then it was removed\nlet customOutputRemovedIndex = NODE.customoutputs.indexOf(data);\n- NODE.outputs = !(isNaN(NODE.outputs)) ? { 0: 0, 1: 1 } : NODE.outputs;\n+ NODE.outputs = !isNaN(NODE.outputs) ? { 0: 0, 1: 1 } : NODE.outputs;\nNODE.outputs[customOutputRemovedIndex + NUM_DEFAULT_OUTPUTS] = -1;\nNODE.customoutputs.forEach((o, customOutputIndex) => {\nconst customAllIndex = customOutputIndex + NUM_DEFAULT_OUTPUTS;\n- const outputIsBeforeRemoval = (customOutputIndex < customOutputRemovedIndex);\n- const customOutputAlreadyMapped = NODE.outputs.hasOwnProperty(customAllIndex);\n+ const outputIsBeforeRemoval =\n+ customOutputIndex < customOutputRemovedIndex;\n+ const customOutputAlreadyMapped = NODE.outputs.hasOwnProperty(\n+ customAllIndex\n+ );\n// If we're on removed output\nif (customOutputIndex === customOutputRemovedIndex) return;\n// output already removed\n- if (customOutputAlreadyMapped && NODE.outputs[customAllIndex] === -1) return;\n+ if (\n+ customOutputAlreadyMapped &&\n+ NODE.outputs[customAllIndex] === -1\n+ )\n+ return;\n// output previously removed caused this output to be remapped\nif (customOutputAlreadyMapped) {\n- NODE.outputs[customAllIndex] = (outputIsBeforeRemoval)\n+ NODE.outputs[customAllIndex] = outputIsBeforeRemoval\n? NODE.outputs[customAllIndex]\n: NODE.outputs[customAllIndex] - 1;\nreturn;\n}\n// output exists after removal and hasn't been mapped, remap to current index - 1\n- NODE.outputs[customAllIndex] = (outputIsBeforeRemoval)\n+ NODE.outputs[customAllIndex] = outputIsBeforeRemoval\n? customAllIndex\n: customAllIndex - 1;\n});\n},\nonMessageTypeChange: function(e) {\nconst val = e.target.value;\n- (val === 'default')\n- ? $customoutputs.messageValue.attr('disabled', 'disabled')\n- : $customoutputs.messageValue.removeAttr('disabled');\n+ val === \"default\"\n+ ? $customoutputs.messageValue.attr(\"disabled\", \"disabled\")\n+ : $customoutputs.messageValue.removeAttr(\"disabled\");\n},\ncomparatorPropertyTypeChange: function(e) {\nconst val = e.target.value;\n- if (val === 'always') {\n- $customoutputs.comparatorPropertyValue.attr('disabled', 'disabled');\n- $customoutputs.comparatorType.attr('disabled', 'disabled');\n- $customoutputs.comparatorValue.attr('disabled', 'disabled');\n- }\n- if (val === 'previous_state' || val === 'current_state') {\n- $customoutputs.comparatorPropertyValue.attr('disabled', 'disabled');\n- $customoutputs.comparatorType.removeAttr('disabled');\n- $customoutputs.comparatorValue.removeAttr('disabled');\n+ if (val === \"always\") {\n+ $customoutputs.comparatorPropertyValue.attr(\"disabled\", \"disabled\");\n+ $customoutputs.comparatorType.attr(\"disabled\", \"disabled\");\n+ $customoutputs.comparatorValue.attr(\"disabled\", \"disabled\");\n}\n- if (val === 'property') {\n- $customoutputs.comparatorPropertyValue.removeAttr('disabled');\n- $customoutputs.comparatorType.removeAttr('disabled');\n- $customoutputs.comparatorValue.removeAttr('disabled');\n+ if (val === \"previous_state\" || val === \"current_state\") {\n+ $customoutputs.comparatorPropertyValue.attr(\"disabled\", \"disabled\");\n+ $customoutputs.comparatorType.removeAttr(\"disabled\");\n+ $customoutputs.comparatorValue.removeAttr(\"disabled\");\n}\n+ if (val === \"property\") {\n+ $customoutputs.comparatorPropertyValue.removeAttr(\"disabled\");\n+ $customoutputs.comparatorType.removeAttr(\"disabled\");\n+ $customoutputs.comparatorValue.removeAttr(\"disabled\");\n}\n}\n+ };\n$customoutputs.list.editableList({\naddButton: false,\n});\n// Constraint select menu change handlers\n- $customoutputs.messageType.on('change', outputsHandler.onMessageTypeChange);\n- $customoutputs.comparatorPropertyType.on('change', outputsHandler.comparatorPropertyTypeChange);\n+ $customoutputs.messageType.on(\n+ \"change\",\n+ outputsHandler.onMessageTypeChange\n+ );\n+ $customoutputs.comparatorPropertyType.on(\n+ \"change\",\n+ outputsHandler.comparatorPropertyTypeChange\n+ );\n- $customoutputs.addBtn.on('click', outputsHandler.onAddButtonClicked);\n+ $customoutputs.addBtn.on(\"click\", outputsHandler.onAddButtonClicked);\n// **************************\n// * General Init\n// **************************\n- $accordionContraint.accordion({ active: true, collapsible: true, heightStyle: 'content' });\n- $accordionOutput.accordion({ active: false, collapsible: true, heightStyle: 'content' });\n+ $accordionContraint.accordion({\n+ active: true,\n+ collapsible: true,\n+ heightStyle: \"content\"\n+ });\n+ $accordionOutput.accordion({\n+ active: false,\n+ collapsible: true,\n+ heightStyle: \"content\"\n+ });\n$entityid.val(NODE.entityid);\n$server.change(() => utils.setupAutocomplete(this));\n}\n// Add previous constraints/outputs to editable lists\n- NODE.constraints.forEach(c => $constraints.list.editableList('addItem', c));\n- NODE.customoutputs.forEach(o => $customoutputs.list.editableList('addItem', o));\n+ NODE.constraints.forEach(c =>\n+ $constraints.list.editableList(\"addItem\", c)\n+ );\n+ NODE.customoutputs.forEach(o =>\n+ $customoutputs.list.editableList(\"addItem\", o)\n+ );\n},\noneditsave: function() {\n- const $constraintsList = $('#constraint-list');\n- const $outputList = $('#output-list');\n- const $entityid = $('#node-input-entityid');\n+ const $constraintsList = $(\"#constraint-list\");\n+ const $outputList = $(\"#output-list\");\n+ const $entityid = $(\"#node-input-entityid\");\nthis.entityid = $entityid.val();\n// Compile Constraints\nconst nodeConstraints = [];\n- const listConstraints = $constraintsList.editableList('items');\n- listConstraints.each(function (i) { nodeConstraints.push($(this).data('data')); });\n+ const listConstraints = $constraintsList.editableList(\"items\");\n+ listConstraints.each(function(i) {\n+ nodeConstraints.push($(this).data(\"data\"));\n+ });\nthis.constraints = nodeConstraints;\n// Compile Outputs\nconst nodeOutputs = [];\n- const listOutputs = $outputList.editableList('items');\n- listOutputs.each(function (i) { nodeOutputs.push($(this).data('data')); });\n+ const listOutputs = $outputList.editableList(\"items\");\n+ listOutputs.each(function(i) {\n+ nodeOutputs.push($(this).data(\"data\"));\n+ });\nthis.customoutputs = nodeOutputs;\nthis.outputs = this.customoutputs.length + 2;\n});\n</script>\n+<script type=\"text/x-red\" data-template-name=\"trigger-state\">\n+ <!-- Name -->\n+ <div class=\"form-row\">\n+ <label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n+ <input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n+ </div>\n+\n+ <!-- Server -->\n+ <div class=\"form-row\">\n+ <label for=\"node-input-server\"><i class=\"fa fa-server\"></i> Server</label>\n+ <input type=\"text\" id=\"node-input-server\" />\n+ </div>\n+\n+ <!-- Entity ID Filter and Filter Type -->\n+ <div class=\"form-row\">\n+ <label for=\"node-input-entityid\"><i class=\"fa fa-tag\"></i> Entity ID</label>\n+ <input type=\"text\" id=\"node-input-entityid\" placeholder=\"binary_sensor\" style=\"width: 50%;\" />\n+ <select type=\"text\" id=\"node-input-entityidfiltertype\" style=\"width: 20%;\">\n+ <option value=\"exact\">Exact</option>\n+ <option value=\"substring\">Substring</option>\n+ <option value=\"regex\">Regex</option>\n+ </select>\n+ </div>\n+\n+ <!-- -------------------------------------------------------------- -->\n+ <!-- Add Custom Constraints -->\n+ <!-- -------------------------------------------------------------- -->\n+ <div class=\"form-row\" id=\"add-constraint-container\">\n+ <h3>Add Constraints</h3>\n+ <div>\n+ <!-- Target Selection -->\n+ <div class=\"form-row\">\n+ <!-- Type -->\n+ <select type=\"text\" id=\"constraint-target-type\" style=\"width: 140px;\">\n+ <option value=\"this_entity\">This Entity</option>\n+ <option value=\"entity_id\">Entity ID</option>\n+ </select>\n+\n+ <!-- Value -->\n+ <input type=\"text\" id=\"constraint-target-value\" style=\"width: 62%\" disabled />\n+ </div>\n+\n+ <!-- Property Selection -->\n+ <div class=\"form-row\">\n+ <!-- Type -->\n+ <select type=\"text\" id=\"constraint-property-type\" style=\"width: 140px;\">\n+ <option value=\"current_state\">Current State</option>\n+ <option value=\"previous_state\">Previous State</option>\n+ <option value=\"property\">Property</option>\n+ </select>\n+\n+ <!-- Value -->\n+ <input type=\"text\" id=\"constraint-property-value\" style=\"width: 62%\" disabled />\n+ </div>\n+\n+\n+ <!-- Comparator Selection -->\n+ <div class=\"form-row\">\n+ <!-- Type -->\n+ <select type=\"text\" id=\"constraint-comparator-type\" style=\"width: 140px;\">\n+ <option value=\"is\">Is</option>\n+ <option value=\"is_not\">Is Not</option>\n+\n+ <option value=\">\">></option>\n+ <option value=\">=\">>=</option>\n+ <option value=\"<\"><</option>\n+ <option value=\"<=\"><=</option>\n+\n+ <option value=\"includes\">Includes</option>\n+ <option value=\"does_not_include\">Does Not Include</option>\n+ </select>\n+\n+ <!-- Value -->\n+ <input type=\"text\" id=\"constraint-comparator-value\" />\n+ </div>\n+\n+ <!-- Add Constraint Button -->\n+ <button id=\"constraint-add-btn\" style=\"width: 100%\">Add Constraint</button>\n+ </div>\n+ </div>\n+\n+ <!-- Constraints List -->\n+ <div class=\"form-row\">\n+ <ol id=\"constraint-list\"></ol>\n+ </div>\n+\n+ <!-- -------------------------------------------------------------- -->\n+ <!-- Add Custom Outputs -->\n+ <!-- -------------------------------------------------------------- -->\n+ <div class=\"form-row\" id=\"add-output-container\">\n+ <h3>Add Outputs</h3>\n+ <div>\n+ <div class=\"form-row\">\n+ <!-- Type -->\n+ <select type=\"text\" id=\"output-message-type\" style=\"width: 140px;\">\n+ <option value=\"default\"> Default Msg </option>\n+ <option value=\"custom\"> Custom Msg </option>\n+ </select>\n+\n+ <input type=\"text\" id=\"output-message-value\" style=\"width: 62%\" disabled/>\n+ </div>\n+\n+\n+ <!-- Output Comparator Selection -->\n+ <div class=\"form-row\">\n+ <select type=\"text\" id=\"output-comparator-property-type\" style=\"width: 140px\">\n+ <option value=\"always\"> Send Always </option>\n+ <option value=\"current_state\"> If State </option>\n+ <option value=\"previous_state\"> If Prev State </option>\n+ <option value=\"property\"> If Property </option>\n+ </select>\n+\n+ <input type=\"text\" id=\"output-comparator-property-value\" style=\"width: 62%\" disabled />\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <!-- Type -->\n+ <select type=\"text\" id=\"output-comparator-type\" style=\"width: 140px;\" disabled>\n+ <option value=\"is\"> Is </option>\n+ <option value=\"is_not\"> Is Not </option>\n+\n+ <option value=\">\">></option>\n+ <option value=\">=\">>=</option>\n+ <option value=\"<\"><</option>\n+ <option value=\"<=\"><=</option>\n+\n+ <option value=\"includes\">Includes</option>\n+ <option value=\"does_not_include\">Does Not Include</option>\n+ </select>\n+\n+ <input type=\"text\" id=\"output-comparator-value\" style=\"width: 62%\" disabled />\n+ </div>\n+ <!-- Add Output Button -->\n+ <button id=\"output-add-btn\" style=\"width: 100%\">Add Output</button>\n+ </div>\n+ </div>\n+ <!-- Output List -->\n+ <div class=\"form-row\">\n+ <ol id=\"output-list\"></ol>\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <input type=\"checkbox\" id=\"node-input-outputinitially\" style=\"display: inline-block; width: auto; vertical-align: top;\">\n+ <label for=\"node-input-outputinitially\" style=\"width: auto;\">Output Initially / On Deploy</label>\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <input type=\"checkbox\" id=\"node-input-debugenabled\" style=\"display: inline-block; width: auto; vertical-align: top;\" />\n+ <label for=\"node-input-debugenabled\" style=\"width: auto;\">Show Debug Information</label>\n+ </div>\n+</script>\n<script type=\"text/x-red\" data-help-name=\"trigger-state\">\n<p>Advanced version of 'server:state-changed' node</p>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -6,6 +6,16 @@ module.exports = function(RED) {\ndebug: true,\nconfig: {\nentityid: {},\n+ entityidfilter: nodeDef => {\n+ if (!nodeDef.entityid) return undefined;\n+\n+ if (nodeDef.entityidfiltertype === 'substring')\n+ return nodeDef.entityid.split(',').map(f => f.trim());\n+ if (nodeDef.entityidfiltertype === 'regex')\n+ return new RegExp(nodeDef.entityid);\n+ return nodeDef.entityid;\n+ },\n+ entityidfiltertype: {},\nisenabled: {},\nconstraints: {},\ncustomoutputs: {},\n@@ -17,13 +27,11 @@ module.exports = function(RED) {\nconstructor(nodeDefinition) {\nsuper(nodeDefinition, RED, nodeOptions);\n- const eventTopic = (this.eventTopic = `ha_events:state_changed:${\n- this.nodeConfig.entityid\n- }`);\nthis.addEventClientListener({\n- event: eventTopic,\n+ event: 'ha_events:state_changed',\nhandler: this.onEntityStateChanged.bind(this)\n});\n+\nthis.NUM_DEFAULT_MESSAGES = 2;\nthis.messageTimers = {};\n@@ -88,6 +96,9 @@ module.exports = function(RED) {\n);\nreturn;\n}\n+ if (!this.shouldIncludeEvent(eventMessage.entity_id)) {\n+ return;\n+ }\ntry {\nconst constraintComparatorResults = await this.getConstraintComparatorResults(\n@@ -386,6 +397,25 @@ module.exports = function(RED) {\nawait this.removeNodeData();\n}\n}\n+\n+ shouldIncludeEvent(entityId) {\n+ if (!this.nodeConfig.entityidfilter) return true;\n+ const filter = this.nodeConfig.entityidfilter;\n+ const type = this.nodeConfig.entityidfiltertype;\n+\n+ if (type === 'substring') {\n+ const found = this.nodeConfig.entityidfilter.filter(\n+ filterStr => entityId.indexOf(filterStr) >= 0\n+ );\n+ return found.length > 0;\n+ }\n+\n+ if (type === 'regex') {\n+ return filter.test(entityId);\n+ }\n+\n+ return filter === entityId;\n+ }\n}\nRED.nodes.registerType('trigger-state', TriggerState);\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added substring/exact/regex to trigger node entity filter |
748,234 | 18.11.2018 20:40:15 | 28,800 | e8c22d5b0ccf2d384eb38613304c20130cccf4f5 | Added option to rendar Mustache templates in data
Call-service and fire-event data properties
Better handling of call-service error when not connected to HA
Sending status for fire-event and call-services nodes
fire-event won't pass message on until response from HA | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "}\n}\n},\n+ render_data: { value: false },\nmergecontext: { value: null }\n},\noneditprepare: function() {\n<input type=\"text\" id=\"node-input-data\" />\n</div>\n+ <div class=\"form-row\">\n+ <input type=\"checkbox\" id=\"node-input-render_data\" style=\"margin-left: 105px;display:inline-block; width:15px; vertical-align:baseline;\">\n+ <label for=\"node-input-render_data\" style=\"width: auto;\">Render templates in Data</label>\n+ </div>\n+\n<div class=\"form-row\">\n<label for=\"node-input-mergecontext\"><i class=\"fa fa-dot-circle-o\"></i> Merge Context</label>\n<input type=\"text\" id=\"node-input-mergecontext\" placeholder=\"lightOptions\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.js",
"new_path": "nodes/call-service/call-service.js",
"diff": "/* eslint-disable camelcase */\nconst BaseNode = require('../../lib/base-node');\n+const mustache = require('mustache');\nmodule.exports = function(RED) {\nconst nodeOptions = {\n@@ -8,6 +9,7 @@ module.exports = function(RED) {\nservice_domain: {},\nservice: {},\ndata: {},\n+ render_data: {},\nmergecontext: {},\nname: {},\nserver: { isNode: true }\n@@ -32,6 +34,22 @@ module.exports = function(RED) {\n}\n}\nonInput({ message }) {\n+ if (\n+ this.nodeConfig.server.websocket.connectionState !==\n+ this.nodeConfig.server.websocket.CONNECTED\n+ ) {\n+ this.status({\n+ fill: 'red',\n+ shape: 'ring',\n+ text: `No Connection at: ${this.getPrettyDate()}`\n+ });\n+ this.warn(\n+ 'Call-Service attempted without connection to server.'\n+ );\n+\n+ return;\n+ }\n+\nlet payload, payloadDomain, payloadService;\nif (message && message.payload) {\n@@ -39,31 +57,36 @@ module.exports = function(RED) {\npayloadDomain = this.utils.reach('domain', payload);\npayloadService = this.utils.reach('service', payload);\n}\n+\nconst configDomain = this.nodeConfig.service_domain;\nconst configService = this.nodeConfig.service;\n-\nconst apiDomain = payloadDomain || configDomain;\nconst apiService = payloadService || configService;\n- const apiData = this.getApiData(payload);\n- if (!apiDomain)\n+ let apiData = this.getApiData(payload);\n+\n+ if (!apiDomain) {\nthrow new Error(\n'call service node is missing api \"domain\" property, not found in config or payload'\n);\n- if (!apiService)\n+ }\n+\n+ if (!apiService) {\nthrow new Error(\n'call service node is missing api \"service\" property, not found in config or payload'\n);\n+ }\n+\n+ if (this.nodeConfig.render_data) {\n+ apiData = JSON.parse(\n+ mustache.render(JSON.stringify(apiData), message)\n+ );\n+ }\nthis.debug(\n`Calling Service: ${apiDomain}:${apiService} -- ${JSON.stringify(\napiData || {}\n)}`\n);\n- this.status({\n- fill: 'green',\n- shape: 'dot',\n- text: `${apiDomain}.${apiService} called at: ${this.getPrettyDate()}`\n- });\nmessage.payload = {\ndomain: apiDomain,\n@@ -71,9 +94,22 @@ module.exports = function(RED) {\ndata: apiData || null\n};\n+ this.status({\n+ fill: 'yellow',\n+ shape: 'dot',\n+ text: `Sending at: ${this.getPrettyDate()}`\n+ });\n+\nreturn this.nodeConfig.server.websocket\n.callService(apiDomain, apiService, apiData)\n- .then(this.send(message))\n+ .then(() => {\n+ this.status({\n+ fill: 'green',\n+ shape: 'dot',\n+ text: `${apiDomain}.${apiService} called at: ${this.getPrettyDate()}`\n+ });\n+ this.send(message);\n+ })\n.catch(err => {\nthis.warn(\n'Error calling service, home assistant api error',\n@@ -116,6 +152,7 @@ module.exports = function(RED) {\ncontextData,\npayloadData\n);\n+\nreturn apiData;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/fire-event/fire-event.html",
"new_path": "nodes/fire-event/fire-event.html",
"diff": "<script type=\"text/javascript\">\n- RED.nodes.registerType('ha-fire-event', {\n- category: 'home_assistant',\n- color: '#52C0F2',\n+ RED.nodes.registerType(\"ha-fire-event\", {\n+ category: \"home_assistant\",\n+ color: \"#52C0F2\",\ninputs: 1,\noutputs: 1,\n- icon: 'feed.png',\n- align: 'right',\n- paletteLabel: 'fire event',\n+ icon: \"feed.png\",\n+ align: \"right\",\n+ paletteLabel: \"fire event\",\nlabel: function() {\nreturn this.name || `Event: ${this.event}`;\n},\ndefaults: {\nname: {\n- value: ''\n+ value: \"\"\n},\nserver: {\n- value: '',\n- type: 'server',\n+ value: \"\",\n+ type: \"server\",\nrequired: true\n},\nevent: {\n- value: ''\n+ value: \"\"\n},\ndata: {\n- value: '',\n+ value: \"\",\nvalidate: function(v) {\n// data isn't required since it could be either not needed or provided via payload\nif (!v) {\n}\n}\n},\n+ render_data: { value: false },\nmergecontext: {\nvalue: null\n}\n},\noneditprepare: function() {\nconst NODE = this;\n- const $server = $('#node-input-server');\n+ const $server = $(\"#node-input-server\");\nconst node = this;\n- $('#node-input-data').typedInput({\n- 'types': ['json']\n+ $(\"#node-input-data\").typedInput({\n+ types: [\"json\"]\n});\nconst utils = {\nsetDefaultServerSelection: function() {\nlet defaultServer;\nRED.nodes.eachConfig(n => {\n- if (n.type === 'server' && !defaultServer) defaultServer = n.id;\n+ if (n.type === \"server\" && !defaultServer) defaultServer = n.id;\n});\nif (defaultServer) $server.val(defaultServer);\n}\n});\n</script>\n-\n<script type=\"text/x-red\" data-template-name=\"ha-fire-event\">\n<div class=\"form-row\">\n<label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n<input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n</div>\n-\n<div class=\"form-row\">\n<label for=\"node-input-server\"><i class=\"fa fa-dot-circle-o\"></i> Server</label>\n<input type=\"text\" id=\"node-input-server\" />\n<input type=\"text\" id=\"node-input-data\" placeholder=\"{ }\"/>\n</div>\n+ <div class=\"form-row\">\n+ <input type=\"checkbox\" id=\"node-input-render_data\" style=\"margin-left: 105px;display:inline-block; width:15px; vertical-align:baseline;\">\n+ <label for=\"node-input-render_data\" style=\"width: auto;\">Render templates in Data</label>\n+ </div>\n+\n<div class=\"form-row\">\n<label for=\"node-input-mergecontext\"><i class=\"fa fa-dot-circle-o\"></i> Merge Context</label>\n<input type=\"text\" id=\"node-input-mergecontext\" placeholder=\"lightOptions\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/fire-event/fire-event.js",
"new_path": "nodes/fire-event/fire-event.js",
"diff": "const BaseNode = require('../../lib/base-node');\n+const mustache = require('mustache');\nmodule.exports = function(RED) {\nconst nodeOptions = {\n@@ -6,6 +7,7 @@ module.exports = function(RED) {\nconfig: {\nevent: {},\ndata: {},\n+ render_data: {},\nmergecontext: {},\nname: {},\nserver: {\n@@ -37,30 +39,46 @@ module.exports = function(RED) {\npayload = this.tryToObject(message.payload);\npayloadEvent = this.utils.reach('event', payload);\n}\n- const configEvent = this.nodeConfig.event;\n+ const configEvent = this.nodeConfig.event;\nconst eventType = payloadEvent || configEvent;\n- const eventData = this.getEventData(payload);\n- if (!eventType)\n+ let eventData = this.getEventData(payload);\n+\n+ if (!eventType) {\nthrow new Error(\n'fire event node is missing \"event\" property, not found in config or payload'\n);\n+ }\nthis.debug(`Fire Event: ${eventType} -- ${JSON.stringify({})}`);\n- this.status({\n- fill: 'green',\n- shape: 'dot',\n- text: `${eventType} at: ${this.getPrettyDate()}`\n- });\n+\n+ if (this.nodeConfig.render_data) {\n+ eventData = JSON.parse(\n+ mustache.render(JSON.stringify(eventData), message)\n+ );\n+ }\nmessage.payload = {\nevent: eventType,\ndata: eventData || null\n};\n- this.send(message);\n+\n+ this.status({\n+ fill: 'yellow',\n+ shape: 'dot',\n+ text: `Sending at: ${this.getPrettyDate()}`\n+ });\nreturn this.nodeConfig.server.api\n.fireEvent(eventType, eventData)\n+ .then(() => {\n+ this.status({\n+ fill: 'green',\n+ shape: 'dot',\n+ text: `${eventType} at: ${this.getPrettyDate()}`\n+ });\n+ this.send(message);\n+ })\n.catch(err => {\nthis.error(\n`Error firing event, home assistant rest api error: ${\n@@ -101,6 +119,7 @@ module.exports = function(RED) {\ncontextData,\npayloadData\n);\n+\nreturn eventData;\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added option to rendar Mustache templates in data
- Call-service and fire-event data properties
- Better handling of call-service error when not connected to HA
- Sending status for fire-event and call-services nodes
- fire-event won't pass message on until response from HA |
748,234 | 18.11.2018 21:07:23 | 28,800 | a5d858c959ca15db6c72cb760e65b00efcd62b24 | Removed some fire-event tests until mock server is in | [
{
"change_type": "MODIFY",
"old_path": "test/fire-event_spec.js",
"new_path": "test/fire-event_spec.js",
"diff": "@@ -23,7 +23,7 @@ describe('fire-event node', function() {\n});\n// Merge Context: Payload Data > Flow Data > Global Data > Config Data ( payload data property always wins if provided )\n-\n+ /*\nit('should pass config data through', function(done) {\nvar flow = [\n{\n@@ -168,4 +168,5 @@ describe('fire-event node', function() {\nn1.receive({ payload: { data: { foo: 'toto' } }, topic: 'bar' });\n});\n});\n+ */\n});\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Removed some fire-event tests until mock server is in |
748,234 | 18.11.2018 21:49:13 | 28,800 | bea72e3ced75f2ac82fa64741b146a986330022e | Add Requesting status to get-history and render-template | [
{
"change_type": "MODIFY",
"old_path": "nodes/get-history/get-history.js",
"new_path": "nodes/get-history/get-history.js",
"diff": "@@ -76,6 +76,12 @@ module.exports = function(RED) {\nenddate\n);\n+ this.status({\n+ fill: 'yellow',\n+ shape: 'dot',\n+ text: `Requesting at: ${this.getPrettyDate()}`\n+ });\n+\nreturn apiRequest\n.then(res => {\nmessage.startdate = startdate;\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/render-template/render-template.js",
"new_path": "nodes/render-template/render-template.js",
"diff": "@@ -30,6 +30,12 @@ module.exports = function(RED) {\nlet { template } = parsedMessage;\ntemplate = template.value;\n+ this.status({\n+ fill: 'yellow',\n+ shape: 'dot',\n+ text: `Requesting at: ${this.getPrettyDate()}`\n+ });\n+\nreturn this.nodeConfig.server.api\n.renderTemplate(template)\n.then(res => {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Add Requesting status to get-history and render-template |
748,234 | 18.11.2018 22:46:31 | 28,800 | 13bd7a3f70194ec266852fb28b98d3be6e293204 | Only subscribe to all state_changed events if needed
If filter type is exact for trigger and event state nodes only subscribe to the exact entity id state change | [
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -23,8 +23,17 @@ module.exports = function(RED) {\nclass ServerStateChangedNode extends EventsNode {\nconstructor(nodeDefinition) {\nsuper(nodeDefinition, RED, nodeOptions);\n+\n+ let eventTopic = 'ha_events:state_changed';\n+\n+ if (this.nodeConfig.entityidfiltertype === 'exact') {\n+ eventTopic = this.eventTopic = `ha_events:state_changed:${\n+ this.nodeConfig.entityidfilter\n+ }`;\n+ }\n+\nthis.addEventClientListener({\n- event: 'ha_events:state_changed',\n+ event: eventTopic,\nhandler: this.onHaEventsStateChanged.bind(this)\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -27,8 +27,16 @@ module.exports = function(RED) {\nconstructor(nodeDefinition) {\nsuper(nodeDefinition, RED, nodeOptions);\n+ let eventTopic = 'ha_events:state_changed';\n+\n+ if (this.nodeConfig.entityidfiltertype === 'exact') {\n+ eventTopic = this.eventTopic = `ha_events:state_changed:${\n+ this.nodeConfig.entityid\n+ }`;\n+ }\n+\nthis.addEventClientListener({\n- event: 'ha_events:state_changed',\n+ event: eventTopic,\nhandler: this.onEntityStateChanged.bind(this)\n});\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Only subscribe to all state_changed events if needed
If filter type is exact for trigger and event state nodes only subscribe to the exact entity id state change |
748,234 | 19.11.2018 18:18:19 | 28,800 | 5bae5022abcb4b06bcb5ff4293158974dff9688f | stalebot config changes - removed stale label | [
{
"change_type": "MODIFY",
"old_path": ".github/stale.yml",
"new_path": ".github/stale.yml",
"diff": "@@ -7,7 +7,7 @@ exemptLabels:\n- pinned\n- security\n# Label to use when marking an issue as stale\n-staleLabel: wontfix\n+# staleLabel: wontfix\n# Comment to post when marking an issue as stale. Set to `false` to disable\nmarkComment: >\nThis issue has been automatically marked as stale because it has not had\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | stalebot config changes - removed stale label |
748,234 | 27.11.2018 00:39:57 | 28,800 | 6270854a05a318863d5c8e5b543b2948d0ae1b45 | Removed unused timed-task.js and dependency
Update dev dependencies | [
{
"change_type": "DELETE",
"old_path": "lib/timed-task.js",
"new_path": null,
"diff": "-const serialize = require('serialize-javascript');\n-\n-class TimedTask {\n- constructor(o) {\n- this.id = o.id;\n- this.task = o.task;\n- this.onStart = o.onStart;\n- this.onComplete = o.onComplete;\n- this.onCancel = o.onCancel;\n- this.onFailed = o.onFailed;\n-\n- const now = this.getNow();\n- if (o.runsAt && o.runsAt <= now)\n- throw new Error(\n- 'Cannot schedule a task which is set to run in the past'\n- );\n-\n- let runsIn = o.runsAt ? o.runsAt - now : o.runsIn;\n-\n- this.schedule(runsIn);\n- }\n-\n- schedule(runsInMs) {\n- this.cancel();\n- this.scheduledAt = this.getNow();\n- this.runsAt = this.scheduledAt + runsInMs;\n- this.timer = setTimeout(this.start.bind(this), runsInMs);\n- }\n-\n- getNow() {\n- return Date.now();\n- }\n-\n- cancel() {\n- if (this.timer) {\n- if (typeof this.onCancel === 'function') this.onCancel();\n- clearTimeout(this.timer);\n- ['timer', 'scheduledAt', 'runsAt'].forEach(k => (this[k] = null));\n- }\n- }\n-\n- getRunsAtDate() {\n- return new Date(this.runsAt);\n- }\n-\n- async start() {\n- if (typeof this.onStart === 'function') this.onStart();\n- try {\n- await this.task();\n- this.onComplete();\n- } catch (e) {\n- if (typeof this.onFailed === 'function') {\n- this.cancel();\n- this.onFailed(e);\n- } else {\n- throw e;\n- }\n- }\n- }\n- static create(o) {\n- return new TimedTask(o);\n- }\n-\n- static createFromSerialized(str) {\n- const taskObj = eval('(' + str + ')'); // eslint-disable-line\n- return new TimedTask(taskObj);\n- }\n-\n- serialize() {\n- return serialize(this);\n- }\n-\n- // Called by stringify with serialize\n- toJSON() {\n- const {\n- id,\n- runsAt,\n- task,\n- onStart,\n- onComplete,\n- onCancel,\n- onFailed\n- } = this;\n- return { id, runsAt, task, onStart, onComplete, onCancel, onFailed };\n- }\n-}\n-\n-module.exports = TimedTask;\n"
},
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "\"ansi-regex\": {\n\"version\": \"2.1.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"aproba\": {\n\"version\": \"1.2.0\",\n\"balanced-match\": {\n\"version\": \"1.0.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"brace-expansion\": {\n\"version\": \"1.1.11\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"balanced-match\": \"^1.0.0\",\n\"concat-map\": \"0.0.1\"\n\"code-point-at\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"concat-map\": {\n\"version\": \"0.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"console-control-strings\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"core-util-is\": {\n\"version\": \"1.0.2\",\n\"inherits\": {\n\"version\": \"2.0.3\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"ini\": {\n\"version\": \"1.3.5\",\n\"version\": \"1.0.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"number-is-nan\": \"^1.0.0\"\n}\n\"version\": \"3.0.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"brace-expansion\": \"^1.1.7\"\n}\n\"minimist\": {\n\"version\": \"0.0.8\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"minipass\": {\n\"version\": \"2.2.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"safe-buffer\": \"^5.1.1\",\n\"yallist\": \"^3.0.0\"\n\"yallist\": {\n\"version\": \"3.0.2\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n}\n}\n},\n\"version\": \"0.5.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"minimist\": \"0.0.8\"\n}\n\"number-is-nan\": {\n\"version\": \"1.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"object-assign\": {\n\"version\": \"4.1.1\",\n\"version\": \"1.4.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"wrappy\": \"1\"\n}\n\"safe-buffer\": {\n\"version\": \"5.1.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"safer-buffer\": {\n\"version\": \"2.1.2\",\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"code-point-at\": \"^1.0.0\",\n\"is-fullwidth-code-point\": \"^1.0.0\",\n\"version\": \"3.0.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"ansi-regex\": \"^2.0.0\"\n}\n\"wrappy\": {\n\"version\": \"1.0.2\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n}\n}\n},\n\"readable-stream\": \"> 1.0.0 < 3.0.0\"\n}\n},\n+ \"caller-callsite\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz\",\n+ \"integrity\": \"sha1-hH4PzgoiN1CpoCfFSzNzGtMVQTQ=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"callsites\": \"^2.0.0\"\n+ },\n+ \"dependencies\": {\n+ \"callsites\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"http://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz\",\n+ \"integrity\": \"sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA=\",\n+ \"dev\": true\n+ }\n+ }\n+ },\n\"caller-path\": {\n\"version\": \"0.1.0\",\n\"resolved\": \"https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz\",\n}\n},\n\"cosmiconfig\": {\n- \"version\": \"5.0.6\",\n- \"resolved\": \"https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.6.tgz\",\n- \"integrity\": \"sha512-6DWfizHriCrFWURP1/qyhsiFvYdlJzbCzmtFWh744+KyWsJo5+kPzUZZaMRSSItoYc0pxFX7gEO7ZC1/gN/7AQ==\",\n+ \"version\": \"5.0.7\",\n+ \"resolved\": \"https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.7.tgz\",\n+ \"integrity\": \"sha512-PcLqxTKiDmNT6pSpy4N6KtuPwb53W+2tzNvwOZw0WH9N6O0vLIBq0x8aj8Oj75ere4YcGi48bDFCL+3fRJdlNA==\",\n\"dev\": true,\n\"requires\": {\n+ \"import-fresh\": \"^2.0.0\",\n\"is-directory\": \"^0.3.1\",\n\"js-yaml\": \"^3.9.0\",\n\"parse-json\": \"^4.0.0\"\n}\n}\n},\n+ \"del\": {\n+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/del/-/del-3.0.0.tgz\",\n+ \"integrity\": \"sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"globby\": \"^6.1.0\",\n+ \"is-path-cwd\": \"^1.0.0\",\n+ \"is-path-in-cwd\": \"^1.0.0\",\n+ \"p-map\": \"^1.1.1\",\n+ \"pify\": \"^3.0.0\",\n+ \"rimraf\": \"^2.2.8\"\n+ }\n+ },\n\"delayed-stream\": {\n\"version\": \"1.0.0\",\n\"resolved\": \"https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz\",\n\"ansi-regex\": {\n\"version\": \"2.1.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"aproba\": {\n\"version\": \"1.2.0\",\n\"balanced-match\": {\n\"version\": \"1.0.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"brace-expansion\": {\n\"version\": \"1.1.11\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"balanced-match\": \"^1.0.0\",\n\"concat-map\": \"0.0.1\"\n\"code-point-at\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"concat-map\": {\n\"version\": \"0.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"console-control-strings\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"core-util-is\": {\n\"version\": \"1.0.2\",\n\"inherits\": {\n\"version\": \"2.0.3\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"ini\": {\n\"version\": \"1.3.5\",\n\"version\": \"1.0.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"number-is-nan\": \"^1.0.0\"\n}\n\"version\": \"3.0.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"brace-expansion\": \"^1.1.7\"\n}\n\"minimist\": {\n\"version\": \"0.0.8\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"minipass\": {\n\"version\": \"2.2.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"safe-buffer\": \"^5.1.1\",\n\"yallist\": \"^3.0.0\"\n\"version\": \"0.5.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"minimist\": \"0.0.8\"\n}\n\"number-is-nan\": {\n\"version\": \"1.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"object-assign\": {\n\"version\": \"4.1.1\",\n\"version\": \"1.4.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"wrappy\": \"1\"\n}\n\"safe-buffer\": {\n\"version\": \"5.1.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"safer-buffer\": {\n\"version\": \"2.1.2\",\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"code-point-at\": \"^1.0.0\",\n\"is-fullwidth-code-point\": \"^1.0.0\",\n\"version\": \"3.0.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"ansi-regex\": \"^2.0.0\"\n}\n\"wrappy\": {\n\"version\": \"1.0.2\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"yallist\": {\n\"version\": \"3.0.2\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n}\n}\n},\n\"integrity\": \"sha512-5cJVtyXWH8PiJPVLZzzoIizXx944O4OmRro5MWKx5fT4MgcN7OfaMutPeaTdJCCURwbWdhhcCWcKIffPnmTzBg==\",\n\"dev\": true\n},\n+ \"globby\": {\n+ \"version\": \"6.1.0\",\n+ \"resolved\": \"http://registry.npmjs.org/globby/-/globby-6.1.0.tgz\",\n+ \"integrity\": \"sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"array-union\": \"^1.0.1\",\n+ \"glob\": \"^7.0.3\",\n+ \"object-assign\": \"^4.0.1\",\n+ \"pify\": \"^2.0.0\",\n+ \"pinkie-promise\": \"^2.0.0\"\n+ },\n+ \"dependencies\": {\n+ \"pify\": {\n+ \"version\": \"2.3.0\",\n+ \"resolved\": \"http://registry.npmjs.org/pify/-/pify-2.3.0.tgz\",\n+ \"integrity\": \"sha1-7RQaasBDqEnqWISY59yosVMw6Qw=\",\n+ \"dev\": true\n+ }\n+ }\n+ },\n\"got\": {\n\"version\": \"6.7.1\",\n\"resolved\": \"http://registry.npmjs.org/got/-/got-6.7.1.tgz\",\n}\n},\n\"husky\": {\n- \"version\": \"1.1.4\",\n- \"resolved\": \"https://registry.npmjs.org/husky/-/husky-1.1.4.tgz\",\n- \"integrity\": \"sha512-cZjGpS7qsaBSo3fOMUuR7erQloX3l5XzL1v/RkIqU6zrQImDdU70z5Re9fGDp7+kbYlM2EtS4aYMlahBeiCUGw==\",\n+ \"version\": \"1.2.0\",\n+ \"resolved\": \"https://registry.npmjs.org/husky/-/husky-1.2.0.tgz\",\n+ \"integrity\": \"sha512-/ib3+iycykXC0tYIxsyqierikVa9DA2DrT32UEirqNEFVqOj1bFMTgP3jAz8HM7FgC/C8pc/BTUa9MV2GEkZaA==\",\n\"dev\": true,\n\"requires\": {\n\"cosmiconfig\": \"^5.0.6\",\n}\n}\n},\n+ \"import-fresh\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/import-fresh/-/import-fresh-2.0.0.tgz\",\n+ \"integrity\": \"sha1-2BNVwVYS04bGH53dOSLUMEgipUY=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"caller-path\": \"^2.0.0\",\n+ \"resolve-from\": \"^3.0.0\"\n+ },\n+ \"dependencies\": {\n+ \"caller-path\": {\n+ \"version\": \"2.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/caller-path/-/caller-path-2.0.0.tgz\",\n+ \"integrity\": \"sha1-Ro+DBE42mrIBD6xfBs7uFbsssfQ=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"caller-callsite\": \"^2.0.0\"\n+ }\n+ },\n+ \"resolve-from\": {\n+ \"version\": \"3.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz\",\n+ \"integrity\": \"sha1-six699nWiBvItuZTM17rywoYh0g=\",\n+ \"dev\": true\n+ }\n+ }\n+ },\n\"import-lazy\": {\n\"version\": \"2.1.0\",\n\"resolved\": \"https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz\",\n\"dev\": true\n},\n\"lint-staged\": {\n- \"version\": \"8.0.5\",\n- \"resolved\": \"https://registry.npmjs.org/lint-staged/-/lint-staged-8.0.5.tgz\",\n- \"integrity\": \"sha512-QI2D6lw2teArlr2fmrrCIqHxef7mK2lKjz9e+aZSzFlk5rsy10rg97p3wA9H/vIFR3Fvn34fAgUktD/k896S2A==\",\n+ \"version\": \"8.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/lint-staged/-/lint-staged-8.1.0.tgz\",\n+ \"integrity\": \"sha512-yfSkyJy7EuVsaoxtUSEhrD81spdJOe/gMTGea3XaV7HyoRhTb9Gdlp6/JppRZERvKSEYXP9bjcmq6CA5oL2lYQ==\",\n\"dev\": true,\n\"requires\": {\n\"@iamstarkov/listr-update-renderer\": \"0.4.1\",\n\"chalk\": \"^2.3.1\",\n\"commander\": \"^2.14.1\",\n- \"cosmiconfig\": \"^5.0.2\",\n+ \"cosmiconfig\": \"5.0.6\",\n\"debug\": \"^3.1.0\",\n\"dedent\": \"^0.7.0\",\n\"del\": \"^3.0.0\",\n\"stringify-object\": \"^3.2.2\"\n},\n\"dependencies\": {\n- \"cross-spawn\": {\n- \"version\": \"6.0.5\",\n- \"resolved\": \"https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz\",\n- \"integrity\": \"sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==\",\n+ \"cosmiconfig\": {\n+ \"version\": \"5.0.6\",\n+ \"resolved\": \"https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.6.tgz\",\n+ \"integrity\": \"sha512-6DWfizHriCrFWURP1/qyhsiFvYdlJzbCzmtFWh744+KyWsJo5+kPzUZZaMRSSItoYc0pxFX7gEO7ZC1/gN/7AQ==\",\n\"dev\": true,\n\"requires\": {\n- \"nice-try\": \"^1.0.4\",\n- \"path-key\": \"^2.0.1\",\n- \"semver\": \"^5.5.0\",\n- \"shebang-command\": \"^1.2.0\",\n- \"which\": \"^1.2.9\"\n+ \"is-directory\": \"^0.3.1\",\n+ \"js-yaml\": \"^3.9.0\",\n+ \"parse-json\": \"^4.0.0\"\n}\n},\n\"debug\": {\n\"ms\": \"^2.1.1\"\n}\n},\n- \"del\": {\n- \"version\": \"3.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/del/-/del-3.0.0.tgz\",\n- \"integrity\": \"sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=\",\n- \"dev\": true,\n- \"requires\": {\n- \"globby\": \"^6.1.0\",\n- \"is-path-cwd\": \"^1.0.0\",\n- \"is-path-in-cwd\": \"^1.0.0\",\n- \"p-map\": \"^1.1.1\",\n- \"pify\": \"^3.0.0\",\n- \"rimraf\": \"^2.2.8\"\n- }\n- },\n- \"execa\": {\n- \"version\": \"1.0.0\",\n- \"resolved\": \"https://registry.npmjs.org/execa/-/execa-1.0.0.tgz\",\n- \"integrity\": \"sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==\",\n- \"dev\": true,\n- \"requires\": {\n- \"cross-spawn\": \"^6.0.0\",\n- \"get-stream\": \"^4.0.0\",\n- \"is-stream\": \"^1.1.0\",\n- \"npm-run-path\": \"^2.0.0\",\n- \"p-finally\": \"^1.0.0\",\n- \"signal-exit\": \"^3.0.0\",\n- \"strip-eof\": \"^1.0.0\"\n- }\n- },\n- \"get-stream\": {\n- \"version\": \"4.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz\",\n- \"integrity\": \"sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==\",\n- \"dev\": true,\n- \"requires\": {\n- \"pump\": \"^3.0.0\"\n- }\n- },\n- \"globby\": {\n- \"version\": \"6.1.0\",\n- \"resolved\": \"https://registry.npmjs.org/globby/-/globby-6.1.0.tgz\",\n- \"integrity\": \"sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=\",\n- \"dev\": true,\n- \"requires\": {\n- \"array-union\": \"^1.0.1\",\n- \"glob\": \"^7.0.3\",\n- \"object-assign\": \"^4.0.1\",\n- \"pify\": \"^2.0.0\",\n- \"pinkie-promise\": \"^2.0.0\"\n- },\n- \"dependencies\": {\n- \"pify\": {\n- \"version\": \"2.3.0\",\n- \"resolved\": \"https://registry.npmjs.org/pify/-/pify-2.3.0.tgz\",\n- \"integrity\": \"sha1-7RQaasBDqEnqWISY59yosVMw6Qw=\",\n- \"dev\": true\n- }\n- }\n- },\n\"is-glob\": {\n\"version\": \"4.0.0\",\n\"resolved\": \"https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz\",\n\"resolved\": \"https://registry.npmjs.org/ms/-/ms-2.1.1.tgz\",\n\"integrity\": \"sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==\",\n\"dev\": true\n+ },\n+ \"parse-json\": {\n+ \"version\": \"4.0.0\",\n+ \"resolved\": \"https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz\",\n+ \"integrity\": \"sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=\",\n+ \"dev\": true,\n+ \"requires\": {\n+ \"error-ex\": \"^1.3.1\",\n+ \"json-parse-better-errors\": \"^1.0.1\"\n+ }\n}\n}\n},\n\"integrity\": \"sha1-MyeRAMNcOFGcpeQ1JFGGxRL+D9w=\",\n\"dev\": true\n},\n- \"serialize-javascript\": {\n- \"version\": \"1.5.0\",\n- \"resolved\": \"https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.5.0.tgz\",\n- \"integrity\": \"sha512-Ga8c8NjAAp46Br4+0oZ2WxJCwIzwP60Gq1YPgU+39PiTVxyed/iKE/zyZI6+UlVYH5Q4PaQdHhcegIFPZTUfoQ==\"\n- },\n\"serve-static\": {\n\"version\": \"1.13.2\",\n\"resolved\": \"https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"merge\": \"1.2.1\",\n\"mustache\": \"^3.0.1\",\n\"selectn\": \"1.1.2\",\n- \"serialize-javascript\": \"1.5.0\",\n\"time-ago\": \"0.2.1\",\n\"ws\": \"6.1.2\"\n},\n\"eslint-plugin-prettier\": \"^3.0.0\",\n\"eslint-plugin-promise\": \"^4.0.1\",\n\"eslint-plugin-standard\": \"^4.0.0\",\n- \"husky\": \"^1.1.4\",\n+ \"husky\": \"^1.2.0\",\n\"istanbul\": \"^1.1.0-alpha.1\",\n- \"lint-staged\": \"^8.0.5\",\n+ \"lint-staged\": \"^8.1.0\",\n\"mocha\": \"^5.2.0\",\n\"nock\": \"^10.0.2\",\n\"node-red\": \"^0.19.5\",\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Removed unused timed-task.js and dependency
Update dev dependencies |
748,246 | 02.12.2018 12:03:00 | 0 | 51ecf7ad69a26630f54a7598c47dd91e9d63c9d0 | Added times to success and error message statuses. | [
{
"change_type": "MODIFY",
"old_path": "nodes/render-template/render-template.js",
"new_path": "nodes/render-template/render-template.js",
"diff": "@@ -45,7 +45,7 @@ module.exports = function(RED) {\nthis.status({\nfill: 'green',\nshape: 'dot',\n- text: 'Success'\n+ text: `Success at: ${this.getPrettyDate()}`\n});\n})\n.catch(err => {\n@@ -55,7 +55,11 @@ module.exports = function(RED) {\n}`,\nmessage\n);\n- this.status({ fill: 'red', shape: 'ring', text: 'Error' });\n+ this.status({\n+ fill: 'red',\n+ shape: 'ring',\n+ text: `Error at: ${this.getPrettyDate()}`\n+ });\n});\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added times to success and error message statuses. (#46) |
748,234 | 05.12.2018 14:31:53 | 28,800 | 8df2acbd33b781bb35219caba858b67408ec1483 | Add timeSinceChangedMs to current-state, events-state, and trigger-state nodes | [
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -55,6 +55,9 @@ module.exports = function(RED) {\n`entity could not be found in cache for entity_id: ${entity_id}, sending empty payload`\n);\n+ currentState.timeSinceChangedMs =\n+ Date.now() - new Date(currentState.last_changed).getTime();\n+\nconst shouldHaltIfState =\nthis.nodeConfig.halt_if &&\ncurrentState.state === this.nodeConfig.halt_if;\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -73,6 +73,10 @@ module.exports = function(RED) {\nreturn null;\n}\n+ event.new_state.timeSinceChangedMs =\n+ Date.now() -\n+ new Date(event.new_state.last_changed).getTime();\n+\n// Convert and save original state if needed\nif (this.nodeConfig.state_type) {\nif (event.old_state) {\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -110,6 +110,12 @@ module.exports = function(RED) {\n}\ntry {\n+ eventMessage.event.new_state.timeSinceChangedMs =\n+ Date.now() -\n+ new Date(\n+ eventMessage.event.new_state.last_changed\n+ ).getTime();\n+\nconst constraintComparatorResults = await this.getConstraintComparatorResults(\nthis.nodeConfig.constraints,\neventMessage\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Add timeSinceChangedMs to current-state, events-state, and trigger-state nodes |
748,234 | 05.12.2018 15:01:14 | 28,800 | f492a63c175e6b5e1a66ab15c33eb2aa2d97827e | Refactor casting state to happen before halt and trigger logic | [
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -58,6 +58,15 @@ module.exports = function(RED) {\ncurrentState.timeSinceChangedMs =\nDate.now() - new Date(currentState.last_changed).getTime();\n+ // Convert and save original state if needed\n+ if (this.nodeConfig.state_type) {\n+ currentState.original_state = currentState.state;\n+ currentState.state = this.getCastValue(\n+ this.nodeConfig.state_type,\n+ currentState.state\n+ );\n+ }\n+\nconst shouldHaltIfState =\nthis.nodeConfig.halt_if &&\ncurrentState.state === this.nodeConfig.halt_if;\n@@ -73,15 +82,6 @@ module.exports = function(RED) {\nreturn null;\n}\n- // Convert and save original state if needed\n- if (this.nodeConfig.state_type) {\n- currentState.original_state = currentState.state;\n- currentState.state = this.getCastValue(\n- this.nodeConfig.state_type,\n- currentState.state\n- );\n- }\n-\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\nconst override_topic = this.nodeConfig.override_topic !== false;\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -54,25 +54,6 @@ module.exports = function(RED) {\nreturn null;\n}\n- const shouldHaltIfState = this.shouldHaltIfState(event);\n- const shouldIncludeEvent = this.shouldIncludeEvent(entity_id);\n-\n- if (shouldIncludeEvent) {\n- if (shouldHaltIfState) {\n- this.debug(\n- 'flow halted due to \"halt if state\" setting'\n- );\n- this.status({\n- fill: 'red',\n- shape: 'ring',\n- text: `${\n- event.new_state.state\n- } at: ${this.getPrettyDate()}`\n- });\n-\n- return null;\n- }\n-\nevent.new_state.timeSinceChangedMs =\nDate.now() -\nnew Date(event.new_state.last_changed).getTime();\n@@ -80,8 +61,7 @@ module.exports = function(RED) {\n// Convert and save original state if needed\nif (this.nodeConfig.state_type) {\nif (event.old_state) {\n- event.old_state.original_state =\n- event.old_state.state;\n+ event.old_state.original_state = event.old_state.state;\nevent.old_state.state = this.getCastValue(\nthis.nodeConfig.state_type,\nevent.old_state.state\n@@ -94,6 +74,25 @@ module.exports = function(RED) {\n);\n}\n+ const shouldHaltIfState = this.shouldHaltIfState(event);\n+ const shouldIncludeEvent = this.shouldIncludeEvent(entity_id);\n+\n+ if (shouldIncludeEvent) {\n+ if (shouldHaltIfState) {\n+ this.debug(\n+ 'flow halted due to \"halt if state\" setting'\n+ );\n+ this.status({\n+ fill: 'red',\n+ shape: 'ring',\n+ text: `${\n+ event.new_state.state\n+ } at: ${this.getPrettyDate()}`\n+ });\n+\n+ return null;\n+ }\n+\nconst msg = {\ntopic: entity_id,\npayload: event.new_state.state,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -105,10 +105,31 @@ module.exports = function(RED) {\n);\nreturn;\n}\n+\n+ eventMessage = this.utils.merge({}, eventMessage);\n+\nif (!this.shouldIncludeEvent(eventMessage.entity_id)) {\nreturn;\n}\n+ // Convert and save original state if needed\n+ if (this.nodeConfig.state_type) {\n+ if (eventMessage.event.old_state) {\n+ eventMessage.event.old_state.original_state =\n+ eventMessage.event.old_state.state;\n+ eventMessage.event.old_state.state = this.getCastValue(\n+ this.nodeConfig.state_type,\n+ eventMessage.event.old_state.state\n+ );\n+ }\n+ eventMessage.event.new_state.original_state =\n+ eventMessage.event.new_state.state;\n+ eventMessage.event.new_state.state = this.getCastValue(\n+ this.nodeConfig.state_type,\n+ eventMessage.event.new_state.state\n+ );\n+ }\n+\ntry {\neventMessage.event.new_state.timeSinceChangedMs =\nDate.now() -\n@@ -222,23 +243,7 @@ module.exports = function(RED) {\n}\ngetDefaultMessageOutputs(comparatorResults, eventMessage) {\n- const { entity_id, event } = this.utils.merge({}, eventMessage);\n-\n- // Convert and save original state if needed\n- if (this.nodeConfig.state_type) {\n- if (event.old_state) {\n- event.old_state.original_state = event.old_state.state;\n- event.old_state.state = this.getCastValue(\n- this.nodeConfig.state_type,\n- event.old_state.state\n- );\n- }\n- event.new_state.original_state = event.new_state.state;\n- event.new_state.state = this.getCastValue(\n- this.nodeConfig.state_type,\n- event.new_state.state\n- );\n- }\n+ const { entity_id, event } = eventMessage;\nconst msg = {\ntopic: entity_id,\n@@ -380,26 +385,6 @@ module.exports = function(RED) {\n}\nif (output.messageType === 'default') {\n- eventMessage = this.utils.merge({}, eventMessage);\n-\n- // Convert and save original state if needed\n- if (this.nodeConfig.state_type) {\n- if (eventMessage.event.old_state) {\n- eventMessage.event.old_state.original_state =\n- eventMessage.event.old_state.state;\n- eventMessage.event.old_state.state = this.getCastValue(\n- this.nodeConfig.state_type,\n- eventMessage.event.old_state.state\n- );\n- }\n- eventMessage.event.new_state.original_state =\n- eventMessage.event.new_state.state;\n- eventMessage.event.new_state.state = this.getCastValue(\n- this.nodeConfig.state_type,\n- eventMessage.event.new_state.state\n- );\n- }\n-\nreturn {\ntopic: eventMessage.entity_id,\npayload: eventMessage.event.new_state.state,\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Refactor casting state to happen before halt and trigger logic |
748,234 | 05.12.2018 15:04:56 | 28,800 | 5ee065b754aa7ed77319c04e060a705efd0626d6 | Only cast state if not casting to string | [
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -59,7 +59,10 @@ module.exports = function(RED) {\nDate.now() - new Date(currentState.last_changed).getTime();\n// Convert and save original state if needed\n- if (this.nodeConfig.state_type) {\n+ if (\n+ this.nodeConfig.state_type &&\n+ this.nodeConfig.state_type !== 'str'\n+ ) {\ncurrentState.original_state = currentState.state;\ncurrentState.state = this.getCastValue(\nthis.nodeConfig.state_type,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -59,7 +59,10 @@ module.exports = function(RED) {\nnew Date(event.new_state.last_changed).getTime();\n// Convert and save original state if needed\n- if (this.nodeConfig.state_type) {\n+ if (\n+ this.nodeConfig.state_type &&\n+ this.nodeConfig.state_type !== 'str'\n+ ) {\nif (event.old_state) {\nevent.old_state.original_state = event.old_state.state;\nevent.old_state.state = this.getCastValue(\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -89,7 +89,10 @@ module.exports = function(RED) {\nDate.now() - dateChanged.getTime();\n// Convert and save original state if needed\n- if (this.nodeConfig.state_type) {\n+ if (\n+ this.nodeConfig.state_type &&\n+ this.nodeConfig.state_type !== 'str'\n+ ) {\npollState.original_state = pollState.state;\npollState.state = this.getCastValue(\nthis.nodeConfig.state_type,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -113,7 +113,10 @@ module.exports = function(RED) {\n}\n// Convert and save original state if needed\n- if (this.nodeConfig.state_type) {\n+ if (\n+ this.nodeConfig.state_type &&\n+ this.nodeConfig.state_type !== 'str'\n+ ) {\nif (eventMessage.event.old_state) {\neventMessage.event.old_state.original_state =\neventMessage.event.old_state.state;\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Only cast state if not casting to string |
748,234 | 08.12.2018 09:42:09 | 28,800 | d19992911b6797ad6b9627f84df8b2a70c918dde | Added a more comprehensive half if logic to serveral nodes | [
{
"change_type": "MODIFY",
"old_path": "lib/base-node.js",
"new_path": "lib/base-node.js",
"diff": "@@ -15,7 +15,7 @@ const utils = {\ntoCamelCase(str) {\nreturn str.replace(/(?:^\\w|[A-Z]|\\b\\w|\\s+)/g, function(match, index) {\nif (+match === 0) return '';\n- return index == 0 ? match.toLowerCase() : match.toUpperCase(); // eslint-disable-line\n+ return index === 0 ? match.toLowerCase() : match.toUpperCase();\n});\n}\n};\n@@ -235,6 +235,59 @@ class BaseNode {\nreturn value;\n}\n}\n+\n+ getComparatorResult(\n+ comparatorType,\n+ comparatorValue,\n+ actualValue,\n+ comparatorValueDatatype\n+ ) {\n+ if (\n+ comparatorType === 'includes' ||\n+ comparatorType === 'does_not_include'\n+ ) {\n+ comparatorValueDatatype = 'list';\n+ }\n+ if (comparatorValueDatatype === 'bool') {\n+ comparatorValue = comparatorValue === 'true';\n+ }\n+\n+ const cValue = this.getCastValue(\n+ comparatorValueDatatype,\n+ comparatorValue\n+ );\n+\n+ switch (comparatorType) {\n+ case 'is':\n+ case 'is_not':\n+ // Datatype might be num, bool, str, re (regular expression)\n+ const isMatch =\n+ comparatorValueDatatype === 're'\n+ ? cValue.test(actualValue)\n+ : cValue === actualValue;\n+ return comparatorType === 'is' ? isMatch : !isMatch;\n+ case 'includes':\n+ case 'does_not_include':\n+ const isIncluded = cValue.includes(actualValue);\n+ return comparatorType === 'includes' ? isIncluded : !isIncluded;\n+ case 'cont':\n+ return (actualValue + '').indexOf(cValue) !== -1;\n+ case 'greater_than': // here for backwards compatibility\n+ case '>':\n+ case 'gt':\n+ return actualValue > cValue;\n+ case '>=':\n+ case 'gte':\n+ return actualValue >= cValue;\n+ case 'less_than': // here for backwards compatibility\n+ case '<':\n+ case 'lt':\n+ return actualValue < cValue;\n+ case '<=':\n+ case 'lte':\n+ return actualValue <= cValue;\n+ }\n+ }\n}\nconst _internals = {\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "name: { value: \"\" },\nserver: { value: \"\", type: \"server\", required: true },\nhalt_if: { value: \"\" },\n+ halt_if_type: { value: \"str\" },\n+ halt_if_compare: { value: \"is\" },\noverride_topic: { value: true },\noverride_payload: { value: true },\noverride_data: { value: true },\n})\n.fail(err => RED.notify(err.responseText, \"error\"));\n}\n+\n+ if (this.state_type === undefined) {\n+ $(\"#node-input-state_type\").val(\"str\");\n+ }\n+\n+ const defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\n+ const $halt_if_compare = $(\"#node-input-halt_if_compare\");\n+ const $halt_if = $(\"#node-input-halt_if\");\n+ const $halt_if_help = $(\"#halt_if_help\");\n+\n+ if (this.halt_if_compare === undefined) {\n+ $(\"#node-input-halt_if_compare\").val(\"is\");\n+ }\n+\n+ $halt_if.typedInput({\n+ default: \"str\",\n+ types: defaultTypes,\n+ typeField: \"#node-input-halt_if_type\"\n+ });\n+ $halt_if.typedInput(\"width\", \"74.5%\");\n+\n+ $halt_if_compare.change(function(e) {\n+ let types = defaultTypes;\n+ $halt_if_help.hide();\n+\n+ switch (e.target.value) {\n+ case \"is\":\n+ case \"is_not\":\n+ break;\n+ case \"lt\":\n+ case \"lte\":\n+ case \"gt\":\n+ case \"gte\":\n+ types = [\"num\"];\n+ break;\n+ case \"includes\":\n+ case \"does_not_include\":\n+ $halt_if_help.show();\n+ types = [\"str\"];\n+ break;\n+ }\n+ $halt_if.typedInput(\"types\", types);\n+ });\n+ $halt_if_compare.trigger(\"change\");\n},\noneditsave: function() {\nthis.entity_id = $(\"#entity_id\").val();\n</div>\n<div class=\"form-row\">\n- <label for=\"node-input-halt_if\"><i class=\"fa fa-hand-paper-o\"></i> Halt If</label>\n- <input type=\"text\" id=\"node-input-halt_if\" placeholder=\"off\" />\n+ <label for=\"node-input-halt_if_compare\"><i class=\"fa fa-hand-paper-o\"></i> Halt if State</label>\n+ <div style=\"width: 70%;display: inline-block;\">\n+ <select type=\"text\" id=\"node-input-halt_if_compare\" style=\"width: auto;\">\n+ <option value=\"is\">is</option>\n+ <option value=\"is_not\">is not</option>\n+ <option value=\"lt\"><</option>\n+ <option value=\"lte\"><=</option>\n+ <option value=\"gt\">></option>\n+ <option value=\"gte\">>=</option>\n+ <option value=\"includes\">in</option>\n+ <option value=\"does_not_include\">not in</option>\n+ </select>\n+ <input type=\"text\" id=\"node-input-halt_if\" />\n+ </div>\n+ <input type=\"hidden\" id=\"node-input-halt_if_type\" />\n</div>\n+ <span id=\"halt_if_help\" style=\"inline-block;margin-left: 210px;\">^ Comma delimited string</span>\n<div class=\"form-row\">\n<label for=\"node-input-state_type\"><i class=\"fa fa-tint\"></i> State Type</label>\n<dd>Latest current state object received from home assistant</dd>\n<dt>data.state <span class=\"property-type\">string</span></dt>\n- <dd>Main attribute state value, examples: 'on', 'off', 'home', 'open', 'closed', etc...</dd>\n+ <dd>Main attribute state value, examples: 'on', 'off', 'home', 'open', 'closed', etc...</dd>\n<dt>data.entity_id <span class=\"property-type\">string</span></dt>\n<dd>The entity to which this state belongs</dd>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -7,6 +7,8 @@ module.exports = function(RED) {\nconfig: {\nname: {},\nhalt_if: {},\n+ halt_if_type: {},\n+ halt_if_compare: {},\noverride_topic: {},\noverride_payload: {},\noverride_data: {},\n@@ -72,7 +74,13 @@ module.exports = function(RED) {\nconst shouldHaltIfState =\nthis.nodeConfig.halt_if &&\n- currentState.state === this.nodeConfig.halt_if;\n+ this.getComparatorResult(\n+ this.nodeConfig.halt_if_compare,\n+ this.nodeConfig.halt_if,\n+ currentState.state,\n+ this.nodeConfig.halt_if_type\n+ );\n+\nif (shouldHaltIfState) {\nconst debugMsg = `Get current state: halting processing due to current state of ${entity_id} matches \"halt if state\" option`;\nthis.debug(debugMsg);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "server: { value: \"\", type: \"server\", required: true },\nentityidfilter: { value: \"\", required: true },\nentityidfiltertype: { value: \"substring\" },\n- haltifstate: { value: \"\" },\noutputinitially: { value: false },\n- state_type: { value: \"str\" }\n+ state_type: { value: \"str\" },\n+ haltifstate: { value: \"\" },\n+ halt_if_type: {},\n+ halt_if_compare: {}\n},\ninputs: 0,\noutputs: 1,\n};\n$server.change(() => setupAutocomplete(this));\n+\n+ if (this.state_type === undefined) {\n+ $(\"#node-input-state_type\").val(\"str\");\n+ }\n+\n+ const defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\n+ const $halt_if_compare = $(\"#node-input-halt_if_compare\");\n+ const $haltifstate = $(\"#node-input-haltifstate\");\n+ const $halt_if_help = $(\"#halt_if_help\");\n+\n+ if (this.halt_if_compare === undefined) {\n+ $(\"#node-input-halt_if_compare\").val(\"is\");\n+ }\n+\n+ $haltifstate.typedInput({\n+ default: \"str\",\n+ types: defaultTypes,\n+ typeField: \"#node-input-halt_if_type\"\n+ });\n+ $haltifstate.typedInput(\"width\", \"74.5%\");\n+\n+ $halt_if_compare.change(function(e) {\n+ let types = defaultTypes;\n+ $halt_if_help.hide();\n+\n+ switch (e.target.value) {\n+ case \"is\":\n+ case \"is_not\":\n+ break;\n+ case \"lt\":\n+ case \"lte\":\n+ case \"gt\":\n+ case \"gte\":\n+ types = [\"num\"];\n+ break;\n+ case \"includes\":\n+ case \"does_not_include\":\n+ $halt_if_help.show();\n+ types = [\"str\"];\n+ break;\n+ }\n+ $haltifstate.typedInput(\"types\", types);\n+ });\n+ $halt_if_compare.trigger(\"change\");\n},\noneditsave: function() {\nthis.entityidfilter = $(\"#node-input-entityidfilter\").val();\n</select>\n</div>\n+\n<div class=\"form-row\">\n- <label for=\"node-input-haltifstate\"><i class=\"fa fa-hand-paper-o\"></i> Halt If State</label>\n+ <label for=\"node-input-haltifstate\"><i class=\"fa fa-hand-paper-o\"></i> Halt if State</label>\n+ <div style=\"width: 71%;display: inline-block;\">\n+ <select type=\"text\" id=\"node-input-halt_if_compare\" style=\"width: auto;\">\n+ <option value=\"is\">is</option>\n+ <option value=\"is_not\">is not</option>\n+ <option value=\"lt\"><</option>\n+ <option value=\"lte\"><=</option>\n+ <option value=\"gt\">></option>\n+ <option value=\"gte\">>=</option>\n+ <option value=\"includes\">in</option>\n+ <option value=\"does_not_include\">not in</option>\n+ </select>\n<input type=\"text\" id=\"node-input-haltifstate\" />\n</div>\n+ <input type=\"hidden\" id=\"node-input-halt_if_type\" />\n+ </div>\n+ <span id=\"halt_if_help\" style=\"inline-block;margin-left: 210px;\">^ Comma delimited string</span>\n<div class=\"form-row\">\n<label for=\"node-input-state_type\"><i class=\"fa fa-tint\"></i> State Type</label>\n</script>\n<script type=\"text/x-red\" data-help-name=\"server-state-changed\">\n- <p class=\"ha-description\">Outputs 'state_changed' event types sent from Home Assistant</p>\n+ <p class=\"ha-description\">Outputs 'state_changed' event types sent from Home Assistant</p>\n<p class=\"ha-subdescription\">The autocomplete will open to allow easier selection in the case you want a specific entity however the actual match is a substring match so no validation is done</p>\n<dt>State Type<span class=\"property-type\">string</span></dt>\n<dd>Convert the state of the entity to the selected type. Boolean will be convert to true based on if the string is equial by default to (y|yes|true|on|home|open). Original value stored in msg.data.original_state</dd>\n+\n+ <dt>Output Initially<span class=\"property-type\">boolean</span></dt>\n+ <dd>Output once on startup/deploy then on each interval</dd>\n</dl>\n<h3>Output Object:</h3>\n<dd>CSV substring matches for entity_id field</dd>\n<dt>payload<span class=\"property-type\">string|number|boolean</span></dt>\n- <dd>event.new_state.state (e.g.: 'on', 'off', 88.5, 'home', 'not_home')</dd>\n+ <dd>event.new_state.state (e.g.: 'on', 'off', 88.5, 'home', 'not_home')</dd>\n<dt>data<span class=\"property-type\">json</span></dt>\n<dd>original event object from homeassistant</dd>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -16,6 +16,8 @@ module.exports = function(RED) {\nentityidfiltertype: {},\nhaltIfState: nodeDef =>\nnodeDef.haltifstate ? nodeDef.haltifstate.trim() : null,\n+ halt_if_type: {},\n+ halt_if_compare: {},\noutputinitially: {},\nstate_type: {}\n}\n@@ -77,10 +79,18 @@ module.exports = function(RED) {\n);\n}\n- const shouldHaltIfState = this.shouldHaltIfState(event);\nconst shouldIncludeEvent = this.shouldIncludeEvent(entity_id);\nif (shouldIncludeEvent) {\n+ const shouldHaltIfState =\n+ this.nodeConfig.haltIfState &&\n+ this.getComparatorResult(\n+ this.nodeConfig.halt_if_compare,\n+ this.nodeConfig.haltIfState,\n+ event.new_state.state,\n+ this.nodeConfig.halt_if_type\n+ );\n+\nif (shouldHaltIfState) {\nthis.debug(\n'flow halted due to \"halt if state\" setting'\n@@ -150,13 +160,6 @@ module.exports = function(RED) {\n}\n}\n- shouldHaltIfState(haEvent, haltIfState) {\n- if (!this.nodeConfig.haltIfState) return false;\n- const shouldHalt =\n- this.nodeConfig.haltIfState === haEvent.new_state.state;\n- return shouldHalt;\n- }\n-\nshouldIncludeEvent(entityId) {\nif (!this.nodeConfig.entityidfilter) return true;\nconst filter = this.nodeConfig.entityidfilter;\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "value: \"\",\nrequired: true\n},\n- state_type: { value: \"str\" }\n+ state_type: { value: \"str\" },\n+ halt_if: { value: \"\" },\n+ halt_if_type: { value: \"str\" },\n+ halt_if_compare: { value: \"is\" }\n},\noneditprepare: function() {\nconst $entityIdField = $(\"#entity_id\");\n})\n.fail(err => RED.notify(err.responseText, \"error\"));\n}\n+\n+ if (this.state_type === undefined) {\n+ $(\"#node-input-state_type\").val(\"str\");\n+ }\n+\n+ const defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\n+ const $halt_if_compare = $(\"#node-input-halt_if_compare\");\n+ const $halt_if = $(\"#node-input-halt_if\");\n+ const $halt_if_help = $(\"#halt_if_help\");\n+\n+ if (this.halt_if_compare === undefined) {\n+ $(\"#node-input-halt_if_compare\").val(\"is\");\n+ }\n+\n+ $halt_if.typedInput({\n+ default: \"str\",\n+ types: defaultTypes,\n+ typeField: \"#node-input-halt_if_type\"\n+ });\n+ $halt_if.typedInput(\"width\", \"74.5%\");\n+\n+ $halt_if_compare.change(function(e) {\n+ let types = defaultTypes;\n+ $halt_if_help.hide();\n+\n+ switch (e.target.value) {\n+ case \"is\":\n+ case \"is_not\":\n+ break;\n+ case \"lt\":\n+ case \"lte\":\n+ case \"gt\":\n+ case \"gte\":\n+ types = [\"num\"];\n+ break;\n+ case \"includes\":\n+ case \"does_not_include\":\n+ $halt_if_help.show();\n+ types = [\"str\"];\n+ break;\n+ }\n+ $halt_if.typedInput(\"types\", types);\n+ });\n+ $halt_if_compare.trigger(\"change\");\n},\noneditsave: function() {\nthis.entity_id = $(\"#entity_id\").val();\n</div>\n<div class=\"form-row\">\n- <label for=\"node-input-updateinterval\"><i class=\"fa fa-hand-paper-o\"></i> Update Interval</label>\n+ <label for=\"node-input-updateinterval\"><i class=\"fa fa-clock-o\"></i> Update Interval</label>\n<input type=\"text\" id=\"node-input-updateinterval\" placeholder=\"10\"/>\n</div>\n+ <div class=\"form-row\">\n+ <label for=\"node-input-halt_if_compare\"><i class=\"fa fa-hand-paper-o\"></i> Halt if State</label>\n+ <div style=\"width: 70%;display: inline-block;\">\n+ <select type=\"text\" id=\"node-input-halt_if_compare\" style=\"width: auto;\">\n+ <option value=\"is\">is</option>\n+ <option value=\"is_not\">is not</option>\n+ <option value=\"lt\"><</option>\n+ <option value=\"lte\"><=</option>\n+ <option value=\"gt\">></option>\n+ <option value=\"gte\">>=</option>\n+ <option value=\"includes\">in</option>\n+ <option value=\"does_not_include\">not in</option>\n+ </select>\n+ <input type=\"text\" id=\"node-input-halt_if\" />\n+ </div>\n+ <input type=\"hidden\" id=\"node-input-halt_if_type\" />\n+ </div>\n+ <span id=\"halt_if_help\" style=\"inline-block;margin-left: 210px;\">^ Comma delimited string</span>\n+\n<div class=\"form-row\">\n<label for=\"node-input-state_type\"><i class=\"fa fa-tint\"></i> State Type</label>\n<select type=\"text\" id=\"node-input-state_type\" style=\"width: auto;\">\n<dt>Update Interval<span class=\"property-type\">number</span></dt>\n<dd>Number of seconds between checking / sending updates</dd>\n+ <dt>Half If<span class=\"property-type\">string</span></dt>\n+ <dd>If the new_state === this setting then skip sending</dd>\n+\n<dt>State Type<span class=\"property-type\">string</span></dt>\n<dd>Convert the state of the entity to the selected type. Boolean will be convert to true based on if the string is equial by default to (y|yes|true|on|home|open). Original value stored in msg.data.original_state</dd>\n<h3>Details</h3>\n<p>Polls for state at regular intervals, optionally also outputing at start and when state changes. Useful for either alerts for non-communicating devices (time since change > 1 day for example) or dashboard graphs with consistent interval charts</p>\n- <p>NOTE: The last changed calculation is based on homeassistant's <code>last_changed</code> property so anything that changes that field will result in your last changed time outputted here to be changed.</p>\n+ <p>NOTE: The last changed calculation is based on homeassistant's <code>last_changed</code> property so anything that changes that field will result in your last changed time outputted here to be changed.</p>\n<h3>References</h3>\n<ul>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -9,7 +9,10 @@ module.exports = function(RED) {\nupdateinterval: {},\noutputinitially: {},\noutputonchanged: {},\n- state_type: {}\n+ state_type: {},\n+ halt_if: {},\n+ halt_if_type: {},\n+ halt_if_compare: {}\n}\n};\n@@ -100,6 +103,31 @@ module.exports = function(RED) {\n);\n}\n+ const shouldHaltIfState =\n+ this.nodeConfig.halt_if &&\n+ this.getComparatorResult(\n+ this.nodeConfig.halt_if_compare,\n+ this.nodeConfig.halt_if,\n+ pollState.state,\n+ this.nodeConfig.halt_if_type\n+ );\n+\n+ if (shouldHaltIfState) {\n+ const debugMsg = `poll state: halting processing due to current state of ${\n+ pollState.entity_id\n+ } matches \"halt if state\" option`;\n+ this.debug(debugMsg);\n+ this.debugToClient(debugMsg);\n+ this.status({\n+ fill: 'red',\n+ shape: 'ring',\n+ text: `${\n+ pollState.state\n+ } at: ${this.getPrettyDate()}`\n+ });\n+ return null;\n+ }\n+\nthis.status({\nfill: 'green',\nshape: 'dot',\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "</script>\n<script type=\"text/x-red\" data-help-name=\"trigger-state\">\n- <p>Advanced version of 'server:state-changed' node</p>\n+ <p>Advanced version of 'server:state-changed' node</p>\n<h3>Inputs</h3>\n<dl class=\"message-properties\">\n<dt class=\"optional\">\n[payload|msg] <span class=\"property-type\">string|object</span>\n</dt>\n- <dd>If incoming payload or message is a string and equal to 'enable' or 'disable' then set the node accordingly.</dd>\n+ <dd>If incoming payload or message is a string and equal to 'enable' or 'disable' then set the node accordingly.</dd>\n+\n+ <dt>Output Initially<span class=\"property-type\">boolean</span></dt>\n+ <dd>Output once on startup/deploy then on each interval</dd>\n</dl>\n<h3>Outputs</h3>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -331,46 +331,6 @@ module.exports = function(RED) {\nreturn targetData;\n}\n- /* eslint-disable indent */\n- getComparatorResult(\n- comparatorType,\n- comparatorValue,\n- actualValue,\n- comparatorValueDatatype\n- ) {\n- const cValue = this.getCastValue(\n- comparatorValueDatatype,\n- comparatorValue\n- );\n-\n- switch (comparatorType) {\n- case 'is':\n- case 'is_not':\n- // Datatype might be num, bool, str, re (regular expression)\n- const isMatch =\n- comparatorValueDatatype === 're'\n- ? cValue.test(actualValue)\n- : cValue === actualValue;\n- return comparatorType === 'is' ? isMatch : !isMatch;\n- case 'includes':\n- case 'does_not_include':\n- const isIncluded = cValue.includes(actualValue);\n- return comparatorType === 'includes'\n- ? isIncluded\n- : !isIncluded;\n- case 'greater_than': // here for backwards compatibility\n- case '>':\n- return actualValue > cValue;\n- case '>=':\n- return actualValue >= cValue;\n- case 'less_than': // here for backwards compatibility\n- case '<':\n- return actualValue < cValue;\n- case '<=':\n- return actualValue <= cValue;\n- }\n- }\n-\ngetOutputMessage(\n{ output, comparatorMatched, actualValue },\neventMessage\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added a more comprehensive half if logic to serveral nodes |
748,234 | 08.12.2018 12:47:01 | 28,800 | f43287cc1185a8a1bf41bddc1ae420dd8179d2e1 | Changed the way autocomplete queries for states and services
to allow for more than one HA server and to populate the correct values.
Fixes | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "const selectedServer = $server.val();\nif (node.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nsetServicesAndDomains(node);\n- $.get(`homeassistant/entities`)\n+ $.get(`homeassistant/${node.server}/entities`)\n.done(entities => {\nthis.availableEntities = JSON.parse(entities);\n// Calls the custom api backend defined in the config-server.js node\nfunction setServicesAndDomains(node) {\n- return $.get(`homeassistant/services`)\n+ return $.get(`homeassistant/${node.server}/services`)\n.then(services => {\nnode.allServices = JSON.parse(services);\nnode.allDomains = Object.keys(node.allServices);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -5,18 +5,30 @@ module.exports = function(RED) {\nconst httpHandlers = {\ngetEntities: function(req, res, next) {\n+ if (!this.homeAssistant) {\n+ return res.json('[]');\n+ }\n+\nreturn this.homeAssistant\n.getEntities()\n.then(states => res.json(JSON.stringify(states)))\n.catch(e => this.error(e.message));\n},\ngetStates: function(req, res, next) {\n+ if (!this.homeAssistant) {\n+ return res.json('[]');\n+ }\n+\nreturn this.homeAssistant\n.getStates()\n.then(states => res.json(JSON.stringify(states)))\n.catch(e => this.error(e.message));\n},\ngetServices: function(req, res, next) {\n+ if (!this.homeAssistant) {\n+ return res.json('[]');\n+ }\n+\nreturn this.homeAssistant\n.getServices()\n.then(services => res.json(JSON.stringify(services)))\n@@ -56,17 +68,17 @@ module.exports = function(RED) {\n}\nthis.RED.httpAdmin.get(\n- '/homeassistant/entities',\n+ `/homeassistant/${this.id}/entities`,\nRED.auth.needsPermission('server.read'),\nhttpHandlers.getEntities.bind(this)\n);\nthis.RED.httpAdmin.get(\n- '/homeassistant/states',\n+ `/homeassistant/${this.id}/states`,\nRED.auth.needsPermission('server.read'),\nhttpHandlers.getStates.bind(this)\n);\nthis.RED.httpAdmin.get(\n- '/homeassistant/services',\n+ `/homeassistant/${this.id}/services`,\nRED.auth.needsPermission('server.read'),\nhttpHandlers.getServices.bind(this)\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/entities`)\n+ $.get(`homeassistant/${NODE.server}/entities`)\n.done(entities => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "// A home assistant server is selected in the node config\nif (node.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/entities`)\n+ $.get(`homeassistant/${node.server}/entities`)\n.done(entities => {\nnode.availableEntities = JSON.parse(entities);\n$entityidfilter.autocomplete({\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/entities`)\n+ $.get(`homeassistant/${NODE.server}/entities`)\n.done(entities => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "// A home assistant server is selected in the node config\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/entities`)\n+ $.get(`homeassistant/${NODE.server}/entities`)\n.done(entities => {\nNODE.availableEntities = JSON.parse(entities);\n$entityid.autocomplete({\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Changed the way autocomplete queries for states and services
to allow for more than one HA server and to populate the correct values.
Fixes #49 |
748,234 | 08.12.2018 18:05:02 | 28,800 | d8b69033796536376913df9f0360c3623c3009a2 | Changelog and Readme changes | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [0.4.0] 2018.12.8\n+\n+### New Features\n+\n+- Ability to cast the `state` of event entities and payload to String/Number/Boolean\n+- Changed `halt if` logic to be able to use different comparators to check the state for current-state, and events-state-change nodes\n+- Poll-state now has `halt if` logic\n+\n+### Added\n+\n+- Added status times for success and error messages for the `get template` node ([@jonathanadams](https://github.com/jonathanadams))\n+- Added timeSinceChangedMs to current-state, events-state, and trigger-state nodes `entity.timeSinceChangedMs`\n+\n+### Fixed\n+\n+- Autocomplete to use the correct entities/services if more than one server is setup ([#49](https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues/49))\n+\n## [0.3.1] 2018.11.18\n### Added\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "[](https://travis-ci.com/zachowj/node-red-contrib-home-assistant-websocket) [](https://coveralls.io/github/zachowj/node-red-contrib-home-assistant-websocket?branch=master)\n+[](https://buymeacoff.ee/zachowj)\n+\nVarious nodes to assist in setting up automation using [node-red](https://nodered.org/) communicating with [Home Assistant](https://home-assistant.io/).\n## Project status\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Changelog and Readme changes |
748,234 | 09.12.2018 10:25:48 | 28,800 | dc46a91f5d390d687e53af43dc15457040918cce | Make sure halt if logic and default values and version bump | [
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -72,6 +72,11 @@ module.exports = function(RED) {\n);\n}\n+ this.nodeConfig.halt_if_compare =\n+ this.nodeConfig.halt_if_compare || 'is';\n+ this.nodeConfig.halt_if_type =\n+ this.nodeConfig.halt_if_type || 'str';\n+\nconst shouldHaltIfState =\nthis.nodeConfig.halt_if &&\nthis.getComparatorResult(\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -82,6 +82,11 @@ module.exports = function(RED) {\nconst shouldIncludeEvent = this.shouldIncludeEvent(entity_id);\nif (shouldIncludeEvent) {\n+ this.nodeConfig.halt_if_compare =\n+ this.nodeConfig.halt_if_compare || 'is';\n+ this.nodeConfig.halt_if_type =\n+ this.nodeConfig.halt_if_type || 'str';\n+\nconst shouldHaltIfState =\nthis.nodeConfig.haltIfState &&\nthis.getComparatorResult(\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -103,6 +103,11 @@ module.exports = function(RED) {\n);\n}\n+ this.nodeConfig.halt_if_compare =\n+ this.nodeConfig.halt_if_compare || 'is';\n+ this.nodeConfig.halt_if_type =\n+ this.nodeConfig.halt_if_type || 'str';\n+\nconst shouldHaltIfState =\nthis.nodeConfig.halt_if &&\nthis.getComparatorResult(\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.4.0\",\n+ \"version\": \"0.4.1\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Make sure halt if logic and default values and version bump |
748,234 | 09.12.2018 10:27:10 | 28,800 | dddbde8a765df30d337f829b3aad70b0ab70856b | changelog version bump | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [0.4.1] 2018.12.9\n+\n+### Fixed\n+\n+- Make sure `halt if` logic has default starting values\n+\n## [0.4.0] 2018.12.8\n### New Features\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | changelog version bump |
748,234 | 09.12.2018 14:35:19 | 28,800 | 5ca161c620cf948a375dc1a334f8f60892f74649 | A fix to make sure the server id is present for the autocomplete call
Fixes | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "// If a server is selected populate dropdowns\nconst selectedServer = $server.val();\n+ const serverId = node.server || selectedServer;\nif (node.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nsetServicesAndDomains(node);\n- $.get(`homeassistant/${node.server}/entities`)\n+ $.get(`homeassistant/${serverId}/entities`)\n.done(entities => {\nthis.availableEntities = JSON.parse(entities);\n// Calls the custom api backend defined in the config-server.js node\nfunction setServicesAndDomains(node) {\n- return $.get(`homeassistant/${node.server}/services`)\n+ return $.get(`homeassistant/${serverId}/services`)\n.then(services => {\nnode.allServices = JSON.parse(services);\nnode.allDomains = Object.keys(node.allServices);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/${NODE.server}/entities`)\n+ const serverId = NODE.server || selectedServer;\n+ $.get(`homeassistant/${serverId}/entities`)\n.done(entities => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "// A home assistant server is selected in the node config\nif (node.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/${node.server}/entities`)\n+ const serverId = node.server || selectedServer;\n+ $.get(`homeassistant/${serverId}/entities`)\n.done(entities => {\nnode.availableEntities = JSON.parse(entities);\n$entityidfilter.autocomplete({\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/${NODE.server}/entities`)\n+ const serverId = NODE.server || selectedServer;\n+ $.get(`homeassistant/${serverId}/entities`)\n.done(entities => {\nthis.availableEntities = JSON.parse(entities);\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "// A home assistant server is selected in the node config\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n- $.get(`homeassistant/${NODE.server}/entities`)\n+ const serverId = NODE.server || selectedServer;\n+ $.get(`homeassistant/${serverId}/entities`)\n.done(entities => {\nNODE.availableEntities = JSON.parse(entities);\n$entityid.autocomplete({\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | A fix to make sure the server id is present for the autocomplete call
Fixes #50 |
748,234 | 10.12.2018 07:24:19 | 28,800 | b27c565775185c4cdf6d7da6d5c095a12e07f6b0 | Make Server Id is not empty when performing autocomplete ajax call for get history node | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [0.4.3] 2018.12.9\n+\n+### Fixed\n+\n+- Make Server Id is not empty when performing autocomplete ajax call for `get history` node\n+\n## [0.4.2] 2018.12.9\n### Fixed\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n\"description\": \"Node-RED integration with Home Assistant through websocket and REST API\",\n- \"version\": \"0.4.2\",\n+ \"version\": \"0.4.3\",\n\"homepage\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket\",\n\"bugs\": {\n\"url\": \"https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Make Server Id is not empty when performing autocomplete ajax call for get history node |
748,234 | 10.12.2018 16:59:19 | 28,800 | d261b993dcd3d5bf3578c6428b6ca9ec1f1bd192 | Added secondary outputs for 'halt if' logic
current-state, events-state, and poll-state nodes | [
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "override_payload: { value: true },\noverride_data: { value: true },\nentity_id: { value: \"\" },\n- state_type: { value: \"str\" }\n+ state_type: { value: \"str\" },\n+ outputs: { value: 1 }\n},\noneditprepare: function() {\nconst $entityIdField = $(\"#entity_id\");\n},\noneditsave: function() {\nthis.entity_id = $(\"#entity_id\").val();\n+ const outputs = $(\"#node-input-halt_if\").val() ? 2 : 1;\n+ $(\"#node-input-outputs\").val(outputs);\n}\n});\n</script>\n<div class=\"form-row\">\n<label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n<input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n+ <input type=\"hidden\" id=\"node-input-outputs\"/>\n</div>\n<div class=\"form-row\">\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -86,18 +86,6 @@ module.exports = function(RED) {\nthis.nodeConfig.halt_if_type\n);\n- if (shouldHaltIfState) {\n- const debugMsg = `Get current state: halting processing due to current state of ${entity_id} matches \"halt if state\" option`;\n- this.debug(debugMsg);\n- this.debugToClient(debugMsg);\n- this.status({\n- fill: 'red',\n- shape: 'ring',\n- text: `${currentState.state} at: ${this.getPrettyDate()}`\n- });\n- return null;\n- }\n-\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\nconst override_topic = this.nodeConfig.override_topic !== false;\n@@ -107,12 +95,24 @@ module.exports = function(RED) {\nif (override_payload) message.payload = currentState.state;\nif (override_data) message.data = currentState;\n+ if (shouldHaltIfState) {\n+ const debugMsg = `Get current state: halting processing due to current state of ${entity_id} matches \"halt if state\" option`;\n+ this.debug(debugMsg);\n+ this.debugToClient(debugMsg);\n+ this.status({\n+ fill: 'red',\n+ shape: 'ring',\n+ text: `${currentState.state} at: ${this.getPrettyDate()}`\n+ });\n+ this.node.send([null, message]);\n+ } else {\nthis.status({\nfill: 'green',\nshape: 'dot',\ntext: `${currentState.state} at: ${this.getPrettyDate()}`\n});\n- this.node.send(message);\n+ this.node.send([message, null]);\n+ }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "state_type: { value: \"str\" },\nhaltifstate: { value: \"\" },\nhalt_if_type: {},\n- halt_if_compare: {}\n+ halt_if_compare: {},\n+ outputs: { value: 1 }\n},\ninputs: 0,\noutputs: 1,\n},\noneditsave: function() {\nthis.entityidfilter = $(\"#node-input-entityidfilter\").val();\n+ const outputs = $(\"#node-input-haltifstate\").val() ? 2 : 1;\n+ $(\"#node-input-outputs\").val(outputs);\n}\n});\n</script>\n<div class=\"form-row\">\n<label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n<input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n+ <input type=\"hidden\" id=\"node-input-outputs\"/>\n</div>\n<!-- Server -->\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -96,6 +96,12 @@ module.exports = function(RED) {\nthis.nodeConfig.halt_if_type\n);\n+ const msg = {\n+ topic: entity_id,\n+ payload: event.new_state.state,\n+ data: event\n+ };\n+\nif (shouldHaltIfState) {\nthis.debug(\n'flow halted due to \"halt if state\" setting'\n@@ -108,15 +114,9 @@ module.exports = function(RED) {\n} at: ${this.getPrettyDate()}`\n});\n- return null;\n+ return this.send([null, msg]);\n}\n- const msg = {\n- topic: entity_id,\n- payload: event.new_state.state,\n- data: event\n- };\n-\nthis.status({\nfill: 'green',\nshape: 'dot',\n@@ -139,7 +139,7 @@ module.exports = function(RED) {\n}, new_state: ${event.new_state.state}`\n);\n- return this.send(msg);\n+ return this.send([msg, null]);\n}\nreturn null;\n} catch (e) {\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "defaults: {\nname: { value: \"\" },\nserver: { value: \"\", type: \"server\", required: true },\n- updateinterval: { value: \"\", validate: v => !isNaN(v) },\n+ updateinterval: { value: \"10\", validate: v => !isNaN(v) },\noutputinitially: { value: false },\noutputonchanged: { value: false },\nentity_id: {\nstate_type: { value: \"str\" },\nhalt_if: { value: \"\" },\nhalt_if_type: { value: \"str\" },\n- halt_if_compare: { value: \"is\" }\n+ halt_if_compare: { value: \"is\" },\n+ outputs: { value: 1 }\n},\noneditprepare: function() {\nconst $entityIdField = $(\"#entity_id\");\n},\noneditsave: function() {\nthis.entity_id = $(\"#entity_id\").val();\n+ const outputs = $(\"#node-input-halt_if\").val() ? 2 : 1;\n+ $(\"#node-input-outputs\").val(outputs);\n}\n});\n</script>\n<div class=\"form-row\">\n<label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n<input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n+ <input type=\"hidden\" id=\"node-input-outputs\"/>\n</div>\n<div class=\"form-row\">\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.js",
"new_path": "nodes/poll-state/poll-state.js",
"diff": "@@ -117,6 +117,12 @@ module.exports = function(RED) {\nthis.nodeConfig.halt_if_type\n);\n+ const msg = {\n+ topic: this.nodeConfig.entity_id,\n+ payload: pollState.state,\n+ data: pollState\n+ };\n+\nif (shouldHaltIfState) {\nconst debugMsg = `poll state: halting processing due to current state of ${\npollState.entity_id\n@@ -130,7 +136,7 @@ module.exports = function(RED) {\npollState.state\n} at: ${this.getPrettyDate()}`\n});\n- return null;\n+ return this.send([null, msg]);\n}\nthis.status({\n@@ -139,11 +145,7 @@ module.exports = function(RED) {\ntext: `${pollState.state} at: ${this.getPrettyDate()}`\n});\n- this.send({\n- topic: this.nodeConfig.entity_id,\n- payload: pollState.state,\n- data: pollState\n- });\n+ this.send([msg, null]);\n} else {\nthis.warn(\n`could not calculate time since changed for entity_id \"${\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added secondary outputs for 'halt if' logic
current-state, events-state, and poll-state nodes |
748,234 | 11.12.2018 12:43:56 | 28,800 | 1de0c0e57260d17474f2358a54099a3dea1deb2e | Refactored the UI for `halt if` logic into an external file and loaded on demand | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [Unreleased]\n+\n+### New Features\n+\n+- Added secondary outputs for `halt if` logic for current-state, events-state, and poll-state nodes\n+\n+### Added\n+\n+- Added Spinner UI element to poll-state node\n+\n+### Changed\n+\n+- Refactored the UI for `halt if` logic into an external file and loaded on demand\n+\n## [0.4.3] 2018.12.9\n### Fixed\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "nodes/_static/haltif.js",
"diff": "+const $ = window.jQuery;\n+const defaultTypes = ['str', 'num', 'bool', 're'];\n+\n+const resizeHaltIf = function(input) {\n+ const $clearHaltIf = $('#clearHaltIf');\n+ let width =\n+ input.parent('div').width() -\n+ $('#node-input-halt_if_compare').width() -\n+ 20.5;\n+\n+ if ($clearHaltIf.is(':visible')) {\n+ width = width - $clearHaltIf.outerWidth(true) - 4;\n+ }\n+\n+ input.typedInput('width', width);\n+};\n+\n+window.resizeHaltIf = resizeHaltIf;\n+\n+window.setupHaltIf = function(input, compare) {\n+ const $input = $(input);\n+ const $compare = $(compare);\n+ const $help = $('#halt_if_help');\n+\n+ $input.after(\n+ ' <a id=\"clearHaltIf\" class=\"editor-button\"><i class=\"fa fa-remove\"></i></a>'\n+ );\n+ const $clearHaltIf = $('#clearHaltIf');\n+\n+ $input.typedInput({\n+ default: 'str',\n+ types: defaultTypes,\n+ typeField: '#node-input-halt_if_type'\n+ });\n+\n+ $compare.change(function(e) {\n+ let types = defaultTypes;\n+ $help.hide();\n+\n+ switch (e.target.value) {\n+ case 'is':\n+ case 'is_not':\n+ break;\n+ case 'lt':\n+ case 'lte':\n+ case 'gt':\n+ case 'gte':\n+ types = ['num'];\n+ break;\n+ case 'includes':\n+ case 'does_not_include':\n+ $help.show();\n+ types = ['str'];\n+ break;\n+ }\n+ $input.typedInput('types', types);\n+ });\n+\n+ $compare.trigger('change');\n+\n+ $input.on('change', function(e) {\n+ if (e.currentTarget.value) {\n+ $clearHaltIf.show();\n+ resizeHaltIf($input);\n+ }\n+ });\n+\n+ $clearHaltIf.on('click', function() {\n+ $input.typedInput('type', 'str');\n+ $input.typedInput('value', '');\n+ $(this).hide();\n+ resizeHaltIf($input);\n+ });\n+\n+ if (!$input.val()) {\n+ $clearHaltIf.hide();\n+ resizeHaltIf($input);\n+ }\n+ resizeHaltIf($input);\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "$(\"#node-input-state_type\").val(\"str\");\n}\n- const defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\n- const $halt_if_compare = $(\"#node-input-halt_if_compare\");\n- const $halt_if = $(\"#node-input-halt_if\");\n- const $halt_if_help = $(\"#halt_if_help\");\n-\nif (this.halt_if_compare === undefined) {\n$(\"#node-input-halt_if_compare\").val(\"is\");\n}\n- $halt_if.typedInput({\n- default: \"str\",\n- types: defaultTypes,\n- typeField: \"#node-input-halt_if_type\"\n- });\n- $halt_if.typedInput(\"width\", \"74.5%\");\n-\n- $halt_if_compare.change(function(e) {\n- let types = defaultTypes;\n- $halt_if_help.hide();\n-\n- switch (e.target.value) {\n- case \"is\":\n- case \"is_not\":\n- break;\n- case \"lt\":\n- case \"lte\":\n- case \"gt\":\n- case \"gte\":\n- types = [\"num\"];\n- break;\n- case \"includes\":\n- case \"does_not_include\":\n- $halt_if_help.show();\n- types = [\"str\"];\n- break;\n- }\n- $halt_if.typedInput(\"types\", types);\n+ $.getScript(\"/homeassistant/static/haltif.js\", function() {\n+ setupHaltIf(\"#node-input-halt_if\", \"#node-input-halt_if_compare\");\n});\n- $halt_if_compare.trigger(\"change\");\n},\noneditsave: function() {\nthis.entity_id = $(\"#entity_id\").val();\nconst outputs = $(\"#node-input-halt_if\").val() ? 2 : 1;\n$(\"#node-input-outputs\").val(outputs);\n+ },\n+ oneditresize: function() {\n+ $halt_if = $(\"#node-input-halt_if\");\n+ if ($halt_if.hasClass(\"red-ui-typedInput\")) {\n+ resizeHaltIf($halt_if);\n+ }\n}\n});\n</script>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "$(\"#node-input-state_type\").val(\"str\");\n}\n- const defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\n- const $halt_if_compare = $(\"#node-input-halt_if_compare\");\n- const $haltifstate = $(\"#node-input-haltifstate\");\n- const $halt_if_help = $(\"#halt_if_help\");\n-\nif (this.halt_if_compare === undefined) {\n$(\"#node-input-halt_if_compare\").val(\"is\");\n}\n- $haltifstate.typedInput({\n- default: \"str\",\n- types: defaultTypes,\n- typeField: \"#node-input-halt_if_type\"\n- });\n- $haltifstate.typedInput(\"width\", \"74.5%\");\n-\n- $halt_if_compare.change(function(e) {\n- let types = defaultTypes;\n- $halt_if_help.hide();\n-\n- switch (e.target.value) {\n- case \"is\":\n- case \"is_not\":\n- break;\n- case \"lt\":\n- case \"lte\":\n- case \"gt\":\n- case \"gte\":\n- types = [\"num\"];\n- break;\n- case \"includes\":\n- case \"does_not_include\":\n- $halt_if_help.show();\n- types = [\"str\"];\n- break;\n- }\n- $haltifstate.typedInput(\"types\", types);\n+ $.getScript(\"/homeassistant/static/haltif.js\", function() {\n+ setupHaltIf(\"#node-input-haltifstate\", \"#node-input-halt_if_compare\");\n});\n- $halt_if_compare.trigger(\"change\");\n},\noneditsave: function() {\nthis.entityidfilter = $(\"#node-input-entityidfilter\").val();\nconst outputs = $(\"#node-input-haltifstate\").val() ? 2 : 1;\n$(\"#node-input-outputs\").val(outputs);\n+ },\n+ oneditresize: function() {\n+ $halt_if = $(\"#node-input-haltifstate\");\n+ if ($halt_if.hasClass(\"red-ui-typedInput\")) {\n+ resizeHaltIf($halt_if);\n+ }\n}\n});\n</script>\n<div class=\"form-row\">\n<label for=\"node-input-haltifstate\"><i class=\"fa fa-hand-paper-o\"></i> Halt if State</label>\n- <div style=\"width: 71%;display: inline-block;\">\n+ <div style=\"width: 70%;display: inline-block;\">\n<select type=\"text\" id=\"node-input-halt_if_compare\" style=\"width: auto;\">\n<option value=\"is\">is</option>\n<option value=\"is_not\">is not</option>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": ".fail(err => RED.notify(err.responseText, \"error\"));\n}\n+ $(\"#node-input-updateinterval\").spinner({ min: 1 });\n+\nif (this.state_type === undefined) {\n$(\"#node-input-state_type\").val(\"str\");\n}\n- const defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\n- const $halt_if_compare = $(\"#node-input-halt_if_compare\");\n- const $halt_if = $(\"#node-input-halt_if\");\n- const $halt_if_help = $(\"#halt_if_help\");\n-\nif (this.halt_if_compare === undefined) {\n$(\"#node-input-halt_if_compare\").val(\"is\");\n}\n- $halt_if.typedInput({\n- default: \"str\",\n- types: defaultTypes,\n- typeField: \"#node-input-halt_if_type\"\n- });\n- $halt_if.typedInput(\"width\", \"74.5%\");\n-\n- $halt_if_compare.change(function(e) {\n- let types = defaultTypes;\n- $halt_if_help.hide();\n-\n- switch (e.target.value) {\n- case \"is\":\n- case \"is_not\":\n- break;\n- case \"lt\":\n- case \"lte\":\n- case \"gt\":\n- case \"gte\":\n- types = [\"num\"];\n- break;\n- case \"includes\":\n- case \"does_not_include\":\n- $halt_if_help.show();\n- types = [\"str\"];\n- break;\n- }\n- $halt_if.typedInput(\"types\", types);\n+ $.getScript(\"/homeassistant/static/haltif.js\", function() {\n+ setupHaltIf(\"#node-input-halt_if\", \"#node-input-halt_if_compare\");\n});\n- $halt_if_compare.trigger(\"change\");\n},\noneditsave: function() {\nthis.entity_id = $(\"#entity_id\").val();\nconst outputs = $(\"#node-input-halt_if\").val() ? 2 : 1;\n$(\"#node-input-outputs\").val(outputs);\n+ },\n+ oneditresize: function() {\n+ $halt_if = $(\"#node-input-halt_if\");\n+ if ($halt_if.hasClass(\"red-ui-typedInput\")) {\n+ resizeHaltIf($halt_if);\n+ }\n}\n});\n</script>\n<div class=\"form-row\">\n<label for=\"node-input-updateinterval\"><i class=\"fa fa-clock-o\"></i> Update Interval</label>\n- <input type=\"text\" id=\"node-input-updateinterval\" placeholder=\"10\"/>\n+ <input type=\"text\" id=\"node-input-updateinterval\" placeholder=\"10\" style=\"width: auto;\"/> <span style=\"padding-left: 5px;\">Seconds</span>\n</div>\n<div class=\"form-row\">\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Refactored the UI for `halt if` logic into an external file and loaded on demand |
748,234 | 03.12.2018 02:42:46 | 28,800 | 46a94958b0638c0a6d056827b97883f247940d90 | get-entities feature | [
{
"change_type": "MODIFY",
"old_path": "lib/base-node.js",
"new_path": "lib/base-node.js",
"diff": "@@ -286,6 +286,8 @@ class BaseNode {\ncase '<=':\ncase 'lte':\nreturn actualValue <= cValue;\n+ case 'starts_with':\n+ return actualValue.startsWith(cValue);\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "const BaseNode = require('../../lib/base-node');\n+const flatten = require('flat');\n+const uniq = require('lodash.uniq');\nmodule.exports = function(RED) {\nconst HomeAssistant = require('../../lib/node-home-assistant');\n@@ -33,6 +35,23 @@ module.exports = function(RED) {\n.getServices()\n.then(services => res.json(JSON.stringify(services)))\n.catch(e => this.error(e.message));\n+ },\n+ getProperties: function(req, res, next) {\n+ if (!this.homeAssistant) {\n+ return res.json('[]');\n+ }\n+\n+ return this.homeAssistant\n+ .getStates()\n+ .then(states => {\n+ const flat = Object.values(states).map(entity =>\n+ Object.keys(flatten(entity))\n+ );\n+ const uniqArray = uniq([].concat(...flat).sort());\n+\n+ res.json(JSON.stringify(uniqArray));\n+ })\n+ .catch(e => this.error(e.message));\n}\n};\n@@ -82,6 +101,10 @@ module.exports = function(RED) {\nRED.auth.needsPermission('server.read'),\nhttpHandlers.getServices.bind(this)\n);\n+ this.RED.httpAdmin.get(\n+ `/homeassistant/${this.id}/properties`,\n+ httpHandlers.getProperties.bind(this)\n+ );\nconst HTTP_STATIC_OPTS = {\nroot: require('path').join(__dirname, '..', '/_static'),\n@@ -112,7 +135,6 @@ module.exports = function(RED) {\nthis.homeAssistant\n.startListening()\n- // .then(this.onHaEventsOpen())\n.catch(err => this.node.error(err));\nthis.websocket.addListener(\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "nodes/get-entities/get-entities.html",
"diff": "+<script type=\"text/javascript\">\n+ RED.nodes.registerType(\"ha-get-entities\", {\n+ category: \"home_assistant\",\n+ color: \"#52C0F2\",\n+ inputs: 1,\n+ outputs: 1,\n+ icon: \"split.png\",\n+ paletteLabel: \"get entities\",\n+ label: \"get entities\",\n+ defaults: {\n+ server: { value: \"\", type: \"server\", required: true },\n+ name: { value: \"\" },\n+ rules: {\n+ value: [{ property: \"\", logic: \"is\", value: \"\", valueType: \"str\" }]\n+ },\n+ output_type: { value: \"array\" },\n+ output_empty_results: { value: false },\n+ output_location_type: { value: \"msg\" },\n+ output_location: { value: \"payload\" },\n+ output_results_count: {\n+ value: 1,\n+ validate: function(v) {\n+ if ($(\"#node-input-output_type\").val() === \"random\") {\n+ return Number.isInteger(Number(v));\n+ }\n+ return true;\n+ }\n+ }\n+ },\n+ oneditprepare: function() {\n+ const NODE = this;\n+ const $server = $(\"#node-input-server\");\n+ const utils = {\n+ setDefaultServerSelection: function() {\n+ let defaultServer;\n+ RED.nodes.eachConfig(n => {\n+ if (n.type === \"server\" && !defaultServer) defaultServer = n.id;\n+ });\n+ if (defaultServer) $server.val(defaultServer);\n+ }\n+ };\n+ const operators = [\n+ { value: \"is\", text: \"is\" },\n+ { value: \"is_not\", text: \"is not\" },\n+ { value: \"lt\", text: \"<\" },\n+ { value: \"lte\", text: \"<=\" },\n+ { value: \"gt\", text: \">\" },\n+ { value: \"gte\", text: \">=\" },\n+ { value: \"includes\", text: \"in\" },\n+ { value: \"does_not_include\", text: \"not in\" },\n+ { value: \"starts_with\", text: \"starts with\" }\n+ ];\n+ const defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\n+ const $logic = $(\"#logic\");\n+\n+ if (!NODE.server) {\n+ utils.setDefaultServerSelection();\n+ }\n+\n+ const selectedServer = $server.val();\n+ let availableProperties = [];\n+ if (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\n+ const serverId = NODE.server || selectedServer;\n+ $.get(`homeassistant/${serverId}/properties`)\n+ .done(entities => {\n+ availableProperties = JSON.parse(entities);\n+ $(\".input-property\").autocomplete({\n+ source: availableProperties,\n+ minLength: 0\n+ });\n+ })\n+ .fail(err => RED.notify(err.responseText, \"error\"));\n+ }\n+\n+ $logic.editableList({\n+ addButton: true,\n+ removable: true,\n+ height: 321,\n+ addItem: function(container, index, data) {\n+ let $row = $(\"<div />\").appendTo(container);\n+ let $row2 = $(\"<div />\", { style: \"margin-top: 10px;\" }).appendTo(\n+ container\n+ );\n+\n+ if (!data.hasOwnProperty(\"logic\")) {\n+ data.logic = \"is\";\n+ }\n+\n+ $(\"<span />\", {\n+ text: \"Property\",\n+ style: \"padding-right: 47px;\"\n+ }).appendTo($row);\n+ const $property = $(\"<input />\", {\n+ type: \"text\",\n+ class: \"input-property\",\n+ style: \"margin-left: 5px;\"\n+ })\n+ .appendTo($row)\n+ .val(data.property);\n+\n+ $property.autocomplete({\n+ source: availableProperties,\n+ minLength: 0\n+ });\n+\n+ const $logicField = $(\"<select/>\", {\n+ style: \"margin-right: 5px;width: auto;\"\n+ })\n+ .appendTo($row2)\n+ .change(function(e) {\n+ let types = defaultTypes;\n+\n+ switch (e.target.value) {\n+ case \"is\":\n+ case \"is_not\":\n+ break;\n+ case \"lt\":\n+ case \"lte\":\n+ case \"gt\":\n+ case \"gte\":\n+ types = [\"num\"];\n+ break;\n+ case \"includes\":\n+ case \"does_not_include\":\n+ case \"starts_with\":\n+ types = [\"str\"];\n+ break;\n+ }\n+ $value.typedInput(\"types\", types);\n+ });\n+\n+ for (var d in operators) {\n+ $logicField.append(\n+ $(\"<option></option>\")\n+ .val(operators[d].value)\n+ .text(operators[d].text)\n+ );\n+ }\n+\n+ let $value = $(\"<input />\", {\n+ class: \"input-value\",\n+ type: \"text\",\n+ style: \"width: 70%;\"\n+ })\n+ .appendTo($row2)\n+ .val(data.value)\n+ .typedInput({ types: defaultTypes });\n+\n+ $value.typedInput(\"type\", data.valueType);\n+ $logicField.val(data.logic).trigger(\"change\");\n+ }\n+ });\n+\n+ $logic.editableList(\"addItems\", NODE.rules);\n+ $(\"#node-input-output_location\").typedInput({\n+ types: [\"msg\", \"flow\", \"global\"],\n+ typeField: \"#node-input-output_location_type\"\n+ });\n+\n+ $(\"#node-input-output_results_count\").spinner({ min: 1 });\n+\n+ $(\"#node-input-output_type\")\n+ .on(\"change\", function(e) {\n+ $(\".output-option\").hide();\n+ switch (e.target.value) {\n+ case \"array\":\n+ $(\"#output_empty_results\").show();\n+ $(\"#output_location\").show();\n+ break;\n+ case \"random\":\n+ $(\"#output_results_count\").show();\n+ $(\"#output_location\").show();\n+ break;\n+ case \"split\":\n+ default:\n+ break;\n+ }\n+ })\n+ .trigger(\"change\");\n+ },\n+ oneditsave: function() {\n+ const rules = $(\"#logic\").editableList(\"items\");\n+ const NODE = this;\n+ NODE.rules = [];\n+\n+ rules.each(function(i) {\n+ const $rule = $(this);\n+ const inputProperty = $rule.find(\".input-property\").val();\n+ const selectLogic = $rule.find(\"select\").val();\n+ const inputValue = $rule.find(\".input-value\").typedInput(\"value\");\n+ const inputValueType = $rule.find(\".input-value\").typedInput(\"type\");\n+\n+ NODE.rules.push({\n+ property: inputProperty,\n+ logic: selectLogic,\n+ value: inputValue,\n+ valueType: inputValueType\n+ });\n+ });\n+ }\n+ });\n+</script>\n+\n+<script type=\"text/x-red\" data-template-name=\"ha-get-entities\">\n+ <div class=\"form-row\">\n+ <label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n+ <input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-server\"><i class=\"fa fa-server\"></i> Server</label>\n+ <input type=\"text\" id=\"node-input-server\" />\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <ol id=\"logic\"></ol>\n+ </div>\n+\n+ <div class=\"form-row\">\n+ <label for=\"node-input-output_type\" style=\"width: 160px;\">Output Type</label>\n+ <select id=\"node-input-output_type\">\n+ <option value=\"array\">Array</option>\n+ <option value=\"split\">Split</option>\n+ <option value=\"random\">Random</option>\n+ </select>\n+ </div>\n+\n+ <div class=\"form-row output-option\" id=\"output_empty_results\">\n+ <input type=\"checkbox\" id=\"node-input-output_empty_results\" style=\"margin-left: 165px;display:inline-block; width:15px; vertical-align:top;\"/>\n+ <label for=\"node-input-output_empty_results\" style=\"width: auto;\">Send Empty Results</label>\n+ </div>\n+\n+ <div class=\"form-row output-option\" id=\"output_results_count\">\n+ <label for=\"node-input-output_results_count\" style=\"width: 160px;\">Max Number of Results</label>\n+ <input type=\"text\" id=\"node-input-output_results_count\" style=\"width: 150px;\"/>\n+ </div>\n+\n+ <div class=\"form-row output-option\" id=\"output_location\">\n+ <label for=\"node-input-output_location\">Output Location</label>\n+ <input type=\"hidden\" id=\"node-input-output_location_type\" />\n+ <input type=\"text\" id=\"node-input-output_location\" />\n+ </div>\n+</script>\n+\n+<script type=\"text/x-red\" data-help-name=\"ha-get-entities\">\n+ <p>Get Entities based on search criteria</p>\n+\n+ <h3>Config</h3>\n+\n+ <dl class=\"message-properties\">\n+ <dt>Search Criteria</dt>\n+ <dd>All search criteria has to be true for an entity to be valid.</dd>\n+\n+ <dt>Property</dt>\n+ <dd>Has autocomplete with all properties currently set on all loaded entities.</dd>\n+ </dl>\n+\n+ <h3>Outputs</h3>\n+\n+ <dl class=\"message-properties\">\n+ <dt>Array<span class=\"property-type\">array</span></dt>\n+ <dd>Sends an array of state objects from search criteria to the Output Location.</dd>\n+\n+ <dt>Split<span class=\"property-type\">msg part</span></dt>\n+ <dd>Sends a message for each state object. In the same format as if the split node was used.</dd>\n+\n+ <dt>Random<span class=\"property-type\">obect/array</span></dt>\n+ <dd>Return a random object or array from the avaiable state objects to the Output Location. When <code>One Max Results</code> is selected it will return an object and when more than one is selected will always return an array of state objects.</dd>\n+ </dl>\n+\n+ <h3>State Object Format</h3>\n+ <dl class=\"message-properties\">\n+ <dt>entity_id <span class=\"property-type\">string</span></dt>\n+ <dd>The entity to which this state belongs</dd>\n+\n+ <dt>state <span class=\"property-type\">string</span></dt>\n+ <dd>Main attribute state value, examples: 'on', 'off', 'home', 'open', 'closed', etc...</dd>\n+\n+ <dt>attributes <span class=\"property-type\">object</span></dt>\n+ <dd>Supported attributes of state set by homeassistant</dd>\n+\n+ <dt>last_changed <span class=\"property-type\">string</span></dt>\n+ <dd>ISO Date string of last time entity state changed</dd>\n+\n+ <dt>timeSinceChangedMs <span class=\"property-type\">number</span></dt>\n+ <dd>Millliseconds since last time entity state changed</dd>\n+\n+ <dt>last_updated <span class=\"property-type\">string</span></dt>\n+ <dd>ISO Date string of last time entity state was updated</dd>\n+\n+ <dt>context <span class=\"property-type\">object</span></dt>\n+ <dd>Information on who/what changed the state of this object last.</dd>\n+ </dl>\n+\n+ <h3>References</h3>\n+\n+ <ul>\n+ <li><a href=\"https://home-assistant.io/docs/configuration/state_object/\">Home Assistant State Objects</a></li>\n+ </ul>\n+</script>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "nodes/get-entities/get-entities.js",
"diff": "+const BaseNode = require('../../lib/base-node');\n+const lodash = require('lodash');\n+\n+module.exports = function(RED) {\n+ const nodeOptions = {\n+ debug: true,\n+ config: {\n+ server: { isNode: true },\n+ name: {},\n+ rules: {},\n+ output_type: {},\n+ output_empty_results: {},\n+ output_location_type: {},\n+ output_location: {},\n+ output_results_count: {}\n+ }\n+ };\n+\n+ class GetEntitiesNode extends BaseNode {\n+ constructor(nodeDefinition) {\n+ super(nodeDefinition, RED, nodeOptions);\n+ }\n+\n+ /* eslint-disable camelcase */\n+ async onInput({ parsedMessage, message }) {\n+ let noPayload = false;\n+\n+ const states = await this.nodeConfig.server.homeAssistant.getStates();\n+ if (!states) {\n+ this.node.warn(\n+ 'local state cache missing sending empty payload'\n+ );\n+ return { payload: {} };\n+ }\n+\n+ let entities = Object.values(states).filter(entity => {\n+ const rules = this.nodeConfig.rules;\n+\n+ for (const rule of rules) {\n+ const value = this.utils.reach(rule.property, entity);\n+ if (\n+ value === undefined ||\n+ !this.getComparatorResult(\n+ rule.logic,\n+ rule.value,\n+ value,\n+ rule.valueType\n+ )\n+ ) {\n+ return false;\n+ }\n+ }\n+\n+ entity.timeSinceChangedMs =\n+ Date.now() - new Date(entity.last_changed).getTime();\n+\n+ return true;\n+ });\n+\n+ let statusText = `${entities.length} entities`;\n+ let payload = {};\n+\n+ switch (this.nodeConfig.output_type) {\n+ case 'split':\n+ if (entities.length === 0) {\n+ noPayload = true;\n+ break;\n+ }\n+ message.parts = {};\n+ message.parts.id = RED.util.generateId();\n+ delete message._msgid;\n+ message.parts.type = 'array';\n+ message.parts.count = entities.length;\n+\n+ let pos = 0;\n+ message.parts.len = 1;\n+ for (let i = 0; i < entities.length; i++) {\n+ message.payload = entities.slice(pos, pos + 1)[0];\n+ message.parts.index = i;\n+ pos += 1;\n+ this.node.send(this.RED.util.cloneMessage(message));\n+ }\n+\n+ this.status({\n+ fill: 'green',\n+ shape: 'dot',\n+ text: `${statusText} at: ${this.getPrettyDate()}`\n+ });\n+\n+ return;\n+ case 'random':\n+ if (entities.length === 0) {\n+ noPayload = true;\n+ break;\n+ }\n+ let maxReturned =\n+ Number(this.nodeConfig.output_results_count) || 1;\n+\n+ const max =\n+ entities.length <= maxReturned\n+ ? entities.length\n+ : maxReturned;\n+ let shuffledEntities = lodash.shuffle(entities);\n+ payload = shuffledEntities.slice(0, max);\n+ if (maxReturned === 1) {\n+ payload = payload[0];\n+ }\n+ statusText = `${\n+ maxReturned === 1 ? 1 : payload.length\n+ } Random`;\n+ break;\n+ case 'array':\n+ default:\n+ if (\n+ entities.length === 0 &&\n+ !this.nodeConfig.output_empty_results\n+ ) {\n+ noPayload = true;\n+ }\n+\n+ payload = entities;\n+ break;\n+ }\n+\n+ if (noPayload) {\n+ this.status({\n+ fill: 'red',\n+ shape: 'ring',\n+ text: `No Results at: ${this.getPrettyDate()}`\n+ });\n+\n+ return null;\n+ }\n+\n+ this.status({\n+ fill: 'green',\n+ shape: 'dot',\n+ text: `${statusText} at: ${this.getPrettyDate()}`\n+ });\n+\n+ const contextKey = RED.util.parseContextStore(\n+ this.nodeConfig.output_location\n+ );\n+ const locationType = this.nodeConfig.output_location_type;\n+ if (locationType === 'flow' || locationType === 'global') {\n+ this.node\n+ .context()\n+ [locationType].set(\n+ contextKey.key,\n+ payload,\n+ contextKey.store\n+ );\n+ } else {\n+ message[contextKey.key] = payload;\n+ }\n+\n+ this.node.send(message);\n+ }\n+ }\n+\n+ RED.nodes.registerType('ha-get-entities', GetEntitiesNode);\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n- \"version\": \"0.4.2\",\n+ \"version\": \"0.4.3\",\n\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n\"balanced-match\": {\n\"version\": \"1.0.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"brace-expansion\": {\n\"version\": \"1.1.11\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"balanced-match\": \"^1.0.0\",\n\"concat-map\": \"0.0.1\"\n\"code-point-at\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"concat-map\": {\n\"version\": \"0.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"console-control-strings\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"core-util-is\": {\n\"version\": \"1.0.2\",\n\"inherits\": {\n\"version\": \"2.0.3\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"ini\": {\n\"version\": \"1.3.5\",\n\"version\": \"1.0.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"number-is-nan\": \"^1.0.0\"\n}\n\"version\": \"3.0.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"brace-expansion\": \"^1.1.7\"\n}\n\"minimist\": {\n\"version\": \"0.0.8\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"minipass\": {\n\"version\": \"2.2.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"safe-buffer\": \"^5.1.1\",\n\"yallist\": \"^3.0.0\"\n\"yallist\": {\n\"version\": \"3.0.2\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n}\n}\n},\n\"version\": \"0.5.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"minimist\": \"0.0.8\"\n}\n\"number-is-nan\": {\n\"version\": \"1.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"object-assign\": {\n\"version\": \"4.1.1\",\n\"version\": \"1.4.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"wrappy\": \"1\"\n}\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"code-point-at\": \"^1.0.0\",\n\"is-fullwidth-code-point\": \"^1.0.0\",\n\"pinkie-promise\": \"^2.0.0\"\n}\n},\n+ \"flat\": {\n+ \"version\": \"4.1.0\",\n+ \"resolved\": \"https://registry.npmjs.org/flat/-/flat-4.1.0.tgz\",\n+ \"integrity\": \"sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==\",\n+ \"requires\": {\n+ \"is-buffer\": \"~2.0.3\"\n+ },\n+ \"dependencies\": {\n+ \"is-buffer\": {\n+ \"version\": \"2.0.3\",\n+ \"resolved\": \"https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz\",\n+ \"integrity\": \"sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==\"\n+ }\n+ }\n+ },\n\"flat-cache\": {\n\"version\": \"1.3.4\",\n\"resolved\": \"https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.4.tgz\",\n\"balanced-match\": {\n\"version\": \"1.0.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"brace-expansion\": {\n\"version\": \"1.1.11\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"balanced-match\": \"^1.0.0\",\n\"concat-map\": \"0.0.1\"\n\"code-point-at\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"concat-map\": {\n\"version\": \"0.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"console-control-strings\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"core-util-is\": {\n\"version\": \"1.0.2\",\n\"inherits\": {\n\"version\": \"2.0.3\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"ini\": {\n\"version\": \"1.3.5\",\n\"version\": \"1.0.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"number-is-nan\": \"^1.0.0\"\n}\n\"version\": \"3.0.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"brace-expansion\": \"^1.1.7\"\n}\n\"minimist\": {\n\"version\": \"0.0.8\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"minipass\": {\n\"version\": \"2.2.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"safe-buffer\": \"^5.1.1\",\n\"yallist\": \"^3.0.0\"\n\"version\": \"0.5.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"minimist\": \"0.0.8\"\n}\n\"number-is-nan\": {\n\"version\": \"1.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"object-assign\": {\n\"version\": \"4.1.1\",\n\"version\": \"1.4.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"wrappy\": \"1\"\n}\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"code-point-at\": \"^1.0.0\",\n\"is-fullwidth-code-point\": \"^1.0.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"api-call-service\": \"nodes/call-service/call-service.js\",\n\"ha-fire-event\": \"nodes/fire-event/fire-event.js\",\n\"api-current-state\": \"nodes/current-state/current-state.js\",\n+ \"ha-get-entities\": \"nodes/get-entities/get-entities.js\",\n\"api-get-history\": \"nodes/get-history/get-history.js\",\n\"api-render-template\": \"nodes/render-template/render-template.js\"\n}\n\"axios\": \"0.18.0\",\n\"date-fns\": \"1.30.1\",\n\"debug\": \"4.1.0\",\n+ \"flat\": \"^4.1.0\",\n\"home-assistant-js-websocket\": \"3.1.6\",\n\"joi\": \"14.3.0\",\n\"lodash.merge\": \"4.6.1\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/get-entities_spec.js",
"diff": "+const helper = require('node-red-node-test-helper');\n+const currentState = require('../nodes/get-entities/get-entities.js');\n+\n+helper.init(require.resolve('node-red'));\n+\n+describe('get-entities node', function() {\n+ beforeEach(function(done) {\n+ helper.startServer(done);\n+ });\n+\n+ afterEach(function(done) {\n+ helper.unload();\n+ helper.stopServer(done);\n+ });\n+\n+ it('should be loaded', function(done) {\n+ var flow = [\n+ { id: 'n1', type: 'ha-get-entities', name: 'get-entities' }\n+ ];\n+ helper.load(currentState, flow, function() {\n+ var n1 = helper.getNode('n1');\n+ n1.should.have.property('name', 'get-entities');\n+ done();\n+ });\n+ });\n+});\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | get-entities feature |
748,234 | 16.12.2018 23:49:20 | 28,800 | ac3a29e449dece9d835ff320e4cccd9ec5db2b78 | Added payload output location for call-service node
Closes | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "}\n},\nrender_data: { value: false },\n- mergecontext: { value: null }\n+ mergecontext: { value: null },\n+ output_location: { value: \"payload\" },\n+ output_location_type: { value: \"msg\" }\n},\noneditprepare: function() {\nconst node = this;\n$serviceField.autocomplete(\"search\");\n});\n}\n+\n+ if (!this.output_location) {\n+ $(\"#node-input-output_location\").val(\"payload\");\n+ }\n+ $(\"#node-input-output_location\").typedInput({\n+ types: [\n+ \"msg\",\n+ \"flow\",\n+ \"global\",\n+ { value: \"none\", label: \"None\", hasValue: false }\n+ ],\n+ typeField: \"#node-input-output_location_type\"\n+ });\n},\noneditsave: function() {\nconst entityId = $(\"#entity_id\").val();\n</div>\n<div class=\"form-row\">\n- <label for=\"node-input-mergecontext\"><i class=\"fa fa-dot-circle-o\"></i> Merge Context</label>\n+ <label for=\"node-input-mergecontext\">Merge Context</label>\n<input type=\"text\" id=\"node-input-mergecontext\" placeholder=\"lightOptions\"/>\n</div>\n+ <div class=\"form-row output-option\" id=\"output_location\">\n+ <label for=\"node-input-output_location\">Output Location</label>\n+ <input type=\"hidden\" id=\"node-input-output_location_type\" />\n+ <input type=\"text\" id=\"node-input-output_location\" />\n+ </div>\n+\n<div id=\"service-data-desc\" class=\"form-row\">\n<h4>\nService: <span class=\"title\"></span>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.js",
"new_path": "nodes/call-service/call-service.js",
"diff": "@@ -12,7 +12,9 @@ module.exports = function(RED) {\nrender_data: {},\nmergecontext: {},\nname: {},\n- server: { isNode: true }\n+ server: { isNode: true },\n+ output_location: {},\n+ output_location_type: {}\n}\n};\n@@ -88,7 +90,7 @@ module.exports = function(RED) {\n)}`\n);\n- message.payload = {\n+ const msgPayload = {\ndomain: apiDomain,\nservice: apiService,\ndata: apiData || null\n@@ -108,6 +110,26 @@ module.exports = function(RED) {\nshape: 'dot',\ntext: `${apiDomain}.${apiService} called at: ${this.getPrettyDate()}`\n});\n+\n+ const contextKey = RED.util.parseContextStore(\n+ this.nodeConfig.output_location\n+ );\n+ contextKey.key = contextKey.key || 'payload';\n+ const locationType =\n+ this.nodeConfig.output_location_type || 'msg';\n+\n+ if (locationType === 'flow' || locationType === 'global') {\n+ this.node\n+ .context()\n+ [locationType].set(\n+ contextKey.key,\n+ msgPayload,\n+ contextKey.store\n+ );\n+ } else if (locationType === 'msg') {\n+ message[contextKey.key] = msgPayload;\n+ }\n+\nthis.send(message);\n})\n.catch(err => {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added payload output location for call-service node
Closes #56 |
748,234 | 17.12.2018 00:31:41 | 28,800 | 2635ed0ddd0b1a2cc3d6f7380c4b7e29c648e3ad | fixed some html alignment issues | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "}\n} catch (e) {}\n- $data.typedInput({\n+ $data\n+ .typedInput({\ntypes: [\"json\"]\n- });\n+ })\n+ .typedInput(\"width\", \"68%\");\nconst utils = {\nsetDefaultServerSelection: function() {\nif (!this.output_location) {\n$(\"#node-input-output_location\").val(\"payload\");\n}\n- $(\"#node-input-output_location\").typedInput({\n+ $(\"#node-input-output_location\")\n+ .typedInput({\ntypes: [\n\"msg\",\n\"flow\",\n{ value: \"none\", label: \"None\", hasValue: false }\n],\ntypeField: \"#node-input-output_location_type\"\n- });\n+ })\n+ .typedInput(\"width\", \"68%\");\n},\noneditsave: function() {\nconst entityId = $(\"#entity_id\").val();\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/fire-event/fire-event.html",
"new_path": "nodes/fire-event/fire-event.html",
"diff": "const $server = $(\"#node-input-server\");\nconst node = this;\n- $(\"#node-input-data\").typedInput({\n+ $(\"#node-input-data\")\n+ .typedInput({\ntypes: [\"json\"]\n- });\n+ })\n+ .typedInput(\"width\", \"68%\");\nconst utils = {\nsetDefaultServerSelection: function() {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | fixed some html alignment issues |
748,234 | 17.12.2018 10:32:23 | 28,800 | d6063be1e8c5c9ddfa34d78023641dee5fe6f752 | Added lodash.uniq dependency | [
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "\"ansi-regex\": {\n\"version\": \"2.1.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"aproba\": {\n\"version\": \"1.2.0\",\n\"safe-buffer\": {\n\"version\": \"5.1.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"safer-buffer\": {\n\"version\": \"2.1.2\",\n\"version\": \"3.0.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"ansi-regex\": \"^2.0.0\"\n}\n\"wrappy\": {\n\"version\": \"1.0.2\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n}\n}\n},\n\"lodash.uniq\": {\n\"version\": \"4.5.0\",\n\"resolved\": \"https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz\",\n- \"integrity\": \"sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=\",\n- \"dev\": true\n+ \"integrity\": \"sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=\"\n},\n\"log-driver\": {\n\"version\": \"1.2.7\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"axios\": \"0.18.0\",\n\"date-fns\": \"1.30.1\",\n\"debug\": \"4.1.0\",\n- \"flat\": \"^4.1.0\",\n+ \"flat\": \"4.1.0\",\n\"home-assistant-js-websocket\": \"3.1.6\",\n\"joi\": \"14.3.0\",\n\"lodash.merge\": \"4.6.1\",\n+ \"lodash.uniq\": \"4.5.0\",\n\"lowdb\": \"1.0.0\",\n\"merge\": \"1.2.1\",\n\"mustache\": \"3.0.1\",\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added lodash.uniq dependency |
748,234 | 17.12.2018 12:59:42 | 28,800 | 2ba9d8d82aceae11a71106c585055c032ac7c2da | Fixed the handling of multiple entity ids for the homeassistant domain
Fixes | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": ".typedInput(\"width\", \"68%\");\n},\noneditsave: function() {\n- const entityId = $(\"#entity_id\").val();\n+ const entityId = $(\"#entity_id\")\n+ .val()\n+ .replace(/\\s/g, \"\")\n+ .split(\",\");\nthis.service_domain = $(\"#service_domain\").val();\nthis.service = $(\"#service\").val();\n<input type=\"text\" id=\"node-input-name\" placeholder=\"Name\">\n</div>\n-\n<div class=\"form-row\">\n<label for=\"node-input-server\"><i class=\"fa fa-dot-circle-o\"></i> Server</label>\n<input type=\"text\" id=\"node-input-server\" />\n<script type=\"text/x-red\" data-help-name=\"api-call-service\">\n<p>Call a Home Assistant service</p>\n+ <h3>Config</h3>\n+ <dl class=\"message-properties\">\n+ <dt>Entity Id <span class=\"property-type\">string</span></dt>\n+ <dd>A comma delimited list of entity ids</dd>\n+ <dt class=\"optional\">data <span class=\"property-type\">JSON</span></dt>\n+ <dd>When using templates the top level is a property of the message object: <code>msg.payload</code> would be <code>{{payload}}</code></dd>\n+ <dt>Render Templates <span class=\"property-type\">boolean</span></dt>\n+ <dd>When checked will attempt to render templates within the data element including entity ids</dd>\n+ </dl>\n+\n<h3>Inputs</h3>\n<dl class=\"message-properties\">\n<dt class=\"optional\">\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fixed the handling of multiple entity ids for the homeassistant domain
Fixes #57 |
748,234 | 17.12.2018 14:22:36 | 28,800 | fc29219bc661a52d48715a5b80e85b7e2527380e | Changed call-service to only create an array for entity id of more than one | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": ".typedInput(\"width\", \"68%\");\n},\noneditsave: function() {\n- const entityId = $(\"#entity_id\")\n- .val()\n- .replace(/\\s/g, \"\")\n- .split(\",\");\n-\n+ let entityId = $(\"#entity_id\").val();\nthis.service_domain = $(\"#service_domain\").val();\nthis.service = $(\"#service\").val();\nconst $nodeInputData = $(\"#node-input-data\");\nconst dataString = $nodeInputData.val() || \"{}\";\n+ if (entityId.indexOf(\",\") !== -1) {\n+ entityId = entityId.replace(/\\s/g, \"\").split(\",\");\n+ }\n+\ntry {\nconst data = JSON.parse(dataString);\nconst mergedData = Object.assign({ entity_id: entityId }, data);\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Changed call-service to only create an array for entity id of more than one |
748,234 | 17.12.2018 15:07:01 | 28,800 | 9d603cfafb8ad5f116ea8f9aff3f84a2d5056e99 | change call-service to only create array for homeassistant domain to stop possible breaking change | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "const $nodeInputData = $(\"#node-input-data\");\nconst dataString = $nodeInputData.val() || \"{}\";\n- if (entityId.indexOf(\",\") !== -1) {\n+ if (\n+ this.service_domain === \"homeassistant\" &&\n+ entityId.indexOf(\",\") !== -1\n+ ) {\nentityId = entityId.replace(/\\s/g, \"\").split(\",\");\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | change call-service to only create array for homeassistant domain to stop possible breaking change |
748,234 | 18.12.2018 13:33:32 | 28,800 | 511fac2b9db6b466a287c8874b0eef56a2385c15 | CHANGELOG, README, and Bug_reported modified | [
{
"change_type": "MODIFY",
"old_path": ".github/ISSUE_TEMPLATE/Bug_report.md",
"new_path": ".github/ISSUE_TEMPLATE/Bug_report.md",
"diff": "---\nname: Bug report\nabout: Create a report to help us improve\n-\n---\n**Describe the bug**\n@@ -9,6 +8,7 @@ A clear and concise description of what the bug is.\n**To Reproduce**\nSteps to reproduce the behavior:\n+\n1. Go to '...'\n2. Click on '....'\n3. Scroll down to '....'\n@@ -24,13 +24,14 @@ If applicable, add screenshots to help explain your problem.\nIf applicable, add an example of exported json of a flow exhibiting the issue to aid in reproduction.\n**Environment (please complete the following information):**\n- - Node Red Version: [e.g. 0.18.4]\n- - NR Home Assistant Plugin Version: [e.g. 0.3.0]\n- - Is Node Red running in Docker: [e.g. yes/no]\n+\n+- Node Red Version: [e.g. 0.19.5]\n+- NR Home Assistant Plugin Version: [e.g. 0.5.0]\n+- Is Node Red running in Docker: [e.g. yes/no/hassio]\n**Other (please complete the following information):**\n+\n- Have you searched previous issues for duplicates?:\n-- Did you attempt to reproduce the issue in the dev docker environment, if so what were results (See README.md):\n**Additional context**\nAdd any other context about the problem here.\n"
},
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n-## [Unreleased]\n+## [0.5.0] 2018.12.18\n### New Features\n- Added secondary outputs for `halt if` logic for current-state, events-state, and poll-state nodes\n+- Call-service node now has the option for custom location output or no output\n+- New node `get-entities`: Get entities based on search criteria with 3 different output options\n### Added\n@@ -16,6 +18,10 @@ All notable changes to this project will be documented in this file.\n- Refactored the UI for `halt if` logic into an external file and loaded on demand\n+### Fixed\n+\n+- Fixed the handling of multiple entity ids for the homeassistant domain for the call-service node Fixed #57\n+\n## [0.4.3] 2018.12.9\n### Fixed\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -76,10 +76,14 @@ Sends a request to home assistant for any domain and service available ( `light/\nFire an event on the event bus\n-### Get Current State - `websocket`\n+### Current State - `websocket`\nFetches the last known state for any entity on input\n+### Get Entities - `websocket`\n+\n+Get entities based on search criteria with 3 different output options\n+\n### Get History - `http`\nFetches HomeAssistant history on input\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | CHANGELOG, README, and Bug_reported modified |
748,234 | 19.12.2018 16:42:32 | 28,800 | 6a9fb52003e3553554d2fd3864b8dd6efe12e5c5 | fixed get-entities to use dynamic label | [
{
"change_type": "MODIFY",
"old_path": "nodes/get-entities/get-entities.html",
"new_path": "nodes/get-entities/get-entities.html",
"diff": "outputs: 1,\nicon: \"split.png\",\npaletteLabel: \"get entities\",\n- label: \"get entities\",\n+ label: function() {\n+ return this.name || \"get entities\";\n+ },\ndefaults: {\nserver: { value: \"\", type: \"server\", required: true },\nname: { value: \"\" },\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | fixed get-entities to use dynamic label |
748,234 | 28.12.2018 23:40:31 | 28,800 | 284aceae06a26389a2cfd9ba9576d2cb37d50d09 | Fixed race condition where wildcard events were getting processed before new state was set | [
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -129,14 +129,6 @@ class HaWebsocket extends EventEmitter {\nreturn;\n}\n- // Emit on all channel\n- this.emit('ha_events:all', emitEvent);\n-\n- // Emit on the event type channel\n- if (emitEvent.event_type) {\n- this.emit(`ha_events:${msg.event_type}`, emitEvent);\n- }\n-\n// Most specific emit for event_type and entity_id\nif (emitEvent.event_type && emitEvent.entity_id) {\nif (\n@@ -153,6 +145,14 @@ class HaWebsocket extends EventEmitter {\nemitEvent\n);\n}\n+\n+ // Emit on all channel\n+ this.emit('ha_events:all', emitEvent);\n+\n+ // Emit on the event type channel\n+ if (emitEvent.event_type) {\n+ this.emit(`ha_events:${msg.event_type}`, emitEvent);\n+ }\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fixed race condition where wildcard events were getting processed before new state was set |
748,234 | 29.12.2018 22:15:52 | 28,800 | f6abe0dcb41f08185010e013632d12aa16d2172b | html entities fixed in html files | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "<h3>Details</h3>\n<p>If the incoming message has a <code>payload</code> property with <code>domain</code>, <code>service</code> set it will override any config values if set.</p>\n<p>If the incoming message has a <code>payload.data</code> that is an object or parseable into an object these properties will be <strong>merged</strong> with any config values set.<p>\n- <p>If the node has a property value in it's config for <code>Merge Context</code> then the <code>flow</code> and <code>global</code> contexts will be checked for this property which should be an object that will also be merged into the data payload.<p>\n+ <p>If the node has a property value in it's config for <code>Merge Context</code> then the <code>flow</code> and <code>global</code> contexts will be checked for this property which should be an object that will also be merged into the data payload.<p>\n<h3>Merge Resolution</h3>\n<p>As seen above the <code>data</code> property has a lot going on in the way of data merging, in the end all of these are optional and the right most will win in the event that a property exists in multiple objects<p>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.html",
"new_path": "nodes/config-server/config-server.html",
"diff": "<dd>Label for this configuration, see details below for implications</dd>\n<dt>Hass.io <span class=\"property-type\">boolean</span></dt>\n- <dd>If you're connecting Hass.io check this. No other information is needed.</dd>\n+ <dd>If you're connecting Hass.io check this. No other information is needed.</dd>\n<dt>Base URL <span class=\"property-type\">string</span></dt>\n<dd>The base url and port the home assistant instance can be reached at, for example: <code>http://192.168.0.100:8123</code> or <code>https://homeassistant.mysite.com</code></dd>\n<dd>Long-lived Access Token or Password used to contact the API</dd>\n<dt>Legacy Password <span class=\"property-type\">boolean</span></dt>\n- <dd>If you're using the legacy password to log into Home Assistant check this and enter your password in the password text box.</dd>\n+ <dd>If you're using the legacy password to log into Home Assistant check this and enter your password in the password text box.</dd>\n<dt>Unauthorized SSL Certificates <span class=\"property-type\">boolean</span></dt>\n- <dd>This will allow you to use self-signed certificates. Only use this if you know what you're doing.</dd>\n+ <dd>This will allow you to use self-signed certificates. Only use this if you know what you're doing.</dd>\n<dt>State Boolean <span class=\"property-type\">string | delimited</span></dt>\n<dd>A list of strings, not case sensitive, delimited by vertial pipe, | , that will return true for State Type Boolean.</dd>\n</dl>\n<h3>Details</h3>\n- <p>Every node requires a configuration attached to define how to contact home assistant, that is this config node's main purpose.</p>\n+ <p>Every node requires a configuration attached to define how to contact home assistant, that is this config node's main purpose.</p>\n<h4>Context</h4>\n<p>Each config node will also make some data available on the global context, the <code>Name</code> value in this node is used as a, camelcased, namespace for those values</p>\n<h4>Context Example</h4>\n<p>Say we have a config node with name <code>My Awesome server</code>, with an entity setup in homeassistant as <code>switch.my_switch</code>. This state would be available within function nodes and you could fetch using something like the below code</p>\n- <p>NOTE: It's likely one of the state or trigger nodes will better serve most use cases, this is simply provided as an option for more advanced cases, or to implement functionality I haven't thought of/gotten around to</p>\n+ <p>NOTE: It's likely one of the state or trigger nodes will better serve most use cases, this is simply provided as an option for more advanced cases, or to implement functionality I haven't thought of/gotten around to</p>\n<pre>\n- const haCtx = global.get('homeassistant');\n+ const haCtx = global.get('homeassistant');\nconst configCtx = haCtx.myAwesomeServer;\n- const entityState = configCtx.states['switch.my_switch'];\n- return (entityState.state === 'on') ? true : false;\n+ const entityState = configCtx.states['switch.my_switch'];\n+ return (entityState.state === 'on') ? true : false;\n</pre>\n<h3>Connection Issues</h3>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/fire-event/fire-event.html",
"new_path": "nodes/fire-event/fire-event.html",
"diff": "<h3>Details</h3>\n<p>If the incoming message has a <code>payload</code> property with <code>event</code> set it will override any config values if set.</p>\n<p>If the incoming message has a <code>payload.data</code> that is an object or parseable into an object these properties will be <strong>merged</strong> with any config values set.<p>\n- <p>If the node has a property value in it's config for <code>Merge Context</code> then the <code>flow</code> and <code>global</code> contexts will be checked for this property which should be an object that will also be merged into the data payload.<p>\n+ <p>If the node has a property value in it's config for <code>Merge Context</code> then the <code>flow</code> and <code>global</code> contexts will be checked for this property which should be an object that will also be merged into the data payload.<p>\n<h3>Merge Resolution</h3>\n<p>As seen above the <code>data</code> property has a lot going on in the way of data merging, in the end all of these are optional and the right most will win in the event that a property exists in multiple objects<p>\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | html entities fixed in html files |
748,234 | 29.12.2018 22:43:31 | 28,800 | 44a2f86303c89f8e10c9b4aa384ee0f5dbe1914e | fix onDeploy for trigger-state node when substring/regex | [
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -81,22 +81,22 @@ module.exports = function(RED) {\n}\nasync onDeploy() {\n- const entityState = await this.nodeConfig.server.homeAssistant.getStates(\n- this.nodeConfig.entityid\n- );\n+ const entities = await this.nodeConfig.server.homeAssistant.getStates();\n+ for (let entityId in entities) {\nlet eventMessage = {\nevent_type: 'state_changed',\n- entity_id: this.nodeConfig.entityid,\n+ entity_id: entityId,\nevent: {\n- entity_id: this.nodeConfig.entityid,\n- old_state: entityState,\n- new_state: entityState\n+ entity_id: entityId,\n+ old_state: entities[entityId],\n+ new_state: entities[entityId]\n}\n};\nthis.onEntityStateChanged(eventMessage);\n}\n+ }\nasync onEntityStateChanged(eventMessage) {\nif (this.isenabled === false) {\n@@ -251,11 +251,7 @@ module.exports = function(RED) {\nconst msg = {\ntopic: entity_id,\npayload: event.new_state.state,\n- data: {\n- event_type: 'state_changed',\n- entity_id,\n- event\n- }\n+ data: eventMessage\n};\nlet outputs;\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | fix onDeploy for trigger-state node when substring/regex |
748,234 | 29.12.2018 22:54:27 | 28,800 | a297b5788e0891b68995267a22c83ff3c5f8bec6 | CHANGELOG and CONTRIBUTING changes | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "All notable changes to this project will be documented in this file.\n+## [0.5.1] 2018.12.29\n+\n+### Fixed\n+\n+- Fixed `get-entities` to use custom label if valid\n+- Correct possessive apostrophe in trigger state node constraint list ([@albertnis](https://github.com/albertnis))\n+- Fixed condition where wildcard type state changes fired before current states were actually saved\n+- Fixed onDeploy for trigger-state node when using substring/regex for entity id\n+\n## [0.5.0] 2018.12.18\n### New Features\n"
},
{
"change_type": "MODIFY",
"old_path": "CONTRIBUTING.md",
"new_path": "CONTRIBUTING.md",
"diff": "@@ -5,27 +5,28 @@ Please take a moment to review this document in order to make the contribution p\nFollowing these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests.\n## Using the issue tracker\n-The issue tracker is the preferred channel for [bug reports](#bugs), [features requests](#features) and [submitting pull requests](#pull-requests). Currently [support issues](#support-issues) are acceptable in the isuse tracker as well although this may change in the future to cut down on the noise.\n+\n+The issue tracker is the preferred channel for [bug reports](#bugs), [features requests](#features) and [submitting pull requests](#pull-requests). Currently [support issues](#support-issues) are acceptable in the issue tracker as well although this may change in the future to cut down on the noise.\n## Bug reports\n+\nA bug is a _demonstrable problem_ that is caused by the code in the repository. Good bug reports are extremely helpful - thank you!\nGuidelines for bug reports:\n1. **Use the GitHub issue search** — check if the issue has already been reported.\n-2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or `dev-master` branch in the repository.\n+2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` branch in the repository.\n3. **Isolate the problem** — ideally create a reduced test case, an example flow in node-red that you can add to the issue is preferred.\nA good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What OS experiences the problem? What would you expect to be the outcome? All these details will help people to fix any potential bugs. Fill out all the information you can when presented with the Bug Issue template.\n## Feature requests\n-Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.\n+Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.\n## Pull requests\n-Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.\n-**Please note: All pull requests should be submitted against the `dev-master` branch, this allows for some manual testing prior to a relase.**\n+Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.\n**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.\n@@ -59,16 +60,16 @@ If you never created a pull request before, welcome :tada: :smile: [Here is a gr\n4. If you added or changed a feature, make sure to document it accordingly in the `README.md` file.\n-6. Push your topic branch up to your fork:\n+5. Push your topic branch up to your fork:\n```bash\ngit push origin <topic-branch-name>\n```\n-8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description.\n-\n+6. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description.\n## Support Issues\n-At some point, if the need is apparent, the project may get another venue to foster disucssion and help each other with support issues at which point support issues will no longer be accepted in the github issues interface. Until that happens feel free to submit your support issues if they are unique and you are stuck.\n+\n+At some point, if the need is apparent, the project may get another venue to foster discussion and help each other with support issues at which point support issues will no longer be accepted in the github issues interface. Until that happens feel free to submit your support issues if they are unique and you are stuck.\nExamples of support issues are thing like server communication errors, something that only happens \"in your environment\" (not directly code related). A lot of support issues have already been logged and solved so make sure to search previous issues (including closed issues) first and also read the README.md file here. If applicable please fully document how the issue was resolved, this will help others in the future.\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | CHANGELOG and CONTRIBUTING changes |
748,234 | 30.12.2018 02:05:54 | 28,800 | 896d2f87b36f089ac8dd36e4e500c41db82cfe12 | Added verbose error message for autocomplete when server not deployed
Closes | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "minLength: 0\n});\n})\n- .fail(err => RED.notify(err.responseText, \"error\"));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node($(\"#node-input-server\").val());\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\n// Calls the custom api backend defined in the config-server.js node\nreturn node;\n})\n- .fail(err => RED.notify(err.responseText, \"error\"));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node($(\"#node-input-server\").val());\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\nfunction updateServiceSelection({ event, serviceText }) {\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "utils.setDefaultServerSelection();\n}\n- // Check that proper config is set\n- const config = RED.nodes.node($(\"#node-input-server\").val());\n- const isConfigValid = config && config.valid;\n- // TODO: Doesn't seem to be working\n- if (!isConfigValid) {\n- $entityIdField.addClass(\"disabled\");\n- } else {\n- $entityIdField.removeClass(\"disabled\");\n- }\n-\nconst selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\nconst validSelection =\nthis.availableEntities.indexOf(this.entity_id) > -1;\n})\n- .fail(err => RED.notify(err.responseText, \"error\"));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node($(\"#node-input-server\").val());\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\nif (this.state_type === undefined) {\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "minLength: 0\n});\n})\n- .fail(err => RED.notify(err.responseText, \"error\"));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node(\n+ $(\"#node-input-server\").val()\n+ );\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/get-entities/get-entities.html",
"new_path": "nodes/get-entities/get-entities.html",
"diff": "minLength: 0\n});\n})\n- .fail(err => RED.notify(err.responseText, \"error\"));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node($(\"#node-input-server\").val());\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\n$logic.editableList({\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/get-history/get-history.html",
"new_path": "nodes/get-history/get-history.html",
"diff": "<script type=\"text/javascript\">\n- RED.nodes.registerType('api-get-history', {\n- category: 'home_assistant',\n- color: '#52C0F2',\n+ RED.nodes.registerType(\"api-get-history\", {\n+ category: \"home_assistant\",\n+ color: \"#52C0F2\",\ndefaults: {\n- name: { value: '' },\n- server: { value: '', type: 'server', required: true },\n- startdate: { value: '' },\n- enddate: { value: '' },\n- entityid: { value: '' },\n- entityidtype: { value: '' }\n+ name: { value: \"\" },\n+ server: { value: \"\", type: \"server\", required: true },\n+ startdate: { value: \"\" },\n+ enddate: { value: \"\" },\n+ entityid: { value: \"\" },\n+ entityidtype: { value: \"\" }\n},\ninputs: 1,\noutputs: 1,\n- icon: 'timer.png',\n- paletteLabel: 'get history',\n+ icon: \"timer.png\",\n+ paletteLabel: \"get history\",\nlabel: function() {\n- if (this.name) { return this.name; }\n+ if (this.name) {\n+ return this.name;\n+ }\nif (this.startdate) {\nconst startdate = new Date(this.startdate);\nreturn `${startdate.toLocaleDateString()} ${startdate.toLocaleTimeString()}`;\n}\n- return 'get history';\n+ return \"get history\";\n},\noneditprepare: function() {\nconst NODE = this;\n- const $server = $('#node-input-server');\n- const $entityIdField = $('#entity_id');\n+ const $server = $(\"#node-input-server\");\n+ const $entityIdField = $(\"#entity_id\");\n$entityIdField.val(this.entityid);\n- NODE.entityidtype = NODE.entityidtype || 'is';\n- $('#node-input-entityidtype').val(NODE.entityidtype);\n+ NODE.entityidtype = NODE.entityidtype || \"is\";\n+ $(\"#node-input-entityidtype\").val(NODE.entityidtype);\nconst utils = {\nsetDefaultServerSelection: function() {\nlet defaultServer;\nRED.nodes.eachConfig(n => {\n- if (n.type === 'server' && !defaultServer) defaultServer = n.id;\n+ if (n.type === \"server\" && !defaultServer) defaultServer = n.id;\n});\nif (defaultServer) $server.val(defaultServer);\n}\n}\nconst selectedServer = $server.val();\n- if (NODE.server || (selectedServer && selectedServer !== '_ADD_')) {\n+ if (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\n$.get(`homeassistant/${serverId}/entities`)\n- .done((entities) => {\n+ .done(entities => {\nthis.availableEntities = JSON.parse(entities);\n$entityIdField.autocomplete({\nsource: this.availableEntities,\nminLength: 0,\nchange: (evt, ui) => {\n- const validSelection = (this.availableEntities.indexOf($(evt.target).val()) > -1);\n- if (validSelection) { $(evt.target).removeClass('input-error'); }\n- else { $(evt.target).addClass('input-error'); }\n+ const validSelection =\n+ this.availableEntities.indexOf($(evt.target).val()) > -1;\n+ if (validSelection) {\n+ $(evt.target).removeClass(\"input-error\");\n+ } else {\n+ $(evt.target).addClass(\"input-error\");\n+ }\n}\n});\n- const validSelection = (this.availableEntities.indexOf(this.entity_id) > -1);\n- if (validSelection) { $entityIdField.removeClass('input-error'); }\n- else { $entityIdField.addClass('input-error'); }\n+ const validSelection =\n+ this.availableEntities.indexOf(this.entity_id) > -1;\n+ if (validSelection) {\n+ $entityIdField.removeClass(\"input-error\");\n+ } else {\n+ $entityIdField.addClass(\"input-error\");\n+ }\n})\n- .fail((err) => RED.notify(err.responseText, 'error'));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node($(\"#node-input-server\").val());\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\n},\n- oneditsave: function () { this.entityid = $(\"#entity_id\").val(); }\n+ oneditsave: function() {\n+ this.entityid = $(\"#entity_id\").val();\n+ }\n});\n</script>\n-\n<script type=\"text/html\" data-template-name=\"api-get-history\">\n<div class=\"form-row\">\n<label for=\"node-input-name\"><i class=\"fa fa-tag\"></i> Name</label>\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "utils.setDefaultServerSelection();\n}\n- // Check that proper config is set\n- const config = RED.nodes.node($(\"#node-input-server\").val());\n- const isConfigValid = config && config.valid;\n- // TODO: Doesn't seem to be working\n- if (!isConfigValid) {\n- $entityIdField.addClass(\"disabled\");\n- } else {\n- $entityIdField.removeClass(\"disabled\");\n- }\n-\nconst selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\n$entityIdField.addClass(\"input-error\");\n}\n})\n- .fail(err => RED.notify(err.responseText, \"error\"));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node($(\"#node-input-server\").val());\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\n$(\"#node-input-updateinterval\").spinner({ min: 1 });\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "minLength: 0\n});\n})\n- .fail(err => RED.notify(err.responseText, \"error\"));\n+ .fail(err => {\n+ const serverConfig = RED.nodes.node(\n+ $(\"#node-input-server\").val()\n+ );\n+\n+ if (serverConfig && serverConfig.dirty === true) {\n+ RED.notify(\n+ `You probably haven't deployed since adding a server. Do that for autocomplete to work.\\n${\n+ err.responseText\n+ }`,\n+ \"error\"\n+ );\n+ }\n+ });\n}\n},\nsetDefaultServerSelection: function() {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added verbose error message for autocomplete when server not deployed
Closes #66 |
748,234 | 31.12.2018 09:48:14 | 28,800 | 057613f01e45c087443b5fb44a0979745d058229 | Added more autocompletes trigger-node
Added autocomplete for Constraints entity ids and properties
Added autocomplte for properties under Outputs | [
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "source: NODE.availableEntities,\nminLength: 0\n});\n+ $(\"#constraint-target-value\").autocomplete({\n+ source: NODE.availableEntities,\n+ minLength: 0\n+ });\n})\n.fail(err => {\nconst serverConfig = RED.nodes.node(\n);\n}\n});\n+ $.get(`homeassistant/${serverId}/properties`)\n+ .done(entities => {\n+ NODE.availableProperties = JSON.parse(entities);\n+ $(\n+ \"#constraint-property-value,#output-comparator-property-value\"\n+ ).autocomplete({\n+ source: NODE.availableProperties,\n+ minLength: 0\n+ });\n+ })\n+ .fail(err => {});\n}\n},\nsetDefaultServerSelection: function() {\nconst constraintsHandler = {\nonTargetTypeChange: function(e) {\nconst val = e.target.value;\n- val === \"this_entity\"\n- ? $constraints.targetValue.attr(\"disabled\", \"disabled\")\n- : $constraints.targetValue.removeAttr(\"disabled\");\n+ if (val === \"this_entity\") {\n+ $constraints.targetValue.attr(\"disabled\", \"disabled\").val(\"\");\n+ $constraints.propertyType\n+ .find(\"option[value=previous_state]\")\n+ .show();\n+ } else {\n+ $constraints.targetValue.removeAttr(\"disabled\");\n+ $constraints.propertyType\n+ .val(\"current_state\")\n+ .find(\"option[value=previous_state]\")\n+ .hide()\n+ .trigger(\"change\");\n+ }\n},\nonPropertyTypeChange: function(e) {\nconst val = e.target.value;\n- val === \"current_state\" || val === \"previous_state\"\n- ? $constraints.propertyValue.attr(\"disabled\", \"disabled\")\n- : $constraints.propertyValue.removeAttr(\"disabled\");\n+ if (val === \"current_state\" || val === \"previous_state\") {\n+ $constraints.propertyValue.attr(\"disabled\", \"disabled\").val(\"\");\n+ } else {\n+ $constraints.propertyValue.removeAttr(\"disabled\");\n+ }\n},\nonComparatorTypeChange: function(e) {\nconst val = e.target.value; // Placeholder\n$customoutputs.comparatorPropertyValue.attr(\"disabled\", \"disabled\");\n$customoutputs.comparatorType.attr(\"disabled\", \"disabled\");\n$customoutputs.comparatorValue.attr(\"disabled\", \"disabled\");\n+ $customoutputs.comparatorPropertyValue.val(\"\");\n}\nif (val === \"previous_state\" || val === \"current_state\") {\n$customoutputs.comparatorPropertyValue.attr(\"disabled\", \"disabled\");\n$customoutputs.comparatorType.removeAttr(\"disabled\");\n$customoutputs.comparatorValue.removeAttr(\"disabled\");\n+ $customoutputs.comparatorPropertyValue.val(\"\");\n}\nif (val === \"property\") {\n$customoutputs.comparatorPropertyValue.removeAttr(\"disabled\");\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "@@ -304,8 +304,6 @@ module.exports = function(RED) {\n? this.nodeConfig.entityid\n: constraint.targetValue;\n- // TODO: Non 'self' targets state is just new_state of an incoming event, wrap to hack around the fact\n- // NOTE: UI needs changing to handle this there, and also to hide \"previous state\" if target is not self\nif (isTargetThisEntity) {\ntargetData.state = triggerEvent;\n} else {\n@@ -318,7 +316,7 @@ module.exports = function(RED) {\n}\n} catch (e) {\nthis.debug(\n- 'Error during trigger:state comparator evalutation: ',\n+ 'Error during trigger:state comparator evaluation: ',\ne.stack\n);\nthrow e;\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added more autocompletes trigger-node
Added autocomplete for Constraints entity ids and properties
Added autocomplte for properties under Outputs |
748,234 | 01.01.2019 00:10:47 | 28,800 | 93b4306143ee34641f2ba66ee97ed7fe2d770e03 | Refactored autocomplete across all nodes | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "const serverId = node.server || selectedServer;\nif (node.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nsetServicesAndDomains(node);\n- $.get(`homeassistant/${serverId}/entities`)\n+ $.getJSON(`homeassistant/${serverId}/entities`)\n.done(entities => {\n- this.availableEntities = JSON.parse(entities);\n+ this.availableEntities = entities;\n$entityIdField.autocomplete({\nsource: this.availableEntities,\n// Calls the custom api backend defined in the config-server.js node\nfunction setServicesAndDomains(node) {\n- return $.get(`homeassistant/${serverId}/services`)\n+ return $.getJSON(`homeassistant/${serverId}/services`)\n.then(services => {\n- node.allServices = JSON.parse(services);\n- node.allDomains = Object.keys(node.allServices);\n+ node.allServices = services;\n+ node.allDomains = Object.keys(node.allServices).sort();\n$domainField\n.autocomplete({\n$serviceField\n.autocomplete({\n- source: Object.keys(node.selectedDomain.services),\n+ source: Object.keys(node.selectedDomain.services).sort(),\ncreate: (evt, ui) => updateServiceSelection({ event: evt }),\nchange: (evt, ui) => updateServiceSelection({ event: evt }),\nselect: (evt, ui) => updateServiceSelection({ event: evt }),\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/config-server/config-server.js",
"new_path": "nodes/config-server/config-server.js",
"diff": "@@ -8,37 +8,37 @@ module.exports = function(RED) {\nconst httpHandlers = {\ngetEntities: function(req, res, next) {\nif (!this.homeAssistant) {\n- return res.json('[]');\n+ return res.json([]);\n}\nreturn this.homeAssistant\n.getEntities()\n- .then(states => res.json(JSON.stringify(states)))\n+ .then(states => res.json(states))\n.catch(e => this.error(e.message));\n},\ngetStates: function(req, res, next) {\nif (!this.homeAssistant) {\n- return res.json('[]');\n+ return res.json([]);\n}\nreturn this.homeAssistant\n.getStates()\n- .then(states => res.json(JSON.stringify(states)))\n+ .then(states => res.json(states))\n.catch(e => this.error(e.message));\n},\ngetServices: function(req, res, next) {\nif (!this.homeAssistant) {\n- return res.json('[]');\n+ return res.json([]);\n}\nreturn this.homeAssistant\n.getServices()\n- .then(services => res.json(JSON.stringify(services)))\n+ .then(services => res.json(services))\n.catch(e => this.error(e.message));\n},\ngetProperties: function(req, res, next) {\nif (!this.homeAssistant) {\n- return res.json('[]');\n+ return res.json([]);\n}\nreturn this.homeAssistant\n@@ -47,9 +47,18 @@ module.exports = function(RED) {\nconst flat = Object.values(states).map(entity =>\nObject.keys(flatten(entity))\n);\n- const uniqArray = uniq([].concat(...flat).sort());\n+ const uniqArray = uniq(\n+ [].concat(...flat).sort((a, b) => {\n+ if (!a.includes('.') && b.includes('.')) return -1;\n+ if (a.includes('.') && !b.includes('.')) return 1;\n+ if (a < b) return -1;\n+ if (a > b) return 1;\n+\n+ return 0;\n+ })\n+ );\n- res.json(JSON.stringify(uniqArray));\n+ res.json(uniqArray);\n})\n.catch(e => this.error(e.message));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.html",
"new_path": "nodes/current-state/current-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\n- $.get(`homeassistant/${serverId}/entities`)\n+ $.getJSON(`homeassistant/${serverId}/entities`)\n.done(entities => {\n- this.availableEntities = JSON.parse(entities);\n+ this.availableEntities = entities;\n$entityIdField.autocomplete({\nsource: this.availableEntities,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.html",
"new_path": "nodes/events-state-changed/events-state-changed.html",
"diff": "// A home assistant server is selected in the node config\nif (node.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = node.server || selectedServer;\n- $.get(`homeassistant/${serverId}/entities`)\n+ $.getJSON(`homeassistant/${serverId}/entities`)\n.done(entities => {\n- node.availableEntities = JSON.parse(entities);\n+ node.availableEntities = entities;\n$entityidfilter.autocomplete({\nsource: node.availableEntities,\nminLength: 0\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/get-entities/get-entities.html",
"new_path": "nodes/get-entities/get-entities.html",
"diff": "let availableProperties = [];\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\n- $.get(`homeassistant/${serverId}/properties`)\n+ $.getJSON(`homeassistant/${serverId}/properties`)\n.done(entities => {\n- availableProperties = JSON.parse(entities);\n+ availableProperties = entities;\n$(\".input-property\").autocomplete({\nsource: availableProperties,\nminLength: 0\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/get-history/get-history.html",
"new_path": "nodes/get-history/get-history.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\n- $.get(`homeassistant/${serverId}/entities`)\n+ $.getJSON(`homeassistant/${serverId}/entities`)\n.done(entities => {\n- this.availableEntities = JSON.parse(entities);\n+ this.availableEntities = entities;\n$entityIdField.autocomplete({\nsource: this.availableEntities,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/poll-state/poll-state.html",
"new_path": "nodes/poll-state/poll-state.html",
"diff": "const selectedServer = $server.val();\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\n- $.get(`homeassistant/${serverId}/entities`)\n+ $.getJSON(`homeassistant/${serverId}/entities`)\n.done(entities => {\n- this.availableEntities = JSON.parse(entities);\n+ this.availableEntities = entities;\n$entityIdField.autocomplete({\nsource: this.availableEntities,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.html",
"new_path": "nodes/trigger-state/trigger-state.html",
"diff": "// A home assistant server is selected in the node config\nif (NODE.server || (selectedServer && selectedServer !== \"_ADD_\")) {\nconst serverId = NODE.server || selectedServer;\n- $.get(`homeassistant/${serverId}/entities`)\n+ $.getJSON(`homeassistant/${serverId}/entities`)\n.done(entities => {\n- NODE.availableEntities = JSON.parse(entities);\n+ NODE.availableEntities = entities;\n$entityid.autocomplete({\nsource: NODE.availableEntities,\nminLength: 0\n);\n}\n});\n- $.get(`homeassistant/${serverId}/properties`)\n+ $.getJSON(`homeassistant/${serverId}/properties`)\n.done(entities => {\n- NODE.availableProperties = JSON.parse(entities);\n+ NODE.availableProperties = entities;\n$(\n\"#constraint-property-value,#output-comparator-property-value\"\n).autocomplete({\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Refactored autocomplete across all nodes |
748,234 | 01.01.2019 03:00:55 | 28,800 | 23c1fdcbf34daa747a09b60c90a07f5377f3b9b9 | Added 'in group' logic to get-entities
Will check if entity_id is a Home Assistant group | [
{
"change_type": "MODIFY",
"old_path": "lib/base-node.js",
"new_path": "lib/base-node.js",
"diff": "@@ -236,7 +236,7 @@ class BaseNode {\n}\n}\n- getComparatorResult(\n+ async getComparatorResult(\ncomparatorType,\ncomparatorValue,\nactualValue,\n@@ -288,6 +288,13 @@ class BaseNode {\nreturn actualValue <= cValue;\ncase 'starts_with':\nreturn actualValue.startsWith(cValue);\n+ case 'in_group':\n+ const entity = await this.nodeConfig.server.homeAssistant.getStates(\n+ cValue\n+ );\n+ const groupEntities =\n+ this.utils.reach('attributes.entity_id', entity) || [];\n+ return groupEntities.includes(actualValue);\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/current-state/current-state.js",
"new_path": "nodes/current-state/current-state.js",
"diff": "@@ -77,14 +77,13 @@ module.exports = function(RED) {\nthis.nodeConfig.halt_if_type =\nthis.nodeConfig.halt_if_type || 'str';\n- const shouldHaltIfState =\n- this.nodeConfig.halt_if &&\n- this.getComparatorResult(\n+ const isHaltValid = await this.getComparatorResult(\nthis.nodeConfig.halt_if_compare,\nthis.nodeConfig.halt_if,\ncurrentState.state,\nthis.nodeConfig.halt_if_type\n);\n+ const shouldHaltIfState = this.nodeConfig.halt_if && isHaltValid;\n// default switch to true if undefined (backward compatibility\nconst override_payload = this.nodeConfig.override_payload !== false;\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/events-state-changed/events-state-changed.js",
"new_path": "nodes/events-state-changed/events-state-changed.js",
"diff": "@@ -48,7 +48,7 @@ module.exports = function(RED) {\n}\n}\n- onHaEventsStateChanged(evt) {\n+ async onHaEventsStateChanged(evt) {\ntry {\nconst { entity_id, event } = this.utils.merge({}, evt);\n@@ -87,14 +87,14 @@ module.exports = function(RED) {\nthis.nodeConfig.halt_if_type =\nthis.nodeConfig.halt_if_type || 'str';\n- const shouldHaltIfState =\n- this.nodeConfig.haltIfState &&\n- this.getComparatorResult(\n+ const isHaltValid = await this.getComparatorResult(\nthis.nodeConfig.halt_if_compare,\nthis.nodeConfig.haltIfState,\nevent.new_state.state,\nthis.nodeConfig.halt_if_type\n);\n+ const shouldHaltIfState =\n+ this.nodeConfig.haltIfState && isHaltValid;\nconst msg = {\ntopic: entity_id,\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/get-entities/get-entities.html",
"new_path": "nodes/get-entities/get-entities.html",
"diff": "{ value: \"gte\", text: \">=\" },\n{ value: \"includes\", text: \"in\" },\n{ value: \"does_not_include\", text: \"not in\" },\n- { value: \"starts_with\", text: \"starts with\" }\n+ { value: \"starts_with\", text: \"starts with\" },\n+ { value: \"in_group\", text: \"in group\" }\n];\nconst defaultTypes = [\"str\", \"num\", \"bool\", \"re\"];\nconst $logic = $(\"#logic\");\ncase \"includes\":\ncase \"does_not_include\":\ncase \"starts_with\":\n+ case \"in_group\":\ntypes = [\"str\"];\nbreak;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/get-entities/get-entities.js",
"new_path": "nodes/get-entities/get-entities.js",
"diff": "const BaseNode = require('../../lib/base-node');\n-const lodash = require('lodash');\n+const { shuffle } = require('lodash');\n+const { filter } = require('p-iteration');\nmodule.exports = function(RED) {\nconst nodeOptions = {\n@@ -33,27 +34,24 @@ module.exports = function(RED) {\nreturn { payload: {} };\n}\n- let entities = Object.values(states).filter(entity => {\n+ let entities = await filter(Object.values(states), async entity => {\nconst rules = this.nodeConfig.rules;\nfor (const rule of rules) {\nconst value = this.utils.reach(rule.property, entity);\n- if (\n- value === undefined ||\n- !this.getComparatorResult(\n+ const result = await this.getComparatorResult(\nrule.logic,\nrule.value,\nvalue,\nrule.valueType\n- )\n- ) {\n+ );\n+ if (value === undefined || !result) {\nreturn false;\n}\n}\nentity.timeSinceChangedMs =\nDate.now() - new Date(entity.last_changed).getTime();\n-\nreturn true;\n});\n@@ -100,7 +98,7 @@ module.exports = function(RED) {\nentities.length <= maxReturned\n? entities.length\n: maxReturned;\n- let shuffledEntities = lodash.shuffle(entities);\n+ let shuffledEntities = shuffle(entities);\npayload = shuffledEntities.slice(0, max);\nif (maxReturned === 1) {\npayload = payload[0];\n"
},
{
"change_type": "MODIFY",
"old_path": "nodes/trigger-state/trigger-state.js",
"new_path": "nodes/trigger-state/trigger-state.js",
"diff": "/* eslint-disable camelcase */\nconst EventsNode = require('../../lib/events-node');\n+const { reduce } = require('p-iteration');\nmodule.exports = function(RED) {\nconst nodeOptions = {\n@@ -175,7 +176,7 @@ module.exports = function(RED) {\nreturn this.send(outputs);\n}\n- const customOutputsComparatorResults = this.getCustomOutputsComparatorResults(\n+ const customOutputsComparatorResults = await this.getCustomOutputsComparatorResults(\nthis.nodeConfig.customoutputs,\neventMessage\n);\n@@ -214,7 +215,7 @@ module.exports = function(RED) {\nconstraint.propertyValue,\nconstraintTarget.state\n);\n- const comparatorResult = this.getComparatorResult(\n+ const comparatorResult = await this.getComparatorResult(\ncomparatorType,\ncomparatorValue,\nactualValue,\n@@ -269,7 +270,9 @@ module.exports = function(RED) {\n}\ngetCustomOutputsComparatorResults(outputs, eventMessage) {\n- return outputs.reduce((acc, output, reduceIndex) => {\n+ return reduce(\n+ outputs,\n+ async (acc, output, reduceIndex) => {\nlet result = {\noutput,\ncomparatorMatched: true,\n@@ -282,17 +285,22 @@ module.exports = function(RED) {\noutput.comparatorPropertyValue,\neventMessage.event\n);\n- result.comparatorMatched = this.getComparatorResult(\n+ result.comparatorMatched = await this.getComparatorResult(\noutput.comparatorType,\noutput.comparatorValue,\nresult.actualValue,\noutput.comparatorValueDatatype\n);\n}\n- result.message = this.getOutputMessage(result, eventMessage);\n+ result.message = this.getOutputMessage(\n+ result,\n+ eventMessage\n+ );\nacc.push(result);\nreturn acc;\n- }, []);\n+ },\n+ []\n+ );\n}\nasync getConstraintTargetData(constraint, triggerEvent) {\n"
},
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "{\n\"name\": \"node-red-contrib-home-assistant-websocket\",\n- \"version\": \"0.5.0\",\n+ \"version\": \"0.5.1\",\n\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n\"balanced-match\": {\n\"version\": \"1.0.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"brace-expansion\": {\n\"version\": \"1.1.11\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"balanced-match\": \"^1.0.0\",\n\"concat-map\": \"0.0.1\"\n\"code-point-at\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"concat-map\": {\n\"version\": \"0.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"console-control-strings\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"core-util-is\": {\n\"version\": \"1.0.2\",\n\"inherits\": {\n\"version\": \"2.0.3\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"ini\": {\n\"version\": \"1.3.5\",\n\"version\": \"1.0.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"number-is-nan\": \"^1.0.0\"\n}\n\"version\": \"3.0.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"brace-expansion\": \"^1.1.7\"\n}\n\"minimist\": {\n\"version\": \"0.0.8\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"minipass\": {\n\"version\": \"2.2.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"safe-buffer\": \"^5.1.1\",\n\"yallist\": \"^3.0.0\"\n\"yallist\": {\n\"version\": \"3.0.2\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n}\n}\n},\n\"version\": \"0.5.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"minimist\": \"0.0.8\"\n}\n\"number-is-nan\": {\n\"version\": \"1.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"object-assign\": {\n\"version\": \"4.1.1\",\n\"version\": \"1.4.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"wrappy\": \"1\"\n}\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"code-point-at\": \"^1.0.0\",\n\"is-fullwidth-code-point\": \"^1.0.0\",\n\"balanced-match\": {\n\"version\": \"1.0.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"brace-expansion\": {\n\"version\": \"1.1.11\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"balanced-match\": \"^1.0.0\",\n\"concat-map\": \"0.0.1\"\n\"code-point-at\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"concat-map\": {\n\"version\": \"0.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"console-control-strings\": {\n\"version\": \"1.1.0\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"core-util-is\": {\n\"version\": \"1.0.2\",\n\"inherits\": {\n\"version\": \"2.0.3\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"ini\": {\n\"version\": \"1.3.5\",\n\"version\": \"1.0.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"number-is-nan\": \"^1.0.0\"\n}\n\"version\": \"3.0.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"brace-expansion\": \"^1.1.7\"\n}\n\"minimist\": {\n\"version\": \"0.0.8\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"minipass\": {\n\"version\": \"2.2.4\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"safe-buffer\": \"^5.1.1\",\n\"yallist\": \"^3.0.0\"\n\"version\": \"0.5.1\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"minimist\": \"0.0.8\"\n}\n\"number-is-nan\": {\n\"version\": \"1.0.1\",\n\"bundled\": true,\n- \"dev\": true,\n- \"optional\": true\n+ \"dev\": true\n},\n\"object-assign\": {\n\"version\": \"4.1.1\",\n\"version\": \"1.4.0\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"wrappy\": \"1\"\n}\n\"version\": \"1.0.2\",\n\"bundled\": true,\n\"dev\": true,\n- \"optional\": true,\n\"requires\": {\n\"code-point-at\": \"^1.0.0\",\n\"is-fullwidth-code-point\": \"^1.0.0\",\n\"integrity\": \"sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=\",\n\"dev\": true\n},\n+ \"p-iteration\": {\n+ \"version\": \"1.1.7\",\n+ \"resolved\": \"https://registry.npmjs.org/p-iteration/-/p-iteration-1.1.7.tgz\",\n+ \"integrity\": \"sha512-VsYvUPjm2edbKkX4QzlASC1qB2e4Z6IE9WPaRVHKwCtobmB6vfUcU9eBOwj1k5uMNi8O6w89QfsDatO5ePSjQg==\"\n+ },\n\"p-limit\": {\n\"version\": \"1.3.0\",\n\"resolved\": \"https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"lowdb\": \"1.0.0\",\n\"merge\": \"1.2.1\",\n\"mustache\": \"3.0.1\",\n+ \"p-iteration\": \"1.1.7\",\n\"selectn\": \"1.1.2\",\n\"time-ago\": \"0.2.1\",\n\"ws\": \"6.1.2\"\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Added 'in group' logic to get-entities
Will check if entity_id is a Home Assistant group |
748,234 | 01.01.2019 20:42:01 | 28,800 | 89d396872b66929490bd73d60b45a52b530ed951 | Feature: Added autocomplete for multiple entity ids to call-service node | [
{
"change_type": "MODIFY",
"old_path": "nodes/call-service/call-service.html",
"new_path": "nodes/call-service/call-service.html",
"diff": "setServicesAndDomains(node);\n$.getJSON(`homeassistant/${serverId}/entities`)\n.done(entities => {\n- this.availableEntities = entities;\n+ _self = this;\n+ _self.availableEntities = entities;\n- $entityIdField.autocomplete({\n- source: this.availableEntities,\n- minLength: 0\n+ function split(val) {\n+ return val.split(/,\\s*/);\n+ }\n+ function extractLast(term) {\n+ return split(term).pop();\n+ }\n+\n+ $entityIdField\n+ .on(\"keydown\", function(event) {\n+ if (\n+ event.keyCode === $.ui.keyCode.TAB &&\n+ $(this)\n+ .autocomplete()\n+ .data(\"uiAutocomplete\").menu.active\n+ ) {\n+ event.preventDefault();\n+ }\n+ })\n+ .autocomplete({\n+ source: _self.availableEntities,\n+ minLength: 0,\n+ source: function(request, response) {\n+ // delegate back to autocomplete, but extract the last term\n+ response(\n+ $.ui.autocomplete.filter(\n+ _self.availableEntities,\n+ extractLast(request.term)\n+ )\n+ );\n+ },\n+ focus: function() {\n+ // prevent value inserted on focus\n+ return false;\n+ },\n+ select: function(event, ui) {\n+ var terms = split(this.value);\n+ // remove the current input\n+ terms.pop();\n+ // add the selected item\n+ terms.push(ui.item.value);\n+ // add placeholder to get the comma-and-space at the end\n+ terms.push(\"\");\n+ this.value = terms.join(\", \");\n+ return false;\n+ }\n});\n})\n.fail(err => {\nthis.service_domain === \"homeassistant\" &&\nentityId.indexOf(\",\") !== -1\n) {\n- entityId = entityId.replace(/\\s/g, \"\").split(\",\");\n+ entityId = entityId\n+ .replace(/\\s/g, \"\") // remove spaces\n+ .replace(/\\s*,\\s*$/, \"\") // remove trailing comma\n+ .split(\",\");\n+ } else {\n+ entityId = entityId.replace(/\\s*,\\s*$/, \"\"); // remove trailing comma\n}\ntry {\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Feature: Added autocomplete for multiple entity ids to call-service node |
748,234 | 01.01.2019 21:18:48 | 28,800 | 6a94f08ca9ede8f3ec8e4c4431f18fba85c653b6 | style(get-history): format changes | [
{
"change_type": "MODIFY",
"old_path": "nodes/get-history/get-history.html",
"new_path": "nodes/get-history/get-history.html",
"diff": "<div class=\"form-tips\">\n<ul>\n- <li>\n- dates must be in ISO format, example: \"2018-01-27T13:00:00+00:00\"\n- </li>\n+ <li>dates must be in ISO format, example: \"2018-01-27T13:00:00+00:00\"</li>\n</ul>\n</div>\n</script>\n<h3>Inputs</h3>\n<dl class=\"message-properties\">\n- <dt class=\"optional\">\n- startdate <span class=\"property-type\">string | date</span>\n- </dt>\n+ <dt class=\"optional\">startdate <span class=\"property-type\">string | date</span></dt>\n<dd>Date to start fetching history from. Will override the nodes configuration if passed in</dd>\n- <dt class=\"optional\">\n- enddate <span class=\"property-type\">string | date</span>\n- </dt>\n+ <dt class=\"optional\">enddate <span class=\"property-type\">string | date</span></dt>\n<dd>Date to fetch history to. Will override the nodes configuration if passed in</dd>\n- <dt class=\"optional\">\n- entityid <span class=\"property-type\">string</span>\n- </dt>\n+ <dt class=\"optional\">entityid <span class=\"property-type\">string</span></dt>\n<dd>Exact entity_id to fetch history for, must be an exact match as is passed directly to the home-assistant api</dd>\n</dl>\n<h3>Outputs</h3>\n<dl class=\"message-properties\">\n- <dt>\n- payload <span class=\"property-type\">array</span>\n+ <dt>payload <span class=\"property-type\">array</span>\n</dt>\n<dd>The history returned by home-assistant, which is an array of arrays where each array entry contains history objects for one particular entity</dd>\n- <dt>\n- startdate <span class=\"property-type\">string</span>\n- </dt>\n+ <dt>startdate <span class=\"property-type\">string</span></dt>\n<dd>ISO date string used to fetch history</dd>\n- <dt>\n- enddate <span class=\"property-type\">string</span>\n- </dt>\n+ <dt>enddate <span class=\"property-type\">string</span></dt>\n<dd>ISO date string used to fetch history</dd>\n- <dt>\n- entityid <span class=\"property-type\">string</span>\n- </dt>\n+ <dt> entityid <span class=\"property-type\">string</span></dt>\n<dd>entityid string used during fetch history call</dd>\n- <dt>\n- entityidtype <span class=\"property-type\">string</span>\n- </dt>\n- <dd>'is' or 'includes' depending on match type. NOTE: 'includes' fetches all history for time period then filters according to value, this will be less performant than exact ('is') matching</dd>\n+ <dt> entityidtype <span class=\"property-type\">string</span></dt>\n+ <dd> 'is ' or 'includes ' depending on match type. NOTE: 'includes ' fetches all history for time period then filters according to value, this will be less performant than exact ( 'is ') matching</dd>\n</dl>\n<h3>Details</h3>\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | style(get-history): format changes |
748,234 | 07.01.2019 08:46:38 | 28,800 | 7ccc35e03bb1471f60d3f2a63fc2b502b1156d88 | Fix: HomeAssistant object updated before firing state_change event
Fixes | [
{
"change_type": "MODIFY",
"old_path": "lib/ha-websocket.js",
"new_path": "lib/ha-websocket.js",
"diff": "@@ -129,30 +129,30 @@ class HaWebsocket extends EventEmitter {\nreturn;\n}\n- // Most specific emit for event_type and entity_id\n- if (emitEvent.event_type && emitEvent.entity_id) {\nif (\n+ emitEvent.entity_id &&\nemitEvent.event_type === 'state_changed' &&\nemitEvent.event &&\nemitEvent.event.new_state\n) {\n- this.states[emitEvent.entity_id] =\n- emitEvent.event.new_state;\n+ this.states[emitEvent.entity_id] = emitEvent.event.new_state;\n}\n+ // Emit on the event type channel\n+ if (emitEvent.event_type) {\n+ this.emit(`ha_events:${msg.event_type}`, emitEvent);\n+\n+ // Most specific emit for event_type and entity_id\n+ if (emitEvent.entity_id) {\nthis.emit(\n`ha_events:${msg.event_type}:${emitEvent.entity_id}`,\nemitEvent\n);\n}\n+ }\n// Emit on all channel\nthis.emit('ha_events:all', emitEvent);\n-\n- // Emit on the event type channel\n- if (emitEvent.event_type) {\n- this.emit(`ha_events:${msg.event_type}`, emitEvent);\n- }\n}\n}\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Fix: HomeAssistant object updated before firing state_change event
Fixes #74 |
748,234 | 07.01.2019 08:47:20 | 28,800 | d2f96cd9063db466c6d7ea53763c1bc2b6e1be72 | Stale bot config changes | [
{
"change_type": "MODIFY",
"old_path": ".github/stale.yml",
"new_path": ".github/stale.yml",
"diff": "@@ -4,10 +4,11 @@ daysUntilStale: 30\ndaysUntilClose: 7\n# Issues with these labels will never be considered stale\nexemptLabels:\n- - pinned\n- - security\n+ - \"Type: Bug\"\n+ - \"Type: Refactoring\"\n+ - \"Type: Documentation\"\n# Label to use when marking an issue as stale\n-# staleLabel: wontfix\n+staleLabel: stale\n# Comment to post when marking an issue as stale. Set to `false` to disable\nmarkComment: >\nThis issue has been automatically marked as stale because it has not had\n"
}
] | TypeScript | MIT License | zachowj/node-red-contrib-home-assistant-websocket | Stale bot config changes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.