I’m currently using the following script provided by @watou, which provides the current day of the week.
// import org.openhab.core.library.types.StringType
// uncomment above on openHAB 1.x
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
rule SetDay
when
Time cron "0 0 0/1 1/1 * ? *"
then
var Calendar cal = Calendar::instance
var DateFormat fmt = new SimpleDateFormat("EEEE")
var String todayString = fmt.format(cal.time)
Today.postUpdate(todayString)
logInfo("SetDay","Today is " + todayString)
cal.add(Calendar::DAY_OF_YEAR, 1)
var String tomorrowString = fmt.format(cal.time)
Tomorrow.postUpdate(tomorrowString)
logInfo("SetDay","Tomorrow is " + tomorrowString)
cal.add(Calendar::DAY_OF_YEAR, 1)
var String dayAfterString = fmt.format(cal.time)
DayAfterTomorrow.postUpdate(dayAfterString)
logInfo("SetDay","Day After is " + dayAfterString)
end
A side note: I guess your rule says "normally " on Mondays take the bins out. Since there are some weeks in the year where this might get shifted I used a calendar object ( which could be filled with the data you get from the one who schedules the correct dates. This way you won’the get the reminder on a holiday! Which has happened to me.
Same sort of question, tried a few variances of the script but cannot get an output of any sort.
I have an item: Number openhabCommunityResult "[%.0f]" that produces a selection of different set of numbered results from a rule with the following possibilities:
0 - paused
1 - not checked yet
2 - up
8 - seems down
9 - down
What I would like to do is convert the number to text. I have tried using transform and the maps but I cannot get them to work for me… (unsure if there is an ongoing issue). What I currently have but doesn’t work is:
import org.openhab.core.library.types.
rule “OpenHAB Community Transform 0"
when
Item openhabCommunityResult received update
then
if (openhabCommunityResult == 2) {
communityResult.postUpdate("Community is Up!")
}
end
I’ve tried openhabCommunityResult.state == 2. I can’t remember the others I’ve tried but if you could help it would be great!
Try:
(openhabCommunityResult.state == 2)
that should work. check what the value of the item really is(either checking log file or via karaf console)
Maybe your rule for setting the item is flaky and it stays uninitialised?
HTH,
-OLI
P.S.: “Days Until Pay Day” - you really concentrate on the important things!
Can’t stop smiling…i always knew something important was missing in my setup!
Hmm, I think my issue must lay within the value to the item as I keep returning NULL on HABPanel…
Rule I have running for value:
import org.openhab.core.library.types.*
rule "Check Openhab Community"
when
Item UptimeRobotOpenhabCommunity_Output changed
then
var String UROC = UptimeRobotOpenhabCommunity_Output.state.toString
var String type = transform("JSONPATH", "$.monitors.[0]status", UROC)
logInfo("Testing", "Parse Json result = " + UROC)
openhabCommunityResult.postUpdate(new DecimalType(transform("JSONPATH", "$.monitors.[0]status", UROC)))
end