Python3 function node

I have a code where I control a damper.

The damper is running on RS485, and the slider that controls the damper is running in node-red-dashboard.

The problem is when I use the slider, nothing happens with my damper.
The slider is passing through a Python function with codes in it.

I have tried ChatGPT, but it doesn't help.

Anyone who can help?

Welcome!!!
If you would share more details and your flow, more people will be able to give you help and advice

So I understand you have a damper you are communicating with via RS485 using modbus protocol and this is working when you use a Python script

I would consider some possible alternatives:

  1. convert/rewrite the Python code into javascript in a Function node
  2. use the Python script "as is" and execute it with an Exec or Daemon node (you may have to modify the script depending on it's capabilities)
  3. add MQTT support to the Python script, run it outside of Node-RED and communicate with it via MQTT (modifying the script is of course necessary)

Myself I have many similar setups and I always use alternative 3

Node-red has modbus nodes. No reason to shell out to python which, imo, makes things more difficult and less portable. There are hundreds of examples around the forum and YouTube and the www of using node-red with modbus.

Hello,

The Python script is supposed to simulate a CO2 sensor. I intended to create a program where I have a setpoint and a "measured" value. When the damper opens, the CO2 level and the slider should gradually decrease. However, as soon as I deploy my program, it seems unable to calculate, and the damper closes to 0%.

The type of damper I have operates on a scale of 0-100% within a range of 0-10000.

I've posted the code on Pastebin for reference: import randomclass VAVSimulationApp: def __init__(self): self. - Pastebin.com

The damper operates correctly when I use a ui.slider, but I'm unsure if I've made a calculation error elsewhere in the code.

Any insights or guidance on how to identify and resolve the issue would be greatly appreciated.

Thank you in advance for your help.

i use palette node-red-contrib-python3-function

I did make the code in Python, where it worked, so I tried to write it in Node-RED. Here is the code for Python only: # -*- coding: utf-8 -*-import tkinter as tkfrom tkinter import ttk, Scale, - Pastebin.com

As I said, I do prefer an external Python script with MQTT for the unknown. I did try those Python nodes, I never felt I could make them work the way I wanted so I have permanently skipped that path

Maybe you find @Steve-Mcl suggestion being the best-fit solution, otherwise, since you seem doing well with Python, go the MQTT path and fix the script. How hard can it be...

import paho.mqtt.client as mqtt

etc

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.