Börja med att definiera en ny device med namnet "ModeAttr" i TelldusCenter samt starta om NexaHome.
Skriv in nedanstående i Parameters fältet på Device raden.
Skapa en bsh fil vars namn är lika med dess Id.dummy:yes
Exempelvis 43.bsh
Code: Select all
import java.text.SimpleDateFormat;
if (deviceIsOn("ModeAttr")) {
// *** Holiday check begin ***
holiday_attribute = "Holiday";
String[] holiday_array = {
// "2012-03-25" /* Just testing... */,
"2012-01-01" /* Nyårsdagen */,
"2012-01-06" /* Trettondedag jul */,
"2012-04-06" /* Långfredagen */,
"2012-04-09" /* Annandag påsk */,
"2012-05-01" /* Valborg, Första Maj */,
"2012-05-17" /* Kristi Himmelsfärdsdag */,
"2012-06-06" /* Sveriges Nationaldag och Svenska flaggans dag */,
"2012-06-23" /* Midsommardagen */,
"2012-10-03" /* Alla Helgons dag */,
"2012-12-25" /* Juldagen */,
"2012-12-26" /* Annandag Jul */
};
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
date = sdf.format(Calendar.getInstance().getTime());
holiday_flag = false;
for (int ndx = 0; ndx < holiday_array.length; ndx++) {
if (date.equals(holiday_array[ndx])) {
holiday_flag = true;
break;
}
}
attributes = "";
if (holiday_flag && !attributeIsOn(holiday_attribute)) {
if (attributes.length() != 0) {
attributes = attributes + ",";
}
attributes = attributes + holiday_attribute + ":set";
} else if (!holiday_flag && attributeIsOn(holiday_attribute)) {
if (attributes.length() != 0) {
attributes = attributes + ",";
}
attributes = attributes + holiday_attribute + ":clear";
}
// *** Holiday check end ***
// *** Workday check begin ***
// Put a copy of the holiday code here and modify it...
// *** Workday check end ***
if (attributes.length() != 0) {
attribute(attributes);
}
}
Lägg in följande rader i start.bsh
Code: Select all
deviceOn("ModeAttr");
deviceOff("ModeAttr");
Device "ModeAttr" On 00:00
Device "ModeAttr" Off 00:01