Item expire triggers when linked with two buttons

Hey there,

i have a quite simple setup i wanted to build, thought it would go great with expire, but my logic was flawed. Maybe i missed something, otherwise i guess i would have to work with rules.

So i am using expire because i wanted to have different setups for a light. Plan was to do it simply like this:

Switch Steckdose_Garage { expire=“62m,command=OFF” }
Switch Steckdose_Garage_Dauerhaft

And both get linked to the Switch. Now here comes the problem: If i click the item without expire, the expire one will get an update too, thus triggering the timer.

Is there any easy way around this, or do i need a rule with “if item changed” ?

Thank you :slight_smile:

That’s expected behavior. As the expiration is controlled via status, you simply can’t set it this way. Instead you’ll have to use a simple rule.

Switch Steckdose_Garage { expire="62m,command=OFF" } // no channel link!
Switch Steckdose_Garage_Dauerhaft { channel="..." } 

The rule (DSL, but of course you are free to use whatever you want to):

rule "Garagen Timer"
when
    Item Steckdose_Garage received command
then
    Steckdose_Garage_Dauerhaft.sendCommand(receivedCommand)
end

So the rule will simply do a one-way link between the items (i.e. commands are transferred, but not the state)

Hey there,

thank you i just tried it, i get your logic and i´d guess it should work. But unfortunately the predictions are somehow making it not work. I unlinked the one with the timer, and this is what the logs show now:

2024-05-27 12:29:09.376 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘Steckdose_Garage’ received command ON
2024-05-27 12:29:09.378 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘Steckdose_Garage’ predicted to become OFF
2024-05-27 12:29:09.379 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘Steckdose_Garage_Dauerhaft’ received command ON
2024-05-27 12:29:09.383 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘Steckdose_Garage_Dauerhaft’ predicted to become ON

He is predicting, but the one with the timer goes on and off directly, while i cant even see the other one doing anything.

Super confusing. Will have to try and search where this comes from.

Short update - got it. Was a misstake in my sitemap. While trying around i just copied the other switch and forgot to rename it to the item without a timer.

Thank you - solved :slight_smile:

1 Like

There is another simple way to achieve this without a rule: the follow profile which establishes a one-way direction on the link between an item and a channel. This is how I do this.

So, for example with the outlet in my garage I have one regular item linked directly to the outlet

But sometimes I want to charge my scooter from the outlet which should always take less than 5 hours (and I don’t want to leave it charging so it doesn’t catch fire and burn my house down) so I have a second item with a 5 hour expire setting that is also linked to the outlet but using the follow profile

Because of the follow profile changes to the channel either from the regular item or the outlet itself are not passed to the item with the expire timer. So switching on the outlet normally does not trigger the expire countdown. On the other hand, changes from the expire item are passed through the link to the channel so if I use the scooter switch it does turn on the outlet and start the countdown and, then expire turns the outlet off again after the appropriate duration.

2 Likes