I’m posting custom data to emoncms via the emonhub socket interfacer and I’d like to add another input.
As it stands I have one python script that is collecting data and posting to the first 2 inputs of a node and I am working on another script that mostly does something else, but I would like to post data from this script too. To keep things neat I’d like to keep them all in the same node, but each script won’t have access to the other inputs for the node.
Is it possible to post to a specific input in a specific node?
I’ve had a look on here, at the emonhub documentation, had a look through the source of emonhub and had a go at some trial and error and have come up with nothing so far.
How do you want the two different inputs to line up in the timestamped data?
If you’re happy for each script to provide different timestamped rows containing their own part of the data, you could do something like:
A node definition in emonhub.conf like this:
Script #1 is expected to write to 23 and 45 to val1 and val4, Script #2 is expected to write 12 and 1 to val2 and val3.
In Script #1 you would send the string (note the three spaces between 23 and 45):
"19 23 45"
In Script #2 you would send the string (note the two spaces between 19 and 12 and one space on the end):
"19 12 1 "
Looking at the code on github for the Socket Interfacer, it usesf = f.split(' ')to split the fields, so you’d have to do some testing to see what happens with null values being passed through emonhub
What you should end up with is an Input in EmonCMS with 4 values that update at different rates depending on the script update frequencies.
In your Input processing, you’d have to do something to handle the rows that contain nulls so they didn’t incorrectly pollute your feeds.
If you want the two scripts to update the same timestamped row with different values, I don’t believe that is possible.
With all of that said, why do you need them to be the same Input node?
When sending data in the way you mention (adding multiple spaces) emonhub discards the frame because of non-numerical content.
I’d prefer not to have to do too much messing around trying to make it work as really the reason I want them all in the same node is just a matter of preference instead of anything really functional.
I’m happy enough with them posting to separate nodes as that works just fine. I was more just checking I wasn’t missing something obvious which could’ve kept things a little neater.
What you are asking for should have been available by now, it was intended functionality in emonhub from the outset. Originally emoncms would not accept partial frames via the bulk upload api.
I added changes to emoncms to allow it to accept a frame of data with “missing” values eg “100,null,100,null,100” would result in input 1, 3 and 5 being updated to 100 whilst 2 and 4 would remain un-updated.
Since these changes have been made I have not returned to the original version of emonhub to get this working as development stopped when the emonpi variant launched to avoid confusion and I have not had much involvement with the emonpi version.
For now, you would probably be better off with 2 nodes.