Sendcommand Rule with Astro-binding and earliest setting not working

I recently bought four smart plugs from tp-link that I’ve managed to get set up. Two of them are supposed to turn on and off my LEDs. I already tried it with Time cron, but the Astro binding I’ve found online is not working. I would really appreciate help because I can’t tell what I’ve done wrong.

astro.things

astro:sun:home [ geolocation=x,x,x", interval=60 ] {
    Channels:
        Type rangeEvent : set#event [
            earliest:"18:00"
            latest:"21:00"
        ]
}

astro.items

DateTime tSunrise "[%1$tH:%1$tM]" <sunrise> {channel="astro:sun:home:rise#START"}
DateTime tSunset  "[%1$tH:%1$tM]" <sunset>  {channel="astro:sun:home:set#START" }

sunset.rules

rule "sunset HS100c & HS100d"
when
    Channel 'astro:sun:home:rise#event' triggered START 
then
	sendCommand(HS100c, OFF)
	sendCommand(HS100d, OFF)
end

rule "turn off HS100c & HS100d"
when
	Time cron "0 30 22 1/1 * ? *"
then
	sendCommand(HS100c, OFF)
	sendCommand(HS100d, OFF)
end

Does triggering the HS100c with a switch work?
Does the cron triggered rule work?

Did you install the Astro Binding?

Use HS100c.sendCommand(OFF) instead of sendCommand(HS100c, OFF)

https://docs.openhab.org/configuration/rules-dsl.html#sendcommand-method-vs-action

or

Contrary, the Actions sendCommand(MyItem, “<new_state>”) and postUpdate(MyItem, “<new_state>”) can only accept strings as arguments.

sendCommand(HS100c, "OFF")

Yes, I am able to trigger the HS100c with a switch and with the cron trigger. I got the Astro binding installed.
When I used HS100c.sendCommand(OFF), the cron trigger didn’t work either. I will try your advice tomorrow though and give you another update. Thanks for the answer.

Just tried, and still. The switch works, the HS100*.sendCommand(ON) only works when using a cron trigger. Are you sure that my astro code is configured right?

Hidden quite well, the doc says start not START.
So do your Items work?

But the rule does not depend on the items.

Please look into paperUI if the astro binding is really installed as there is a bug which uninstalls bindings.

Do you have events in you log showing the astro binding working?

Add a log so you see if the rule gets trigger.

logInfo("RuleTest", "MyRulesTest")

please show all your items, ruels, sitmap files with regarding elements.

As the engine stops working propperly when there are other errors reduce yor setup to only the things you need. And reboot. Show this minimal example. And explain what you expect and what does not work in detail.
It is sometimes something different that causes the error. Have a look into your logfile.

Hello, sorry for the late reply. I rewrote my rules file with your tips and now it works. Thank you very much for giving me the tips, I’m really grateful :slight_smile: thank you.

1 Like

Could you post the solution here, please?
So anybody with similar problems sees how it’s done? Thanks

2 Likes

Sure I will.
I’m not sure if “latest” works, but I believe it should. Anyways, here’s my astro.things:

astro:sun:home [ geolocation="x,x,x", interval=60 ] {
    Channels:
        Type rangeEvent : set#event [
            earliest="18:00"
            ]
        Type rangeEvent : set#event [
            latest="21:00"
            ]
}

astro.items:

DateTime tSunrise "[%1$tH:%1$tM]" <sunrise> {channel="astro:sun:home:rise#start"}
DateTime tSunset  "[%1$tH:%1$tM]" <sunset>  {channel="astro:sun:home:set#start" }

time.rules:

rule "sunset"
when
    Channel "astro:sun:home:set#event" triggered START
then
	HS100c.sendCommand(OFF)
	HS100d.sendCommand(OFF)
end
2 Likes