If you just want to restart the thing, send an HTTP request to the REST API. To authenticate the request, you’ll need to allow basic authentication in MainUI and create an API token. Put the token in a variable in your rule, and then call the variable in your HTTP request.
Here’s a good explanation for defining the API token variable.
Your HTTP request will look like this:
sendHttpPutRequest("http://openhab-IP-addess:8080/rest/things/INSERT-THING-ID-HERE/enable", "application/json", 'true', headers, 1000)
true
enables the thing, and false
disables it.
UPDATE: This work up until OH 3.1, but in OH3.2 you need to change application/json
to text/plain
.
You can trigger a rule based on a thing’s status changing, but I wouldn’t bother. Instead of waiting for it to fail, just use a cron trigger to disable/enable the thing on a schedule.
Of course, this is just a workaround that doesn’t actually solve the issue of the gateway going offline. I don’t use the Xiaomi binding, so I don’t know if that’s typical/expected behaviour, if it’s a bug that you should investigate with the developer, or if it’s a sign of bigger problems with your system.