WHAT? Weatherstation > Node-red > Mosquitto > Domoticz Topic is solved

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

Post Reply
TheMartian
Posts: 5
Joined: Wednesday 16 November 2022 21:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

WHAT? Weatherstation > Node-red > Mosquitto > Domoticz

Post by TheMartian »

Hi all,

I’m struggling to get my Node-red > Mosquitto > Domoticz communication to work in my new dockerized setup. Before this I had it all working when directly installed on my Odroid M1 device with Ubuntu 22 04 Jammy LTS. But after having to reinstall that two times (after messing things up) I decided it was time for me to dockerize the whole thing. I'm close, but definitely not there.. I hope someone can help me get this to work.

So now I have 3 containers running by setup & config through docker-compose. Domoticz and Node-red are -I think- OK, available and working through their web-interfaces. I’m not sure if Mosquitto is working properly, and I can't find a good way to test if it is running properly. So it could well be that there’s my problem. The other thing that I’m thinking is a cause of failure is the way I may have not properly setup the containers and the links between them. Or maybe a combination, or something else entirely.

For further context: The whole functional idea is that Node-red scrapes a website with weather data from a local weather station, then at the end of the flow it sends the data of all the weatherstation-sensors to dummy devices in Domoticz . What I can now see: Data is (still) successfully scraped in Node-red, the 'MQTT out' node (localhost:1883) is however not connecting to Mosquitto; it status-symbol stays yellow in color (so maybe the Mosquitto container is not working or not properly linked to the node-red container?). In Domoticz under Hardware I have setup the ‘MQTT Client Gateway with LAN interface’ on localhost and port 1883.

For Mosquitto I have created a mosquitto .conf* file with the following content:

Code: Select all

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto .log*
listener 1883
allow_anonymous true
File is located in the folder: /mnt/data/docker/mosquitto/config

I also tried to get it working with the Aedes (MQTT) node, which seems nice, but I’ve never used before. I got that installed, and I think that was properly working, cause then then the MQTT out node said connected (status-symbol green). But still no data was relayed to Domoticz . So maybe not working at all, or Domoticz container not able to communicate properly with Mosquitto container?

I’m hoping someone can help me out here, or set me on the right track again.

This is my docker-compose .yml* file:

Code: Select all

---
version: "3 .7"*

services:
 
  domoticz:
    image: domoticz/domoticz:stable
    container_name: domoticz
    restart: unless-stopped
    devices:
      - "/dev/serial/by-id/usb-0658_0200-if00:/dev/ttyACM0"
    ports:
      - 8080:8080
    volumes:
      - /mnt/data/docker/domoticz/config:/opt/domoticz/userdata
    environment:
      - TZ=Europe/Amsterdam

  mosquitto:
    image: eclipse-mosquitto:2
    restart: unless-stopped
    ports:
      - 1883:1883
    volumes:
      - /mnt/data/docker/mosquitto/config:/mosquitto/config
      - /mnt/data/docker/mosquitto/data:/mosquitto/data
      - /mnt/data/docker/mosquitto/log:/mosquitto/log
    networks:
      - localnet

  node-red:
    image: nodered/node-red:latest
    restart: unless-stopped
    environment:
      - TZ=Europe/Amsterdam
    ports:
      - 1880:1880
    networks:
      - localnet
    volumes:
      - /mnt/data/docker/node-red/data:/data
    links:
      - mosquitto

networks:
  localnet:
    driver: bridge
    
* In my post I had to include a space, cause forum-post-validation sees this as and URL or something, which I'm not allowed to post.
Kedi
Posts: 569
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: WHAT? Weatherstation > Node-red > Mosquitto > Domoticz

Post by Kedi »

Setup this docker container https://hub.docker.com/r/smeagolworms4/mqtt-explorer and you can connect to your local mosquitto server and see what is going on.
B.t.w. this is my compose

Code: Select all

version: '2.0'
services:
  mqtt:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    restart: unless-stopped
    volumes:
      - "/volume1/docker/mosquitto:/mosquitto"
    ports:
      - "1883:1883"
      - "9001:9001"
    command: "mosquitto -c /mosquitto-no-auth.conf"
Logic will get you from A to B. Imagination will take you everywhere.
skippy711
Posts: 32
Joined: Friday 20 January 2017 17:52
Target OS: NAS (Synology & others)
Domoticz version: 2024.2
Location: Netherlands
Contact:

Re: WHAT? Weatherstation > Node-red > Mosquitto > Domoticz

Post by skippy711 »

From your .yml file I gather that you are dutch. Node-red has a Buienradar node available https://flows.nodered.org/node/node-red ... buienradar if that helps
TheMartian
Posts: 5
Joined: Wednesday 16 November 2022 21:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WHAT? Weatherstation > Node-red > Mosquitto > Domoticz

Post by TheMartian »

Kedi wrote: Wednesday 17 May 2023 16:15 Setup this docker container /r/smeagolworms4/mqtt-explorer and you can connect to your local mosquitto server and see what is going on.
Btw. this is my compose

Code: Select all

version: '2 0'
services:
  mqtt:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    restart: unless-stopped
    volumes:
      - "/volume1/docker/mosquitto:/mosquitto"
    ports:
      - "1883:1883"
      - "9001:9001"
    command: "mosquitto -c / .conf"
I did this and found that the mosquitto container was running fine. So basically all my containers were working as the should, but not connecting.

Thx for this Kedi!
TheMartian
Posts: 5
Joined: Wednesday 16 November 2022 21:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WHAT? Weatherstation > Node-red > Mosquitto > Domoticz

Post by TheMartian »

skippy711 wrote: Saturday 20 May 2023 22:40 From your .yml file I gather that you are dutch. Node-red has a Buienradar node available if that helps
Yes I know that, and I have that installed as well, nut the weatherstaion I scrape data from is a very local one, like 50 meters from my house.
TheMartian
Posts: 5
Joined: Wednesday 16 November 2022 21:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: WHAT? Weatherstation > Node-red > Mosquitto > Domoticz

Post by TheMartian »

After establishing -by using Kedi's container- that my mosquitto container was also in good working order, I knew it had to be some problem in connecting or linking the three containers.

I then discovered something very stupid and basic in my setup. The 'MQTT out' node in Node-red was still configured with 'localhost' and '1883' as servername and port. That configuration came from exporting the flows from Node-red out of my natively installed setup, where applications communicated with eachother through the host-network (localhost). Now in the dockerized setup the servername of the mosquitto application on the docker-network is 'mosquitto' (not localhost anymore), still on port 1883. So once I changed 'localhost' to 'mosquitto' in the 'MQTT out' node-red node, it all was fine again.

Similarly I had to change the servername in the ‘MQTT Client Gateway with LAN interface’ of the Domoticz hardware setup from 'localhost' to 'mosquitto'. There also I just exported the database from the native installation and imported it into the dockerized version of Domoticz.

Thanks for your help!
User avatar
waltervl
Posts: 5735
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: WHAT? Weatherstation > Node-red > Mosquitto > Domoticz

Post by waltervl »

skippy711 wrote: Saturday 20 May 2023 22:40 From your .yml file I gather that you are dutch. Node-red has a Buienradar node available https://flows.nodered.org/node/node-red ... buienradar if that helps
Domoticz has a Buienradar integration, no need to go over Node-Red/MQTT here: https://www.domoticz.com/wiki/Buienradar
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest