Willkommen im Loxone Community Forum. Um alle Funktionen nutzen und sehen zu können, registriere dich bitte zuerst. Dies gilt auch für das herunterladen von Dateien.
I have a virtual output, which is getting info from an api, i am saving the answer in a textfile: /user/common/token.txt
I need to get a part of the json (the actual token) from the txt file.
I used a virtual input, but it isnt recognizing the text, but from what i've read this is not the way to get a string value, outputs are only numeric the way i am using it.
Someone any clue how i can get a part of the json stored as a variable in string format?
Moin,
ich habe gestern (versucht) herauszufinden, wie und ob ich mit dem Miniserver gen2 einen API (mit Token) abfragen kann. Bisher habe ich gelesen, dass Loxone bei den virtuellen Eingängen keinen header für den Token mitsenden kann. Demnach ist eine Abfrage der API nicht möglich.
Aber vielleicht habt ihr ja noch einen Tipp
Ich spreche kein Deutsch. Gib Google Translate die Schuld, wenn ich unverständlich bin.
Here i am again.
I managed to extact the token using the workaround, now i'm bumping into the next issue:
I put the result of the workaround into a marker, and forward this to a virtual output
Seems it's not working, i used debug to check whats wrong (see image)
Look like the forwarded text is limited to 25 characters, it cuts of the first x characters
I also tried a status block, but where the <v1> value is inserted, theres no string, altough liveview shows the string being forwarded to the virtual output.
It would be helpful to see a screenshot of your Virtual Output. There are two options for building the lines 'Command for On', 'HTTP Header for On' or 'HTTP body for ON' -
Option 1. In the 1st example pictured below, <v> is injected where the token should go within the line. The Virtual Output command is being fed just the token text. In this example, a fully formed 1740 character string is arriving in the Miniserver from an external system (your 32 bytes shouldn't be a problem).
Option 2. An alternative is to pre-form the line in a Status Block and forward the complete line to the Virtual Output.
In the 2nd picture below, Option 2 would have a Status Text column with the text -
Code:
Content-Type: application/json \r\nx-token: <v2>
The XToken is fed to I2 of a Status Block and a Trigger on I1. The Status Block text output then goes to the Virtual Ouput and would have the 'HTTP Header for On' as simply <v>.
Sometimes one option works where the other option fails. Importantly, in both cases, 'Use as digital output' must be unchecked. Also ensure your memory flags are set to type 'Text'.
The second option also provides a 'gate', whereby the token text is prevented from flowing through to the Virtual Output command until it is triggered. The text workaround takes a finite time to build the complete 32 byte string. The Virtual Output will fire when it sees a value change. It sounds like yours might be firing prematurely...
The trigger seems to do the trick, i made a trigger wich i currently can trigger from the app.
Trigger is I2 in status block (see image), and only sends a value when I2 = 1
It works, but sends a 0 when the trigger is 0.
So 2 virtual outputs are now send, the right value when the trigger is 1, and a 0 when the trigger is 0.
it seems to translate the empty text value to a 0..
I think i'll leave this, bcuz it doesnt harm the working..
Wir verarbeiten personenbezogene Daten über Nutzer unserer Website mithilfe von Cookies und anderen Technologien, um unsere Dienste bereitzustellen, Werbung zu personalisieren und Websiteaktivitäten zu analysieren. Wir können bestimmte Informationen über unsere Nutzer mit unseren Werbe- und Analysepartnern teilen. Weitere Einzelheiten finden Sie in unserer Datenschutzrichtlinie.
Wenn Sie unten auf "Einverstanden" klicken, stimmen Sie unserer Datenschutzrichtlinie und unseren Datenverarbeitungs- und Cookie-Praktiken wie dort beschrieben zu. Sie erkennen außerdem an, dass dieses Forum möglicherweise außerhalb Ihres Landes gehostet wird und Sie der Erhebung, Speicherung und Verarbeitung Ihrer Daten in dem Land, in dem dieses Forum gehostet wird, zustimmen.
Kommentar