-
Notifications
You must be signed in to change notification settings - Fork 534
First attempt at indexed inputs #1003
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
Open
TrystanLea
wants to merge
29
commits into
master
Choose a base branch
from
indexedinputs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use auto naming starting with 0
…to indexedinputs
Member
Author
|
Latest master has been merged into the indexedinputs branch, it still appears to be working fine https://github.com/emoncms/emoncms/compare/indexedinputs I haven’t tested emoncms_mqtt compatibility yet. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request will not be merged without an extended period of testing and pending resolving nodeid/nodename question and any other potential backwards compatibility issues
Indexed inputs
Starting with CSV
Emoncms has historically supported posting of CSV data in the following format:
Emoncms automatically names each input in ascending order as received, our example above results in:
If the name is then changed in the inputs interface, further posted inputs in csv format will recreate the original input name (e.g 1,2,3).
We can also post data using key:value json format:
which results in:
The proposal of indexed inputs is to separate the naming of inputs from the posting/updating of values when using CSV format. So that if we change the input names in the inputs interface and post to the csv API again, the values will apply to the new names according to the index order. This makes it possible to combine the benefits of named inputs that are a feature of the json key:value API with the compact size of CSV.
Using the adapted implementation in the indexedinputs branch, try changing the input key for CSV posted data from 1,2,3 to power1,power2,power3 in the inputs interface, using the pencil edit icon.
Post again with:
Notice how new inputs are not created and that the renamed inputs are updated.
Its also possible to name the inputs directly in the API (note that posting names without values is not currently implemented):
and there's the option to call csv: values which matches the emonhub naming convention:
We can also update the same inputs using the JSON format, try:
Starting with JSON
What happens if we start with JSON.
Step 1: Create a set of inputs with JSON format:
These are indexed in received order, e.g power1 is index:0, power3 is index:2. If you now post another key:value seperately this will be indexed to index:3
Step 2: Post to the same inputs with CSV:
A separate nodeid and nodename is not currently supported in this implementation which still makes it incompatible with the default emonhub http interfacer which posts the nodeid rather than nodename.
input->get_inputs function has been modified and use of this function in other parts of emoncms needs checking
This pull request will not be merged without an extended period of testing and pending resolving nodeid/nodename question and any other potential backwards compatibility issues :)