make python function to Node-RED node
Project description
NodeRED.py
make python function to Node-RED node
🎛️ requirements
- node.js 18.16.1 or higher(latest stable)
- nodered.py 0.2.6 or higher, automatically download from internet if no node.js installed
- python 3.7 or higher
- tested on
OS | Tested | Pass |
---|---|---|
Mac 13(Ventura) | ✅ | ✅ |
Windows 10 | ✅ | ✅ |
Linux(WSL) | 🚫 |
🌐 install
- using pip
python -m pip install nodered.py
- using git(dev)
python -m pip install git+https://github.com/oyajiDev/NodeRED.py.git
🛠 usage
Node-RED initialize
from noderedpy import REDBuilder, RED, Auth
# using builder
red = REDBuilder()\
.set_user_dir("{user_dir}")\
.set_node_red_dir("{node_red_dir}")\
.set_admin_root("{admin_root}")\
.set_node_root("{node_root}")\
.set_port(port).build()
# using RED directly
red = RED(
"{user_dir}", "{node_red_dir}",
"{admin_root}", "{node_root}", port, "{default_flow}",
remote_access, default_category_visible
)
# change editor theme settings
red.editor_theme.palette.editable = False
red.editor_theme.projects.enabled = False
# add auths
red.node_auths.append(
Auth(username = "node-red-py", password = "p@ssword")
)
register Node
- register as decorator
- See noredpy.decorator.register function for details
from noderedpy import Node
from noderedpy.decorator import register
@register("test")
def test(node:Node, props:dict, msg:dict) -> dict:
# user codes here
return msg
- register from Node-RED object
- See noredpy.decorator.register function for details
api = API()
red.register("test", api.test)
- See noderedpy._property for details of "Property"
- See example for details.
start Node-RED
red.start({debug:bool}, {callback:MethodType})
Todos
✅ type support for "list" and "dict"
Roadmap To 2.0
✅ remove aiohttp server
🟩 flexible property ui
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nodered_py-0.2.9.tar.gz
(311.8 kB
view hashes)
Built Distribution
nodered_py-0.2.9-py3-none-any.whl
(310.2 kB
view hashes)
Close
Hashes for nodered_py-0.2.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d499d562b4e58107747ba931b09d656d08b9a00743095592774dc5d66e343f1a |
|
MD5 | 238ec582192ba4f8f88d6df984f61664 |
|
BLAKE2b-256 | b4a019bac196d2c2a7b20f57176f35c46cbebef59c0a6720b98daa3e408a2a05 |