Posts by Tupper

    Wichtig ist, dass ihr den Authentifizierungs-Header richtig setzt.

    Ihr müsst Euren OpenHAB-Cloud-Benutzer und Passwort BASE64 verschlüsseln und diesen verschlüsselten Begriff anstelle des XXXX hinter "Basic:" eintragen.


    Sonst bekommt ihr immer eine BAD-Request zurück

    Das war es.
    Es wundert mich aber, dass ich trotz Anmeldung über den Browser den State nicht abfragen kann.
    Aber mit username:passwort als BASE64 Verschlüsselung über die von Ralph genannte Webseite funktioniert es.

    Danke an Alle für die Hilfe und Unterstützung.

    Perfekt wäre es jetzt natürlich, wenn die Routine nur läuft, wenn der Cloud Service auch online ist.
    https://status.openhab.org/check/359410


    Dann würde man sich noch einen unnötigen Restart des Service sparen wenn der Cloud-Dienst selber down ist.

    ok... klingt seltsam. Bei https://myopenhab.org/rest/items/OpenHABCloud_WatchDog/state kommt also nichts?... so gar nichts?

    https://myopenhab.org/rest/items/OpenHABCloud_WatchDog/state

    https://myopenhab.org/rest/items/OpenHABCloud_WatchDog

    Ergebnis mit und ohne state.

    Im Debug Modus des Browser erhalte ich auch keine Fehlermeldung oder ähnliches. Es wird einfach "nichts" geliefert. Oder besser gesagt, es kommt NULL zurück.

    Richtig, es sollte bei /state auch der Wert des Items zurückgegeben werden. Irgendwas ist in Deiner URL also falsch... wäre jetzt meine erste Vermutung.

    Was mich dann aber auch vermuten lässt, dass es bei Ralph auch nicht funktionieren kann.
    Aber wie bekomme ich nun nur den state Wert...

    Die URL passt ja soweit. wenn ich state hinten lösche bekomme ich das komplette item angezeigt.

    Hast Du mal im Browser getestet, ob die URL funktioniert? https://myopenhab.org/rest/items/OpenHABCloud_WatchDog/state


    Verwendest Du OH 3.x oder noch 2.5?

    Browser zeigt mir in dem Fall eine leere weiße OH Seite, jedenfalls keinen Fehler. In der UI im Browser ist der String gefüllt.

    Ich bin mit OH 3.4.1 unterwegs.

    Ohne das /Stade erhalte ich folgende Rückmeldung:


    Code
    {"link":"https://myopenhab.org/rest/items/OpenHABCloud_WatchDog","state":"1.1565878241437821","editable":true,"type":"String","name":"OpenHABCloud_WatchDog","label":"OpenHAB-Cloud WatchDog","category":"text","tags":["Screen"],"groupNames":["Haus"]}

    Das sagt mir eigentlich, dass der Wert "state" nicht zurückgegeben wird obwohl ich ihn direkt anfrage.
    Mit der URL oben hätte ich eigentlich den Wert 1.1565878241437821 erwartet

    So,

    bin jetzt einen Schritt weiter:


    Code
    2023-01-18 15:56:36.697 [INFO ] [enhab.core.model.script.OpenHABCloud] - rnd1.3781522681800498
    
    2023-01-18 15:56:36.699 [INFO ] [enhab.core.model.script.OpenHABCloud] - responseBad Request

    Bei der Abfrage des Cloud-Wertes bekomme ich einen Bad Request zurück.

    Bedeutet, dieser Befehl wird nicht korrekt ausgeführt:
    var response = sendHttpGetRequest('https://myopenhab.org/rest/items/OpenHABCloud_WatchDog/state', headers, 3000);

    Hat jemand ggf. eine Idee warum?

    Wow - bitte beachte, dass Du damit ggf. für 20 Sekunden dein OpenHab lahmlegst. Verwende besser die Timer: Configuration > Actions > Timers

    Das habe ich nur so hoch gesetzt um im Browser zu prüfen ob cloud und lokale synchron sind bevor der Vergleich stattfindet.
    Ursprünglich und auch in der Anwendung sind es dann 3 Sek.

    Aber das eigentliche Problem ist, dass der Vergleich nicht funktioniert.

    Ralph erstmal Danke für Deinen CloudWatcher

    Ich habe ein kleines Problem mit Deiner Regel.

    Bei mir springt die Regel immer in den Else Zweig und startet den Cloud-Service jede 15 Minuten neu. obwohl die Werte gleich sind.

    Ich habe über die UI eine Rule erstellt die folgendermaßen aussieht:


    When: Cron der alle 20 Sek nach vollen 15 Minuten ausgeführt wird.
    Then: Von Dir übernommenes Skript in einer DSL-Rule


    //Dem WatchDog-Item wird ein Zufallswert zugewiesen

    logInfo( "OpenHABCloud", "OpenHAB-Cloud WatchDog: Start")

    var rnd = (Math.random() +1).toString //Zufallswert generiert

    OpenHABCloud_WatchDog.postUpdate(rnd) //Zufallswert der Variable rnd an OpenHABCloud_WatchDog übergeben

    Thread::sleep(20000) //Damit ich als langsamer Mensch auch das Update zwischen Pi und Cloud nachvollziehen kann, habe ich die Zeitverzögerung auf 20 Sekunden hoch geschraubt. Ergebnis: Werte sind gleich zw. lokal und Cloud im browser!
    Bis hierher funktioniert es problemlos


    //Jetzt wird der eben gesetzte Wert über die Cloud abgerufen

    val headers = newHashMap("Authorization" -> "Basic xxxxxxx") //was passiert hier? token für Cloudzugriff genutzt?

    var response = sendHttpGetRequest('https://myopenhab.org/rest/items/OpenHABCloud_WatchDog/state', headers, 3000); //aus der cloud wird der Zufallswert aus OpenHABCloud_WatchDog ausgelesen und in der Variable "response" vorgehalten


    if (response == rnd) //wird immer als Falsch interpretiert und springt in den Else Zweig ggf. könntest Du einmal aushelfen und den Wert der beiden Variablen "response" und "rnd" im Log anzeigen.

    {

    logInfo( "OpenHABCloud", "OpenHAB-Cloud WatchDog: Der Wert ist korrekt - alles in Ordnung")

    }

    else

    {

    logInfo( "OpenHABCloud", "OpenHAB-Cloud WatchDog: Der Wert ist falsch - Verbindung wird zurückgesetzt")

    SchalterCloudOff.sendCommand(ON) //Meinen eigenen Schalter mit die Restart des CloudConnectors

    }

    logInfo( "OpenHABCloud", "OpenHAB-Cloud WatchDog: Ende")

    Hier das zugehörige bisschen Log:

    So, nun habe ich einen Grund, warum man obiges Vorgehen nicht nutzen sollte sondern besser auf das von Ralph gepostete setzen sollte. Habe das Script jetzt übernommen und unter kleinen Anpassungen in eine DSL Rule übernommen.

    Sobald der Service oder der Pi neu gestartet wird, wird die Exec.Whitelist nicht mehr korrekt erkannt und es erscheint hinter den Befehlen im Log immer "but it is not contained in whitelist."

    Sobald der openHab Service oder der Pi neu gestartet wird, selbst wenn alles noch in der Whitelist vorhanden ist.

    Helfen. tut nur das manuelle öffnen und speichern der Whitelist.

    Ein Image ziehe ich nur wenn ich grundlegend etwas ändere. Ansonsten mache ich nach den kleineren Änderungen ein Config Backup und ziehe es manuell in die Mac Cloud.

    Normal heißt es ja "Never change a running System" und solange es läuft und nichts ändere, brauche ich auch keine neue Sicherung.

    Aaaaahhhh... Das macht Sinn.. Stimmt. Müsste doch dann auch möglich sein, dass man das Backup direkt auf dem mac machen kann, ohne die Karte entnehmen zu müssen, oder? Kannst du auf die SSD direkt vom Mac zugreifen?

    Du benötigst gar keine Karte mehr.
    Du erstellst das Backup einer Karte und spielst es auf die SSD (Sicherung ApplePiBaker und restore mit Raspberry Pi Imager).
    Die SSD schließt Du an den Pi an und gibst ihm wieder Strom.

    Das Backup lasse ich auf meinem Mac liegen und sichere es automatisch in der Cloud und Time-Maschine.
    Auf dem Pi erstelle ich nur noch Sicherungen der openhab-Config und speichere diese weg.
    Sollte dann mal unvorhergesehenes passieren, spiele ich als erstes das Image wieder ein und danach führe ich ein Restore des Openhab config Backups durch.

    zu finden übrigens über "sudo openhabian-config" und dann der letzte Punkt Backup/Restore (50)

    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).

    [Blocked Image: https://community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/a/6/a6d4b80762e830a34f57db75d2398c5f292906cd.png]image733×180 6.78 KB

    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

    1. 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
    2. 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 be Online.

    3. Click the “Create thing” button to save your work.
    4. Create a switch item that’s connected to the Running channel of your exec thing (I’ve called my item Post_Test_Command). When this item is turned ON, it will execute the shell command and then reset itself to OFF.[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

    1. In MainUI, add another thing using the Exec Binding. You can edit the ID and label to be whatever you want them to be.
    2. Enter the following statement in the Command field:
      Code
      openhab-cli console -p habopen bundle:restart org.openhab.io.openhabcloud

      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.

    3. Click the “Create thing” button to save your work.
    4. Create a switch item that’s connected to the Running channel of your exec thing (I’ve called my item Restart_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.

    1. 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.

    2. 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

    1. 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
    2. In the Custom Patterns field, enter the following string:
      Code
      Connected to the openHAB Cloud service

      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.

    3. 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:

    1. Triggers whenever openHAB reconnects to myopenHAB.
    2. Updates the myopenHAB_Connection string item to Testing
    3. Sends a command through the cloud to change myopenHAB_Connection string item to Online
    4. Checks if myopenHAB_Connection changed to Online
    5. 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.

    Danke Dir,
    ich denke, dann werde ich mal einen Versuch machen. Openhabian hat ja direkt eine Möglichkeit von der Config aus das Gerät einzubinden und den Port zu ändern.
    Beim Start würde ich eine Verzögerung des OH einbauen damit der deconz schon hochgefahren ist.

    Hallo zusammen,

    nutzt von Euch jemand ZigBee Geräte ohne eigenen Hub mit dem Raspi?
    Ich habe vor, einzelne Schalter über zusätzliche Sensoren zu steuern die über das ZigBee Protokoll laufen und wollte dazu den Raspi um folgendes Modul erweitern: Phoscon RaspBee II

    Hat damit schon jemand Erfahrung gesammelt?

    Wenn das gut funktioniert, werde ich auch mein Tradfri-Hub abschaffen und alles in OH integrieren.
    Dann kann ich auch Livisi und ZigBee als eine Einheit steuern.

    Manchmal denkt man einfach zu kompliziert und versucht die Abhängigkeit des Status in die Abhängigkeitsregel zu setzen.

    Mein PowerOff Schalter funktioniert jetzt mit einem einzigen Befehl in der DSL-Rule:


    Danke für den Denkanstoß :)

    Nein, habe ich nicht.


    Das, was im Beispiel als Code system.rules erwähnt wird, ist der komplette Code. Ich arbeite ausschließlich Datei-basiert und daher reicht diese Datei aus.

    Könntest Du ggf. mal einen Versuch starten und eine Dummy Rule über die UI erstellen um zu schauen ob er bei Dir das Script ausführen würde?
    Reicht ja ein Logeintrag wenn ein Schalter betätigt wird...