Jeevs
(Jeewan Bahra)
April 21, 2019, 7:50pm
1
Hi all,
I’ve created a new rule to bring up/down my HD Blinds based on time of day of a previous rule.
However, it just doesnt seem to be triggering.
Please see rule below:
// All Blinds Up/Down
rule “Blinds Up/Down”
when
Item vTimeOfDay changed
then
val blindLog = “Blinds”
if (vTimeOfDay == “MORNING”) {
Kitchen_Blind.sendCommand(0)
Conservatory_Left.sendCommand(0)
Conservatory_Door.sendCommand(0)
Conservatory_Right.sendCommand(0)
logInfo(blindLog, blindLog + " going up")
} else if (vTimeOfDay == “SUNSET”) {
Kitchen_Blind.sendCommand(100)
Conservatory_Left.sendCommand(100)
Conservatory_Door.sendCommand(100)
Conservatory_Right.sendCommand(100)
logInfo(blindLog, blindLog + " going down")
}
end
Any ideas on what could potentially be wrong with the above? Any help would be greatly appreciated
Many thanks,
RolfV
(Rolf Vermeer)
April 21, 2019, 7:56pm
2
vTimeOfDay
is an item, so you should use vTimeOfDay.state == ""
.
Furthermore, use logInfo
directly after the then
, to check if the rule gets triggered at all.
1 Like
Jeevs
(Jeewan Bahra)
April 21, 2019, 8:07pm
3
Thanks for the quick response.
I’ve made the below change:
// All Blinds Up/Down
rule “Blinds Up/Down”
when
Item vTimeOfDay changed
then
val blindLog = “Blinds”
logInfo(blindLog, “Blinds Auto Trigger”)
if (vTimeOfDay.state == “MORNING”) {
Kitchen_Blind.sendCommand(0)
Conservatory_Left.sendCommand(0)
Conservatory_Door.sendCommand(0)
Conservatory_Right.sendCommand(0)
logInfo(blindLog, blindLog + " going up")
} else if (vTimeOfDay.state == “SUNSET”) {
Kitchen_Blind.sendCommand(100)
Conservatory_Left.sendCommand(100)
Conservatory_Door.sendCommand(100)
Conservatory_Right.sendCommand(100)
logInfo(blindLog, blindLog + " going down")
}
end
However, still doesnt seem to work. In my logsv I can see vTimeOfDay change:
2019-04-21 21:05:52.339 [ome.event.ItemCommandEvent] - Item ‘vTimeOfDay’ received command SUNSET
What could i be doing wrong?
Thanks,
RolfV
(Rolf Vermeer)
April 21, 2019, 8:11pm
4
No errors in openhab.log concerning this rules file?
Jeevs
(Jeewan Bahra)
April 21, 2019, 8:19pm
5
Absolutley nothing no idea what I’m doing wrong here!
If it helps, I’m using the below DP to trigger my rule:
Consider when these values get calculated.
bed_start get’s calculated for today. sunrise_start get’s calculated for today. So
bed_start = 2019-04-18 23:00
sunrise_start = 2019-04-18 06:20
Your last case can never be true between 2019-04-18 23:00 and 2019-04-19 00:00 (or whenever Astro generates the sunrise start time for the new day).
The switch statement works in the OP because bed_time is 2019-04-19 00:00 so there isn’t that gap between when bedtime starts and Astro recalculates the …
RolfV
(Rolf Vermeer)
April 21, 2019, 8:26pm
6
Let’s go back to basic. Remove the comment before rule
, and remove the val definition and make the arguments of logInfo
literal strings, and remove everything else.
1 Like
Jeevs
(Jeewan Bahra)
April 21, 2019, 8:38pm
7
@RolfV Just figured out why this wasnt triggering. It was looking for a ‘received command’ rather than ‘changed’ in the trigger.
Thank you so much for your help!
RolfV
(Rolf Vermeer)
April 21, 2019, 8:53pm
8
Ah it didn’t change when it became “Sunset”…
1 Like