No that would not work. Rule triggers are event based, not state based so it makes no sense to use AND in a rule trigger. Those two events will never occur at the same time (note the event for “get.timeofday > 18” would only occur one second after 17:59).
See this posting for how I handle this.
The tl;dr of it is I have a String Item that gets set to a string representing the current time of day (Morning, Day, Evening, Night) and rules that change this Item based on times and/or Astro events. For example, Evening starts 90 minutes before sunset as calculated by Astro and ends at 11:00 pm.
In the rest of my rules, when I need to do something at the time of day change I trigger on updates to my TimeOfDay Item. In other rules that care about what the time of day is to determine behavior (e.g. you only want to run your logic during one period of day) I check to see if the TimeOfDay is currently set to the right time.
So, assuming you implemented my rule like this your rule would become:
rule "LivingLightOnWhenDark"
when
Item Lum_Sensor changed
then
if(TimeOfDay.state.toString == "Evening") {
if(Lum_Sensor.state < 500 && Lum_Sensor.state > 300){
logInfo("Staanlamp", "Auto On")
sendCommand(Staanlamp, 50)
}
}
end
If you think your system will eventually grow into needing other rules that care about the time of day I highly recommend this approach. However, if you think you will only ever care about evening in this one rule, your rule would look like this (assuming your evening starts at 7:00 pm and ends at 10:00 pm:
rule "LivingLightOnWhenDark"
when
Item Lum_Sensor changed
then
val eveningStart = now.withTimeAtStartOfDay.plusHours(19).millis
val eveningEnd = now.withTimeAtStartOfDay.plusHours(22).millis
if(now.millis > eveningStart && now.millis < eveningEnd) {
if(Lum_Sensor.state < 500 && Lum_Sensor.state > 300){
logInfo("Staanlamp", "Auto On")
sendCommand(Staanlamp, 50)
}
}
end
See my posting above to see how to incorporate Astro calculated sunset into figuring out when evening starts.