logo elektroda
logo elektroda
X
logo elektroda

[Solved] How do I set up a NodeRed connection with Domoticz for Sofar 15KTL-X data?

Daro1003 489 27
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21421268
    Daro1003
    Level 33  
    Hello

    I am asking for help from colleagues in setting up a NodeRed connection to Domoticz.

    Currently, thanks to my colleague @michal.zd, I have in NodeRed data from a Sofar 15KTL-X inverter which I would like to transfer to domoticz and use there.

    In this topic: https://www.elektroda.pl/rtvforum/topic4101631.html all the details on how to get the data from the Sofar inverter to NodeRed.

    Screenshot of Node-RED interface with MQTT Inverter connection to debug node. .

    Maybe there is someone willing to take the time and help with the topic of getting data from NodeRed into Domoticz.
    Domoticz on a shared raspberry with NodeRed.
    Do you have a problem with Raspberry? Ask question. Visit our forum Raspberry.
  • ADVERTISEMENT
  • Helpful post
    #2 21428336
    michal.zd
    Level 28  
    See here for similar topics.
    There is an example of a json object sent to domoticz
    https://forum.domoticz.com/viewtopic.php?t=30637&start=20

    To start with, I suggest you try to send some data typed in rigidly.
    This node with the f icon is its own function, in which you enter
    
    msg.payload = {"command":"udevice","idx":1001,"nvalue":10,"svalue":""};
    return msg;
    
    .
    Check that you have access to the data in domoticz.
    I have no idea what the command is,
    idx is probably the device index
    nvaluea svalue I suspect numeric, string value.

    Added after 52 [minutes]: .

    Does anyone know if and how to send multiple values to domoticz in one mqtt message?
    After analysing the example above, I somehow don't see this as a possibility, but maybe it is possible.
    It would be the simplest,
  • #3 21428342
    Daro1003
    Level 33  
    @michal.zd I don't really understand what I have to set in this node:

    Node flow diagram in the application. .

    I understand that in the one with F:

    Edit view of a function node in Node-RED software with a snippet of JavaScript code. .

    Somewhere else you probably need to give the IP and port of Domoticz.
  • ADVERTISEMENT
  • #4 21429227
    michal.zd
    Level 28  
    Daro1003 wrote:
    IP and port of Domoticz
    .
    In the one you have signed as domoticz in, that's where it defines itself.
    In the former, on the other hand, I don't know it. On that forum, look for it.
  • Helpful post
    #5 21429925
    michal.zd
    Level 28  
    For testing instead of this ispidel use Timestamp.
    Then by pressing in this area marked with an arrow you generate the pulse and flow action manually.
    Node-RED flow example with Timestamp, To Domoticz, and Domoticz In nodes. .

    Settings for this Timestamp:
    Node-Red properties window with node settings, repeat option set to none. .

    Settings Domoticz In you should have guessed.

    Any test flow is good to do on new blank node-red cards. With this button you add:
    Add flow button in the node-red user interface. .

    Have you already taken a node-red course? It is worth getting to know this environment better, many things will become clearer.
    Here an accessible (but a bit short and not much) description of the basic nodes : https://www.pomysłowydom.pl/przykladowe-reguly-node-red/
    A nice course is given by Artur on his channel, here's a link to the first episode : https://www.youtube.com/watch?v=9fTMpgr3EU0
    and of course https://nodered.org/docs/

    Added after 1 [hour] 1 [minute]: .

    Well, and don't forget to connect the nodes to each other, now the net domoticz in is not connected to the predecessor.
  • #6 21431387
    Daro1003
    Level 33  
    Exactly @michal.zd there is no such node as Timestamp and watching some video on NodeRed they also used nodes which I don't have on mine I don't know I need to install them or something.


    Node-RED editor view with node search. Node-RED interface showing a list of available function nodes, such as function, switch, change, and others. List of available network nodes in Node-RED displayed in the application. Screenshot of Node-RED editor showing a list of available nodes under categories output, sequence, and parser. Node-RED panel showing node categories, including Raspberry Pi and storage. Screenshot of Node-RED editor showing a list of available nodes under categories output, sequence, and parser. Node-RED panel showing node categories, including Raspberry Pi and storage.
  • #7 21431532
    michal.zd
    Level 28  
    :D
    fact, for inconspicuousness in the list it is called so: Screenshot from Node-RED tool showing the inject node in the common section. .

    Added after 57 [seconds]:

    Daro1003 wrote:
    watching some movie about NodeRed there were also used nodes which are not there in my case I do not know I need to install them or something.
    .
    Some nodes do need to be installed.

    Added after 2 [minutes]:

    regarding: Screenshot showing the iSpider node in a flow editor with the label connected below. .
    I suspect that someone simply called it that, as the name of the noda can be changed. You need to read the whole thing in this forum, as it may turn out to be the usual mqtt you used earlier in my example. After all, it looks the same. Basically the colour of the noda and its icon is unchangeable, you can tell by that.

    Added after 1 [minute]: .

    ps: here you have two return. one unnecessary
    Editing a function node with code and settings. .

    Added after 12 [minutes]:

    Back to adding nodes...
    This is done here - manage palette:
    Screenshot of the Node-RED menu with the Manage palette option highlighted in version 4.0.2. .
    It is worth installing this one:
    Node-RED installation window highlighting the node-red-dashboard add-on. .
  • ADVERTISEMENT
  • #8 21432602
    Daro1003
    Level 33  
    This is where it flies ok for me:

    Screenshot of the Node-RED interface with a Domoticz error. .

    However, to Domoticz the error:

    Node-RED connection diagram with errors related to Domoticz. .
  • ADVERTISEMENT
  • #9 21432627
    michal.zd
    Level 28  
    Maybe you haven't defined the noda?
    Look in the forum you took it from, I think it will be there.
    Anyway, it's not a problem to guess. Open the parameters of the noda.

    Added after 2 [minutes]: .

    Here you have the def domoticz shown
    https://wiki.domoticz.com/MQTT

    In the image is the topic for mqtt: domoticz/in for messages sent to domoticz.
    Set this in this node

    Added after 1 [minute]: .

    Ps. I guess that index in the idx field is important and must be compatible with domoticz.
    There is some more important information on this page
    if the publish topic of the MQTT hardware is set to Index then the publish topic will be domoticz/out/$idx were $idx is the idx number of the device.
    if the publish topic of the MQTT hardware is set to Index with retain then the publish topic will be domoticz/out/$idx were $idx is the idx number of the device and retained in MQTT broker.
    if the publish topic of the MQTT hardware is set to Name then the publish topic will be domoticz/out/$name were $name is the name of the device.
    Only for domoticz/in they didn't write this, maybe then there will be a topic without an index.

    Added after 11 [minutes]: .

    Daro1003 wrote:
    Somewhere you probably still need to give Domoticz IP and port.
    .
    You don't need that, it's domoticz that needs to have a connection to mosquitto.
    In the noda you give the address to mosquitto. He is the intermediary.
  • #10 21432937
    Daro1003
    Level 33  
    Rozu
    michal.zd wrote:
    Maybe you didn't define the noda?
    .

    I understand that this is about Domoticz IN - I have something not configured in this node.

    IDX in Domoticz is a data block with e.g. temperature.

    Added after 17 [minutes]: .

    I think I have some kind of overflow because:

    Domoticz interface with data widgets and Node-RED environment.

    You can see on the block time 2 minutes inactive I click on nodeRed and it will change for a few seconds that is as if this block got some info.

    Screenshot showing Node-RED interface and Domoticz dashboard with widgets.
  • #11 21433023
    michal.zd
    Level 28  
    Daro1003 wrote:
    block got some info.
    .
    And somewhere you can see what it got? It should be the value from the msg field nvalue.
  • #12 21433069
    Daro1003
    Level 33  
    Well, it is only after this time that I see that something has affected it.
    And now yes:

    1. I don't know what type to set the block in domoticz to receive this test:

    Screenshot showing sensor type selection options in Domoticz software. Screenshot of the Create Virtual Sensor in Domoticz with a dropdown menu of sensor types. .

    2. what exactly is to be sent to Domoticz from NodeRed - some text from this:

    Screenshot showing Node-RED function configuration for Domoticz integration. .

    P.S. What I'm trying to do is as if I've set about doing an electrical installation and I can't see what a cable is.

    Added after 11 [minutes]:

    So this value of 10 should appear in domoticz:

    Screenshot of a function node in Node-RED with command configuration for Domoticz. .
  • #13 21433282
    michal.zd
    Level 28  
    Daro1003 wrote:
    So this value of 10 should appear in domoticz:
    .
    Yes.
    Try some block in domoticz that shows something. Could be some sort of power meter.
    It will be immediately ready for data from the inverter.
  • #14 21433564
    Daro1003
    Level 33  
    It does not transmit this value only this time changes i.e. you can see how it would violate.

    I tried different temperature blocks, text, percentage, counter.

    If I give a block from the energy meter sent by Tasmota, here you can see the topic that is coming from Tasmota:

    Screenshot of Tasmota data related to energy monitoring. .

    Active power:

    Screenshot of active power sensor configuration interface with Tasmota.
  • #15 21433569
    michal.zd
    Level 28  
    Ask about this json passed to domoticz on that domoticz forum.
    Maybe someone can upload an example of such a msg
  • #17 21434690
    michal.zd
    Level 28  
    He has given you the whole flow, copy everything from the code to a file and import it into node-red into a new empty flow.
    Changes need to be made to the node in and out and it should work
    Somewhere in the menu is the import
  • #18 21438038
    Daro1003
    Level 33  
    Do I insert IDX from Domoticz in these underlined places ?

    It says: "Edit the "Function" node and replace in line 3, your Domoticz idx number for P."

    So in line 3 and this is not line 3 for me it is line 5.


    Screenshot of code with line annotations. .
  • #19 21438078
    michal.zd
    Level 28  
    Daro1003 wrote:
    Do I insert IDX from Domoticz in these underlined places ?
    .
    No
    These are the data to import into node-red, they describe the whole flow.
    Do as I wrote earlier, copy the whole thing to a file, then in node-red use the import option.
    Then there will be a new flow with nodes as in the colleague who forwarded it to you.
    Only after that complete the node definitions to mqtt, first and last.
  • #20 21439117
    Daro1003
    Level 33  
    A So I click on options and give import as in image 1.

    Dropdown menu in Node-RED with the Import option highlighted. .

    In the window as in image 2 I paste the given code and give import.

    Node import window with pasted JSON code. .

    Two nodes appear to me as in image 3 and I guess the whole flow should appear like this:

    Screenshot of a Node-RED flow configured to transfer data from MQTT to Domoticz using three nodes. .

    I click on nod F and I have as in image 3 and there I change the IDXs to my own ?

    Two connected nodes Prepare for Domoticz and MQTT Domoticz with visible script.

    And what next ? I create a nod as in image 4 which was previously for testing ??

    User interface with a node graph, including MQTT Inverter and Prepare for Domoticz.
  • #22 21439161
    michal.zd
    Level 28  
    Daro1003 wrote:
    And what next ?
    .
    What you have imported is the finished flow, you already have in it from the left str reading the information from mosquitto, set the appropriate parameters in it as from the old one. The last one on the right passes the information back to mosquitto and it passes it to domoticz. You must configure it accordingly.

    Added after 2 [minutes]: .

    xury wrote:
    Through modbus or via LSW3?

    Via LWS3 modbusTCP. But through my program, writing this information to mosquitto.
    Node-red is supposed to receive it from mosquitto and pass it to domoticz.
  • #24 21439170
    michal.zd
    Level 28  
    Daro1003 wrote:
    I get two nodes like in image 3 and I guess the whole flow should appear like this:
    .
    Hmm, unless a colleague has only specified these two.
    If so, include your node that receives data from mosquitto.
  • Helpful post
    #25 21440097
    michal.zd
    Level 28  
    xury wrote:
    Mate @starob already did long ago:
    .
    I see that it reads modbus data right away in node-red.
    I had a different design premise: the whole control written as a linux program.
    I am slowly completing the pieces of the puzzle, as in addition to the hot water heating control, there is an element responsible for reacting to voltage increases, controlling the heating and the boiler room. Also as a program in C/Cpp. Advantage, simplicity of the programme and simple addition of extensions. JavaScript is moderately suitable for binary data. Very good for processing json objects.
    Mosquitto makes it easy for me to work on successive layers of control, linking everything together.
    Node-red only for displaying data in the dashboard.

    Why this? Ease of transfer in case of rpi failure.
    Initially everything worked on a tplink router under OpenWrt, even without node-red 😉.
    Only something happened to it years later, and since rpi 1 and pi zero in the meantime had become cheap, I decided to recompile this software to just rpi, adding node-red as a control panel.
  • #26 21451545
    Daro1003
    Level 33  
    And there it went.
    A colleague from the domoticz forum helped here the whole topic: https://forum.domoticz.com/viewtopic.php?t=43153

    Maybe it will be useful for someone.

    If anything happens to that topic I will paste the flow to be imported in NodeRed:

    [
        {
            "id": "9faeea04b2b50403",
            "type": "function",
            "z": "c03666d911c02a8f",
            "name": "Prepare for Domoticz",
            "func": "// Declaration of variables\n\nlet idx1 = 123;\nlet idx2 = 456;\nlet idx3 = 789;\n\nlet msg1 = {};\nlet msg2 = {};\nlet msg3 = {};\n\nmsg1.payload = { \"command\": \"udevice\", \"idx\": idx1, \"svalue\": msg.payload.P.toString() + \";0\"};\nmsg2.payload = { \"command\": \"udevice\", \"idx\": idx2, \"svalue\": msg.payload.GP.toString() + \";0\" };\nmsg3.payload = { \"command\": \"udevice\", \"idx\": idx3, \"svalue\": msg.payload.CP.toString() + \";0\" };\n\nreturn[[msg1,msg2,msg3]];",
            "outputs": 1,
            "timeout": 0,
            "noerr": 0,
            "initialize": "",
            "finalize": "",
            "libs": [],
            "x": 460,
            "y": 180,
            "wires": [
                [
                    "85eb0898c7979634",
                    "5b94fc5b22b41f4e"
                ]
            ]
        },
        {
            "id": "5b94fc5b22b41f4e",
            "type": "mqtt out",
            "z": "c03666d911c02a8f",
            "name": "MQTT Domoticz",
            "topic": "",
            "qos": "",
            "retain": "",
            "respTopic": "",
            "contentType": "",
            "userProps": "",
            "correl": "",
            "expiry": "",
            "broker": "175c3dc01f359e9d",
            "x": 710,
            "y": 180,
            "wires": []
        },
        {
            "id": "175c3dc01f359e9d",
            "type": "mqtt-broker",
            "name": "Raspberry Pi 1B",
            "broker": "192.168.10.51",
            "port": 1883,
            "clientid": "",
            "autoConnect": true,
            "usetls": false,
            "protocolVersion": 4,
            "keepalive": 60,
            "cleansession": true,
            "autoUnsubscribe": true,
            "birthTopic": "",
            "birthQos": "0",
            "birthRetain": "false",
            "birthPayload": "",
            "birthMsg": {},
            "closeTopic": "",
            "closeQos": "0",
            "closeRetain": "false",
            "closePayload": "",
            "closeMsg": {},
            "willTopic": "",
            "willQos": "0",
            "willRetain": "false",
            "willPayload": "",
            "willMsg": {},
            "userProps": "",
            "sessionExpiry": ""
        }
    ]
    .

    1 You need to edit the IP address of the broker:
    Screenshot of Node-RED editor showing an MQTT flow. 2.

    2. you need to edit the IDXs:
    Screenshot of Node-RED editor showing a flow with a function Prepare for Domoticz. 3.

    3. attach data from Sofar and it should work:
    Screenshot of a Node-RED flow for integrating Domoticz using MQTT. 3.
  • #27 21454340
    michal.zd
    Level 28  
    This kind of information: currently the broker sends a properly formatted json for domoticz to mosquitto, so node-red is a redundant jkao intermediary.
    But it is, of course, possible for node-red to completely take control of the whole thing, without additional home assistant software.
  • #28 21454585
    Daro1003
    Level 33  
    I believe that this topic has been exhausted and is to be closed.
    This is because the connection between NodeRed and Domoticz as described above has been achieved.

    Those interested in integrating Sofar with Domoticz should definitely follow the whole topic given in the first post and especially here there is a discussion about direct communication of Sofar with Domoticz.

Topic summary

The discussion focuses on establishing a connection between NodeRed and Domoticz to transfer data from a Sofar 15KTL-X solar inverter. The data acquisition from the inverter to NodeRed is already achieved via Modbus TCP through an LSW3 device, with data published to the Mosquitto MQTT broker. The main challenge is configuring NodeRed to send properly formatted JSON messages to Domoticz using MQTT, specifically the "udevice" command with correct "idx", "nvalue", and "svalue" fields corresponding to Domoticz device indices. Users shared example JSON payloads and NodeRed function node scripts to prepare data for Domoticz, emphasizing the importance of matching Domoticz IDX values and MQTT topics (e.g., "domoticz/in"). The conversation includes troubleshooting NodeRed node configurations, installing missing nodes, and importing complete NodeRed flows from external sources. It was noted that Domoticz device types must be compatible with the data sent (e.g., temperature sensors, power meters). The final solution involved importing a ready NodeRed flow, adjusting IDX values, and ensuring MQTT topics and payload formats conform to Domoticz requirements. The integration allows Domoticz to receive and display inverter data, with NodeRed acting as an intermediary between Mosquitto and Domoticz. References to external tutorials, Domoticz MQTT documentation, and community forum threads were provided to assist setup and troubleshooting.
Summary generated by the language model.
ADVERTISEMENT