Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json object return type #25

Closed
Plurax opened this issue Dec 22, 2020 · 4 comments
Closed

Json object return type #25

Plurax opened this issue Dec 22, 2020 · 4 comments
Labels
support Support request

Comments

@Plurax
Copy link

Plurax commented Dec 22, 2020

Hi,

may be I missed it - I would like to use some variable as complex JSON object. That means in contrast to the measurements and status values, I'd like to save a config for my webui within a variable.
This together with MQTT websockets (currently I use twistd+autobahn on localhost for testing) would move on my own LCARS like GUI (attachment). I would use it for the configuration of the GUI on load.

BR
Plurax
LCARSui

@mdzio
Copy link
Owner

mdzio commented Dec 29, 2020

The MQTT server can already store arbitrary JSON objects in arbitrary topics. For this, the retain flag of the message must be set. The payload must be structured as follows: {"v":{ any valid JSON object }}
However, the messages with retain flag are currently not yet persisted between restarts.

Another idea is to use a CCU system variable of type string to store and retrieve a stringified JSON object.

@Plurax
Copy link
Author

Plurax commented Dec 30, 2020

MQTT retain would require to set it up once on startup. Thus I would have the necessity of a startup routine which holds the configuration. I want to keep the ui config (and ideally the broker IP, too) out of the react app.

I would appreciate the "string" variable path. For this I dont need the mqtt access, as the config might be big (currently I fetch it on load initially and create a device tree context with paths similar to the mqtt topics. So the value updates are done on mqtt websocket receive.
With this I would be able to configure the ui in the CCU3 without other dependencies and keep config code out of the project.

@mdzio
Copy link
Owner

mdzio commented Jan 3, 2021

This is already all possible as follows:

When loading the application, the configuration can be read out from a specific system variable via HTTP-GET, e.g. on the address /sysvar/1234/~pv. For this purpose, the ID of the system variable must be known. The ID can be determined via an HTTP GET on address /sysvar (system variable name must match property title).

If the web application is provided by the CCU-Jack itself, the host name does not have to be configured. The web application can be copied into the subdirectory webui.

@mdzio mdzio closed this as completed Jan 3, 2021
@mdzio mdzio added the support Support request label Jan 3, 2021
@Plurax
Copy link
Author

Plurax commented Jan 30, 2021

Thanks for clarification (and the web app path tip). For the record: Placing JSON in a string variable can cause code (JS) injection if someone is able to set the variable. Sparetime is rare but it works currently this way...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Support request
Projects
None yet
Development

No branches or pull requests

2 participants