Simon - I would like to use a GPIO on a Raspber...
I would like to use a GPIO on a Raspberry Pi to record cumulative engine hours for a club vessel. I have some Python code that runs every 6 mins and, if the line is high, increments a value in a file. I would like to send this to the SignalK server on the same Pi. Is it as simple as adding a line similar to:
15 Replies
Are the
vessels/self/engine/cumulativeHours
free text, or is there a canonical list?You cannot PUT to a path like this
That's where I got the idea from "To change a value, a PUT request should be sent via HTTP or using a Signal K put delta." - How does one send the request to change a value then?
“Note that this is very different than updating the current state of something. Use a delta update message to report the current / updated value of something, for example to report on the current wind speed from a sensor. See Delta Format”
Not sure where you got that quote from?
So you need at WebSocket connection. You also have to worry about authentication.
What you are trying to do would probably be easier to do in node-red.
Or you can make a python plugin.
The website seems to have sent me to 1.5.0 which has that text under "Making a Request to Change a Value"
Is there any documentation on Python plugins?
Example here https://github.com/SignalK/sk-plugin-python-demo
GitHub
GitHub - SignalK/sk-plugin-python-demo: Demonstration of a SK serve...
Demonstration of a SK server plugin in Python. Contribute to SignalK/sk-plugin-python-demo development by creating an account on GitHub.
More complex, should be super simple in node-red, and a very useful thing to learn.
And note my link to the Keys Reference, propulsion/engine related paths and their units are listed there.
I can't see in Node Red SignalK how to read from a file, but will have a look.
You should be able to access gpio directly from node-red
So, get rid of the python script and do everything in node-red
I think the issue I've been banging up against is recording and recalling the previous state. So if for example, the engine has done 239.2 hours at shut down, I need to reimport that at switch on, but haven't worked out how yet.
You can put it in persistent node-red storage.
In the config for the plugin, In the “Settings Value” :
Here’s a flow that stores and reads a global variable from there.
https://github.com/SignalK/node-red-embedded/blob/master/examples/put-handler.json
GitHub
node-red-embedded/examples/put-handler.json at master · SignalK/no...
Node red nodes for use with the signalk-node-red plugin - SignalK/node-red-embedded
(And sorry I’m so late! I totally missed your question about this)