# Communication between Python and Offline Nodered

**URL:** <https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770>\
**Category:** General\
**Created:** [20 August 2020 10:05 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770 "2020-08-20T10:05:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 10:05 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/1 "2020-08-20T10:05:08Z")

</div>

Hi all,  
I have downloaded offline Desktop node-red, I have python 3.6.8.  
I know how to send Data from python to Node-red via Cloud or server(eg\>Mqtt).  
I want to send data from python that is when i run the python file it should send some string to node-red without Internet or Cloud.  
Can anyone know about it..?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 August 2020 10:08 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/2 "2020-08-20T10:08:04Z")

</div>

Hi Sandy,

You could simply host a local MQTT broker (like mosquito) on the (offline) device where node-red runs.

Quick question, what do you do in python, that you couldn't do directly in node-red?

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 10:14 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/3 "2020-08-20T10:14:05Z")

</div>

Thank you Mr.Steve for immediate response.  
Mqtt requires Internet, We should not use Internet.  
Yah, we can do it in node-red but we have should send data from python to Offline Node-red where it won't require Internet or any Cloud in between them.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 August 2020 10:16 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/4 "2020-08-20T10:16:09Z")

</div>

> [@Sandy](#):
>
> Mqtt requires Internet, We should not use Internet.

MQTT does not require internet - a broker can be installed locally to node-red and / or where python runs

It DOES require an IP - but that IP can be `localhost` or `127.0.0.1` or an internal `192.168.x.y` address (non internet LAN)

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 10:19 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/5 "2020-08-20T10:19:21Z")

</div>

Thank you,  
Can we have other communication rather than **mqtt**..?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 August 2020 10:22 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/6 "2020-08-20T10:22:34Z")

</div>

Sure, if you want to deal with pipes or raw TCP / UDP or temporary files - go ahead - but you lose the structure and simplicity of MQTT.

Why not just install a local MQTT broker? Lots of people do this.

In fact, you can run a broker inside node-red using [node-red-contrib-aedes](https://flows.nodered.org/node/node-red-contrib-aedes) - so you don't even need too install mosquito (though it would be a better solution).

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 10:27 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/7 "2020-08-20T10:27:51Z")

</div>

Can you share some more info or it might be better if you share an example flow

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 August 2020 10:30 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/8 "2020-08-20T10:30:40Z")

</div>

What do you need information on? You said you know how to use MQTT across the internet, there is no difference running it locally. On a Pi, for example, you can just run  
`sudo apt install mosquitto`  
and it is done. Nothing else to do apart from use it in node-red.

Alternatively, if you just need to run a python script that runs and sends it output to node red then you can call the script from an exec node.

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 10:36 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/9 "2020-08-20T10:36:21Z")

</div>

Thank you Colin,  
I will try and will update you about it.  
For your Info I am clarifying that I want to run python script outside the Offline Node-Red where I will send some messages to Node-Red.

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [20 August 2020 10:59 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/10 "2020-08-20T10:59:02Z")

</div>

> [@Sandy](#):
>
> I am clarifying that I want to run python script outside the Offline Node-Red where I will send some messages to Node-Red

This is simply not working. Like trying to turn on a lamp if the wire is broken

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 August 2020 11:12 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/11 "2020-08-20T11:12:17Z")

</div>

> [@Sandy](#):
>
> Offline Node-Red

I think there may be confusion about what you mean by that. Presumably you are trying to run the script in the same computer as node-red, and the node-red server is running.

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 11:18 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/12 "2020-08-20T11:18:35Z")

</div>

> [@Colin](#):
>
> node-red server is running

yes,you are correct, but I am not using Node-Red Server it is Offline Node-Red Desktop

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 August 2020 11:31 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/13 "2020-08-20T11:31:50Z")

</div>

> [@Sandy](#):
>
> Offline Node-Red Desktop

I have never heard of that, Do you mean [GitHub - sakazuki/node-red-desktop: Node-RED Desktop](https://github.com/sakazuki/node-red-desktop)?

If so then I have no experience with that, I suspect no-one here has, but I may be wrong.

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 11:39 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/14 "2020-08-20T11:39:19Z")

</div>

Yes I am Using the Same Sir

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 August 2020 12:34 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/15 "2020-08-20T12:34:15Z")

</div>

As I said I have no experience with that. I see it is using a 9 month old version of node-red, which is undesirable. Why are you not using a normal node-red install?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [20 August 2020 13:05 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/16 "2020-08-20T13:05:33Z")

</div>

You can add an MQTT broker to Node-RED Desktop by installing node-red-contrib-aedes and try using that

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [20 August 2020 14:34 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/17 "2020-08-20T14:34:57Z")

</div>

It is just Node-RED wrapped inside an Electron container. You should still be able to communicate with other services over all of the usual channels - HTTP, TCP, UDP, MQTT, Websockets & even UNIX Pipes.

What you choose depends on how dynamic you want the connection to be, how much data and how complex or big it is. How often you need to exchange data and so on.

You can run Mosquitto broker on all common platforms and it should still be able to talk to your Node-RED instance because that isn't really "offline", but rather "local".

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 16:41 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/18 "2020-08-20T16:41:21Z")

</div>

Thank you and sure i wiill try that

---

<div class="post-metadata">

**Author:** ![Sandy](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Sandy](https://discourse.nodered.org/u/Sandy)\
**Post date:** [20 August 2020 16:42 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/19 "2020-08-20T16:42:32Z")

</div>

I want Offline Node-red for Offline Dashboard

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [20 August 2020 17:21 UTC](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770/20 "2020-08-20T17:21:24Z")

</div>

As far as I can see, that software does not do anything that a normal node red install, used with a local browser, will not do.

[Next page](https://discourse.nodered.org/t/communication-between-python-and-offline-nodered/31770.md?page=2)
