That’s awesome @Farmer-Ed! A library of components like this would make it a lot easier for folks to cobble together their own custom workflows - and that one (authentication) is a great first step!
I’ve created a second node to handle basic GET, POST, PATCH and DELETE operations.
Could probably still do with some refinements but I will publish them on npm later if anyone wants to try them out. I still need to create some documentation and might even do a couple of short videos.
Hey @Farmer-Ed : do i understand right that this can handle passage of credentials in a secure way? and then i can just enter API requests (GET, POST, PATCH, DELETE) targeting a certain endpoint in a GUI window like you show above, and get server responses directly in this app?
If so, deal me in as a tester!
More or less, but the data still needs to be sent/received in Json format to/from the API, there are existing Node Red modules to help convert that to/from other formats such as CSV but there will still need to be some small amount of javascript.
You are more than welcome to test it out, I would recommend trying it first on a development server.
You’ll need to install Node.js and Node Red, instructions here for Windows, Running on Windows : Node-RED or other machines here Getting Started : Node-RED
The farmOS nodes can be added by running the following npm i @farmer-ed/node-red-4-farmos
from .Node Red
directory in a terminal.
I’ll work on improving the documentation here Node-Red-4-farmOS/README.md at main · Farmer-Eds-Shed/Node-Red-4-farmOS · GitHub when I have time. But will help here if I can too.
@walt
See if you find this useful, I can add a few more later
Links in video:
https://nodered.org/docs/getting-started/windows
Link to launch Node-Red on Local Machine:
http://127.0.0.1:1880/
Cool, @Farmer-Ed : looks like a nice easy install -on Windows at least.
/me: don’t do windows… But I will follow your lead to the instructions for other platforms, and see if i can get it running.
First tho, there’s one other consideration for my part: my farmOS server is Farmier-hosted. I’m guessing this Node Red solution doesn’t care where the API is located, so long as it is net-accessible… But perhaps you can confirm if that’s a correct assumption or not. ?
I don’t usually run it on Windows either except sometimes for development, I expect most users will use Windows for their PC,s/Laptops, for Mac OS the install is the same as Linux. There are Docker images too, which is probably the simplest if you are already using Docker.
docker run -it -p 1880:1880 --name mynodered nodered/node-red
Yes it can be installed on a server anywhere or you local machine.
OK: am on Mac, so Docker method can work for me. But my question was a bit different (albeit naîve): you say:
I get that about Node Red… But then connecting it to API of a farmOS instance out on the Internet (like mine at Farmier), there’s an assumption here to validate: this will be possible with NR installed locally? So: there is nothing that needs to be installed on farmOS server -correct?
Yes, that should be correct as long as your instance is setup to accept API calls using Oauth2 Password Credentials Grant (I believe it should be by default, but I’m not on Farmier)
@walt here is a quick demonstration of using the nodes, hope it makes some sense.
Love it! Moves kinda fast -and (without knowing what’s under the covers) that’s what i like best about it, is how quickly you can move between and even (re)configure different flows. This is where NR holds a distinct advantage over JupyterNotebooks, where it’s a bit more challenging to jump between different code blocks, while keeping track of what has been run in what order, and therefore what is the state of different variables that have been set.
Regarding underlying code, one fundamental Q: am i correct in assuming that this is built not on the farmOS.py API interface, but rather on farmOS.js ?
That, and file handling !
With Node-Red you always have an up to date flow diagram of what is happening so yes much easier to keep track of than most other programing packages.
This currently works with the API through HTTP requests.
Ultimately custom nodes built on farmOS.js would make sense as Node-Red is built on Node.js but I’m not there yet I’ve tried some experimenting with importing farmOS.js library but haven’t had much success yet, so maybe down the line a bit.
@Farmer-Ed, did you work with the Node-Red dashboard, or mainly HomeAssistant?
I’m planning on a series of buttons to create some logs. But some buttons would need input from the user.
It can be different inputs, like passing a number, choosing an asset from a dropdown, a checkbox etc…
A popup form would be awesome, but I can’t find any.
It’s best not to clutter the dashboard with this, unless the button is pressed.
Any ideas?
More Node-Red Dashboard than HA, I dabbled a bit with HA for GUI’s but found the Node-Red Dashboard more versatile. I’ll see if I can dig out a few examples, some have been abandoned at this stage though as I’ve been leaning more towards creating modules.
Edit: Here is a simple example with dropdowns, a date picker, a button and a table.
Cool. It worked.
I’ll study the flow…
You didn’t by any chance come across a way to show/hide dashboard elements from the dashboard itself?
Could be a useful way of creating custom forms.
Buttons to the left, and the form to the right.
Haven’t played with it too much, but isn’t that what the UI Control node does?
Template nodes can be used for custom HTML if you are feeling more adventurous.
You could also check out alternative dashboards for more features.
Ooh. Looks like the UI Control could do the job.
Thanks! I will share if I’m getting there…
No Problem,
Have you a GitHub account? Committing some of these to a repo is a great way of sharing and also storing your work.
I do. Not so familiar with using GitHub as i should be (yet). Even tho I’m an open source enthusiast.