Hi all,
I am having issues successfully creating vacations within Ecobee javascript rules.
OH 4.2.1 on Windows 10.
I think I am having issues properly defining the QuantityType values for the heat and cool setpoints. Below is my Javascript rule:
var push = actions.thingActions("pushover", "pushover:pushover-account:8418ffd5d7");
try {
// Import necessary Java classes
var QuantityType = Java.type('org.openhab.core.library.types.QuantityType');
var ZonedDateTime = Java.type('java.time.ZonedDateTime');
var SimpleDateFormat = Java.type('java.text.SimpleDateFormat');
var Date = Java.type('java.util.Date');
var ecobeeActions = actions.thingActions("ecobee","ecobee:thermostat:beb50b877a:412870797948");
//var coolTarg = 81|°F
//var heatTarg = 55|°F
var coolTarg = new QuantityType("82 °F");
var heatTarg = new QuantityType("54 °F");
var nowDT = ZonedDateTime.now();
if(items.MQTT_HMI_VacationEnd_DateTime.state.toString() == "NULL") {
push.sendMessage("Vacation end time is NULL, cannot begin Ecobee vacation period, you must do this manually.", "Liberty OpenHAB");
} else {
var dtEndVacationStr = items.MQTT_HMI_VacationEnd_DateTime.state.toString();
// Define the format pattern that matches the incoming DateTime string
var sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
var parsedEndVacDateTime = sdf.parse(dtEndVacationStr);
console.log("Ecobee vacation test", "parsed end date: " + parsedEndVacDateTime)
// Add 2 days to the current datetime
//var nowDTplus2 = nowDT.plusHours(48);
console.log("Setting Ecobee vacation with coolTarg: " + coolTarg + " and heatTarg: " + heatTarg);
result = ecobeeActions.createVacation("OH-Vacation", coolTarg, heatTarg, nowDT, parsedEndVacDateTime, 'auto', 0);
if(result == false) {
console.log("Ecobee vacation test", "Ecobee vacation creation failed")
push.sendMessage("Ecobee vacation creation FAILED, please investigate.", "Liberty OpenHAB");
} else if(result == true) {
console.log("Ecobee vacation test", "Ecobee vacation creation SUCCEEDED")
push.sendMessage("Ecobee vacation created successfully, ending " + dtEndVacationStr, "Liberty OpenHAB");
}
}
} catch(err) {
console.error("Something bad happened in Ecobee vacation creation: " + err.message);
}
This runs successfully, a vacation is created in the Ecobee account, but I always get cool and heat setpoints showing up improperly in the Ecobee app, sometimes as 8 degF and 6 degF, respectively, and sometimes as 65 degF and 45 degF.
The console.log comment directly above the vacation creation line prints out:
2024-09-09 17:05:52.348 [INFO ] [nhab.automation.script.ui.d779c6e43b] - Setting Ecobee vacation with coolTarg: 82 and heatTarg: 55
Am I defining the QuantityType values improperly?
When the vacation name says it needs to be ‘unique’ in the docs, what does that actually mean? Do I need to define and save a truly unique UUID? or does it just need to be unique compared to any other currently-existing Ecobee vacations?
Thanks for any help.