Da es den Einen oder anderen gibt, der nach der Abschaltung der Livisi Cloud-Dienste weiterhin alles von unterwegs mit OpenHab steuern will benötigt den OpenHab Cloud-Connector.
Wie man diesen Einrichtet, habe ich schon einmal in einer Anleitung erwähnt. Nichts ist aber ärgerlicher, als dass der Cloud-Connector seinen Dienst verweigert und die Verbindung in die Cloud abbricht. Dann ist es auch nicht mehr möglich, von unterwegs auf das Smarthome zuzugreifen.
Es gibt aber eine Möglichkeit zu prüfen, ob der Dienst noch mit myOpenHab verbunden ist und diesen ggf. automatisch neu startet
Dazu habe ich in Openhab-Community folgende Anleitung gefunden der für mich auch gut funktioniert:
https://community.openhab.org/…cted-disconnection/143199
Hier der Original-Post aus obigem Link:
1. Install bindings and transformations
Start by installing these add-ons, if you don’t already have them:
2. Turn on Implicit User Role
Check that the Implicit User Role is ON
in your API Security settings (it most likely is).
3. Make an unbound item to store the testing message
Create a string item that has no channel attached to it. Mine is called myopenHAB_Connection
.
When the connnection test starts, the string will be updated to Testing
. We’ll then send a command through myopenHAB to change the string to Online
. If the command succeeds, it’s not necessary to restart the cloud connector.
If you want, you can add this item to a page or sitemap as an indicator of the cloud status.
4. Make a thing and item to send a POST command to myopenHAB
- In MainUI, manually add a thing using the Exec Binding. You can edit the ID and label to be whatever you want them to be (mine is called
Post_Test_Command
).[Blocked Image: https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/optimized/3X/c/7/c778612c9533e25aff9f7c3becf8835d36083bd4_2_517x175.png]image722×245 6.01 KB - Enter the following statement in the
Command
field, substituting in your myopenHAB username and password:curl -u username:password -H "Content-Type: text/plain" -X POST -d "Online" https://myopenhab.org/rest/items/myopenHAB_Connection
This curl command changes the string in the
myopenHAB_Connection
item to beOnline
. - Click the “Create thing” button to save your work.
- Create a switch item that’s connected to the
Running
channel of your exec thing (I’ve called my itemPost_Test_Command
). When this item is turnedON
, it will execute the shell command and then reset itself toOFF
.[Blocked Image: https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/e/8/e8e19b7586511eb46a0a23036b631f4df53d81a8.png]image728×136 6.09 KB
5. Make a thing and item to restart the cloud connector
- In MainUI, add another thing using the Exec Binding. You can edit the ID and label to be whatever you want them to be.
- Enter the following statement in the
Command
field:This shell command will log into the console 2 and restart the openhabcloud bundle.
NOTE:
habopen
is the default password for the console (which is different from the password you use to log into your server via SSH. Most users leave it as `habopen’, but if you’ve changed it then you’ll need to change it here as well. - Click the “Create thing” button to save your work.
- Create a switch item that’s connected to the
Running
channel of your exec thing (I’ve called my itemRestart_Cloud_Connector
).
6. Add the exec commands to the exec.whitelist
Before you can execute a shell command, it has to be added to the exec.whitelist
file, which you’ll find in the openhab-conf/misc
folder on your OH server.
- Open
exec.whitelist
in a text editor and insert the commands we used in our exec things:curl -u username:password -H "Content-Type: text/plain" -X POST -d "Online" https://myopenhab.org/rest/items/myopenHAB_Connection
openhab-cli console -p habopen bundle:restart org.openhab.io.openhabcloud
Don’t forget to update your username, password, and item name (if you changed it from
myopenHAB_Connection
). The commands in your exec things must be identical to the whitelist. - Save and close
exec.whitelist
.
7. Test your exec items
At this point, your items should work. You can add them to a page or sitemap and toggle them on to see the results in your log.
8. Make a thing to monitor the log
- In MainUI, manually add a thing using the Log Reader Binding. For the ID and label, I’ve used:
- ID:
openhabcloud
- Label:
LogReader: openHAB Cloud
- ID:
- In the
Custom Patterns
field, enter the following string:The thing will monitor the log and update whenever it sees this exact string of text.
NOTE: We installed the REGEX Transformation earlier so that it can be used by this item (using the default settings). You don’t need to do anything else with REGEX.
- Click the “Create thing” button to save your work.
The log reader thing has an an advanced channel called
New Custom Event
. It can be used to trigger a rule without needing an item (though you can also make a switch if you prefer).So, let’s make that rule.
9. Restart the binding whenever a disconnect is detected
Apologies for the fact that I’m still using Rules DSL. In a nutshell, this rule does the following:
- Triggers whenever openHAB reconnects to myopenHAB.
- Updates the
myopenHAB_Connection
string item toTesting
- Sends a command through the cloud to change
myopenHAB_Connection
string item toOnline
- Checks if
myopenHAB_Connection
changed toOnline
- Restarts the binding if the
Online
command was not received
And that’s all. The hard part is really getting the things/items set up, but only if you’ve never used the exec or log reader bindings before.
Some things to note:
- The rule will trigger every time it sees the “Connected to…” message in the log. So, it will loop continuously until it successfully reconnects. For this reason, I’ve set a five-minute waiting period in case there are multiple disconnects/reconnects in a brief span of time.
- The rule will not run unless it sees the “Connected to…” message. So, if there’s an actual myopenHAB outage, we won’t keep pinging it with this rule and potentially making things worse.
Ich habe allerdings den Neustart der Cloud-Connection nicht über ein zweites Exec-Thing realisiert sondern mit einer DSL-Rule und dem entsprechenden Status des Schalters.