Hey Scott - yes, I am using the helper libraries. Downloaded this weekend.
This is the rule I was talking about. In this case, I am trying to trigger this from any command to item “vTimeOfDay”.
As a side note - you will notice I have a sleep(1000), which is a separate JS function in this script file since JS does not have sleep. I can post that, or you can just comment out.
JSRule({
name: "JM Blinds and Curtains Control",
description: "Opens + Closes on Schedule",
triggers: [
CommandEventTrigger("vTimeOfDay")
],
execute: function (module, input) {
sleep(1000);
var currentTimeOfDay = items["vTimeOfDay"].toString();
if (items["JM_Sleeping_In"] !== ON) {
switch (currentTimeOfDay) {
case 'BED':
sendCommand("JohnSBlinds_", 0);
sendCommand("JM_Curtains_CommandString", "CLOSE");
logInfo("Blinds Control - Bed Complete");
break;
case 'MORNING':
sendCommand("JohnSBlinds_", 85);
sendCommand("JM_Curtains_CommandString", "OPEN");
logInfo("Blinds Control - Morning Complete");
break;
case 'NOON':
sendCommand("JohnSBlinds_", 30);
logInfo("Blinds Control - Noon Complete");
break;
case 'AFTERNOON':
sendCommand("JohnSBlinds_", 50);
logInfo("Blinds Control - Afternoon Complete");
break;
case 'NIGHT':
sendCommand("JohnSBlinds_", 85);
logInfo("Blinds Control - Night Complete");
break;
default:
logInfo(currentTimeOfDay + " - I did nothing.");
return;
}
logInfo("Blinds Control - vTime is " + currentTimeOfDay);
return;
} else {
logInfo("John is sleeping in.");
}
}
});```