Astro event not triggering

Hello,

I’m trying to use the Astro binding to turn on a few rules, but it’s not working.

The idea is to have a time frame where Openhab checks the Lux values, and closes the blinds when it’s dark enough.

We had some dark clouds last winter that closed the blinds in the afternoon.
I’m hoping with the time slot from the Astro binding that won’t happen anymore :slight_smile:

I selected the channel trigger for sunset, and used START as the event.
There is a second rule where i use END as event to disable the rules again.

The rules are not enabled/disabled.

Should i use an Item instead of a trigger?

Thanks in advance for your help!

There’s more to this than you’ve shown here required to make this work.

You can make it work using the event triggers, but that’s probably not the best way. Trigers are not states. They are events. Your rule will run the instant that the set event starts (given the screen shot).

But what do you do with that? Do you set the state of an Item?

Based on your requirements you need to check the Lux values to decide when to close the blinds. And you want to add an additional condition to not close the blinds between certain times even if the Lux says it should.

Triggering a rule based on these times may help achieve that. But it depends on what you do with that event in that rule. Triggering your blinds rule isn’t going to be the one to trigger with this event.

So you have a start time and an end time where you don’t want the blinds rule rule to run.

So put the start time in an Item, I’ll call it SunriseTime.
Put the end time in an Item, I’ll call it SunsetTime.
In the blinds rule, add an Inline Script condition that checks to see if you are in between those two times. If not return false and the rule to close the blinds won’t run.

In Blockly you can use the Rules Blockly - Date Handling | openHAB block.

In JS (> OH 5.0):

time.toZDT().isBetweenTimes(items.SunriseTime, items.SunsetTime);

OH 5.1 +

return time.toZDT().isBetweenTimes(items.SunriseTime, items.SunsetTime);

Hi Rikoshak,

Thank you for this very usefull insight.

I made a rule that enabled all the blinds rules based on the START and END events of the astro channels. the lux was being checked on every change in those enabled rules.
When the sunset ended i had another rule to disable them again.

I followed your advice and made 2 items with start and end time,
and I added the time comparison to each rule separately.

I will let you know tomorrow evening if it worked :wink:

here’s one of the rules:

configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: light_sensor_Number_Value
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: Blinds_Blinds_Bedroom_1_Mode
      state: AUTO
      operator: =
    type: core.ItemStateCondition
  - inputs: {}
    id: "4"
    configuration:
      itemName: light_sensor_Number_Value
      state: "170"
      operator: <
    type: core.ItemStateCondition
  - inputs: {}
    id: "5"
    configuration:
      type: application/vnd.openhab.dsl.rule
      script: time.toZDT().isBetweenTimes(items.Local_Sun_Set_Start,
        items.Local_Sun_Set_End);
    type: script.ScriptCondition
actions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: BlindsBedroom1_BlindsBedroom1
      command: DOWN
    type: core.ItemCommandAction
 

That’s actually a reasonable approach. I often don’t jump to enabling/disabling rules because a lot of newer users don’t always understand what that means, but it’s perfectly acceptable, and it should have worked.

What didn’t work with that approach? The rules were not being disabled? Do your Local_Sun Items have a state other than NULL? If not all of this might be caused by something being wrong with your Astro Thing or the binding.

I still consider myself a beginner, since i have to ask for help with the syntax of scripts in my rules :slight_smile:

The rules i set up with your method work. The blinds went down.
Thanks for the help!

In the previous approach, the rules weren’t being enabled when the astro START trigger was sent.
I don’t know why, but with your approach it works :slight_smile:

I don’t think I’ve seen any reports of Astro events not working recently, but I’ll keep an eye out.

But in OH 5+ there really is nothing you can do with the Astro events that you can’t also achieve using DateTime Items linked to the desired state Channels. so if there is an issue it’s easy enough to sidestep.

I’m glad you got it working!