Here’s the function node I use to set the led status lights. The default I use is all lights off and the main button on only when the light is on.
[{"id":"6c0c3dd0d976bfd1","type":"server-state-changed","z":"1a9590f5.2d236f","name":"doors/windows/alarm","server":"","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":["alarm_control_panel.alarm","binary_sensor.back_door","cover.garage_door"],"entityidfiltertype":"list","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":484,"y":3376,"wires":[["b4391a5b2f70b141"]]},{"id":"b4391a5b2f70b141","type":"trigger","z":"1a9590f5.2d236f","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"1","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":625,"y":3376,"wires":[["b96cbf9b30236f3e"]],"l":false},{"id":"b96cbf9b30236f3e","type":"function","z":"1a9590f5.2d236f","name":"build","func":"const entities = global.get(\"homeassistant\").homeAssistant.states\nconst isAlarmArmed = [\"armed_home\", \"armed_night\", \"armed_away\"].includes(entities['alarm_control_panel.alarm'].state);\nconst isSleeping = entities['input_boolean.sleep_mode'].state === \"on\";\nconst isGarageOpen = entities['cover.garage_door'].state !== \"closed\";\nconst isBackDoorOpen = entities['binary_sensor.back_door'].state !== \"off\";\n\nconst state = {\n on: 3,\n off: 2,\n loadOn: 1,\n loadOff: 0,\n};\nconst color = {\n white: 0,\n blue: 1,\n green: 2,\n red: 3,\n};\nconst brightness = {\n bright: 0, // 100%\n medium: 1, // 60%\n low: 2, // 30%\n};\nconst properties = {\n indicator: \"LED Indicator\",\n color: \"LED Indicator Color\",\n brightness: \"LED Indicator Brightness\"\n};\nconst values = {\n indicator: [1,2,2,2,2],\n color: [0,0,0,0,0],\n brightness: [1,1,1,1,1],\n};\n\nif(!isSleeping) { \n // Show alarm armed\n if(isAlarmArmed) {\n values.indicator[1] = state.on;\n values.color[1] = color.red;\n }\n}\nif(isGarageOpen || isBackDoorOpen) {\n const both = isGarageOpen && isBackDoorOpen;\n values.indicator[2] = state.on;\n values.color[2] = both ? color.blue : color.green;\n}\n// node.warn(values);\nupdateLeds();\n\nfunction getParameterName(property, index) {\n const buttonName = `(${index === 0 ? 'Relay' : `Button ${index}`})`;\n return `${properties[property]} ${buttonName}`\n}\n\nfunction send(property, index, value) {\n node.send({\n payload: {\n data: {\n parameter: getParameterName(property, index),\n value\n }\n }\n });\n}\n\nfunction updateLeds() {\n Object.keys(properties).forEach((property) => {\n values[property].forEach((value, index) => {\n send(property, index, value)\n });\n });\n\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":738,"y":3376,"wires":[["5d91bd48f4645dbf"]]},{"id":"5d91bd48f4645dbf","type":"api-call-service","z":"1a9590f5.2d236f","name":"","server":"","version":5,"debugenabled":false,"domain":"zwave_js","service":"set_config_parameter","areaId":[],"deviceId":[],"entityId":["switch.bedroom_light"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":958,"y":3376,"wires":[[]]}]
const entities = global.get("homeassistant").homeAssistant.states
const isAlarmArmed = ["armed_home", "armed_night", "armed_away"].includes(entities['alarm_control_panel.alarm'].state);
const isSleeping = entities['input_boolean.sleep_mode'].state === "on";
const isGarageOpen = entities['cover.garage_door'].state !== "closed";
const isBackDoorOpen = entities['binary_sensor.back_door'].state !== "off";
const state = {
on: 3,
off: 2,
loadOn: 1,
loadOff: 0,
};
const color = {
white: 0,
blue: 1,
green: 2,
red: 3,
};
const brightness = {
bright: 0, // 100%
medium: 1, // 60%
low: 2, // 30%
};
const properties = {
indicator: "LED Indicator",
color: "LED Indicator Color",
brightness: "LED Indicator Brightness"
};
const values = {
indicator: [1,2,2,2,2],
color: [0,0,0,0,0],
brightness: [1,1,1,1,1],
};
if(!isSleeping) {
// Show alarm armed
if(isAlarmArmed) {
values.indicator[1] = state.on;
values.color[1] = color.red;
}
}
if(isGarageOpen || isBackDoorOpen) {
const both = isGarageOpen && isBackDoorOpen;
values.indicator[2] = state.on;
values.color[2] = both ? color.blue : color.green;
}
// node.warn(values);
updateLeds();
function getParameterName(property, index) {
const buttonName = `(${index === 0 ? 'Relay' : `Button ${index}`})`;
return `${properties[property]} ${buttonName}`
}
function send(property, index, value) {
node.send({
payload: {
data: {
parameter: getParameterName(property, index),
value
}
}
});
}
function updateLeds() {
Object.keys(properties).forEach((property) => {
values[property].forEach((value, index) => {
send(property, index, value)
});
});
}