Restart a thing if connection is lost or if no new data within xx seconds

Hi everybody,
i have a little problem, i have some “things” witch stop recivieng data from here to then. i hafe to disable the thing and enable it again and everything starts working again.
now i searching for a solution witch check the last timestemp of the last recive from an item and the connection state from a thing and if the connection is lost or the last timestemp of an item is older than xx secionds than i want to disable and enable the thing to get it back to work.
so has someone a hint or a solution for me?
thanks in advanced

To get the time off the last update: you can use a profile

To detect thing status: that’s available via rules, you can even trigger a rule of a thing status is changing

a profile? hmm i have to look who this works.
ok the rule have i seen put how can i do an “disable” and “enable” or restart of a thing. i don´t find this in blocky. or do i have to write a rule by my self?

You need to use the restapi the enable / disable a thing.
If you search the forum, you should find several examples

I don’t know how to do that in Blockly, but in RulesDSL it’s something like this.

Note that this is an OH3 example, and may have changed somewhat in OH4.

I recommend disabling/enabling on a schedule so that you’re being proactive. Then it’s a simple CRON rule that doesn’t care about the actual status of the thing.

tactical fix yea sure set up a rule and reinitialize the thing on a recurring basis.
long term strategic fix trouble shoot why you are having to take this action.
What is actually causing the thing to become unresponsive is what I would be chasing if this was happening on my systems.

In JS Scripting there is a setEnabled() function you can use to enable/disable the Thing.

In the Marketplace there is a generic rule template you can install and use to call a rule of the own when the Things go OFFLINE.

If the Thing remains ONLINE and you can only detect it’s broken because some Items so updating, you can use the Threshold Alert rule template to again call a rule of your own when an Item doesn’t update for a given amount if time. Threshold Alert and Open Reminder [;]

The hard part will be mapping the Item to the Thing which isn’t so easy. I would add that as Item metadata.

Is this something (relatively) new?

Not really. I think it’s been a part of the GraalVM JS helper library since the beginning. I know there is similar functionality in jRuby as well.

1 Like

Hi everyone and happy new year. sorry for late response. so where can i find the profiles in the gui? so that i have a timestamp for an item? the rest api trigger i can build that will not be a problem but finding the profiles is hard for me at the moment or i am blind :wink:

probably :wink:
Whenever you create an item from a channel you can select a profile. Usually the default “Standard” is kept but you can select the timestamp too.
You can change the profile afterwards too (things - select it - channels - select item - scroll down)

1 Like

Did you mean that here?

Yes, he means this profiles.
Go to the channel, link new item, create a datetime item, then you can select time profile last change (zeitstempel bei Änderung)

1 Like