Ecowitt2mqtt: Send data from an Ecowitt device to MQTT

This docker does require that we have configured the ecowitt device to report to a custom weather service. It will not work without it. I configure that through the WS view device on an ipad but I know it can be done other ways. Did you do that? (going back to basics) The weather service requires input of your host (unraid server) , a path (/data/report) and the port you use. I set an upload interval of 60 (seconds) for my service as that is plenty at once per minute! Did you see my added note that you need a container port defined? I added that when I realized I had forgot it. It is needed. Hope this helps!

Could you share screenshot of your docker configuration screen in Unraid or the docker run command? Thanks

Here you go:

One other thought: I noticed on your image post that you were using the port 8088. Have you checked to ensure nothing else is using that port to interfere with the communications? Good luck!

Thanks, I created new template and filled it exactly as your screenshot but no dice I guess it just wasnā€™t meant to be. Appreciate your help!

Your welcome! Unfortunate as it works so well for me. Since you did get the docker running but donā€™t see any data logged, perhaps additional tinkering will make it work at a later day. Glad to supply what I could. Just wish I could figure out my battery issue. BTW - if you use HACS, there is an integration in it that I used to use and it worked fine for quite a while. Perhaps that will work instead. Does not require MQTT either.

Oh yeah, I have been using that integration for over a year and itā€™s been working great. I just liked the idea of switching to MQTT so thatā€™s why I was tinkering with it.

1 Like

Not sure if my issue is related or not, but I attempted to set this up yesterday using the HA add-on and I canā€™t get it working.

I see data in the logs for the add-on, but I donā€™t see anything in MQTT.

If I manually run ecowitt2mqtt from another system and change my gw1100 to point at that system everything works as expected.

Seems like the MQTT portion in the add-on or docker container isnā€™t doing something right.

Hi all!

Iā€™ve just released the 2022.06.0 version of ecowitt2mqtt with a completely new architecture, which brings several improvements:

  • Weā€™ve tackled the Ecowitt battery problem. As many of you know, Ecowitt devices are very sporadic in how they report batteries: some report 0/1 integer values (denoting ā€œbattery OKā€ and ā€œbattery lowā€), and some report other integer values that represent raw voltage. This new release gives you more control over how batteries are represented by providing a default battery ā€œstrategyā€ and allowing the override of individual batteries. Read the docs for more info!
  • You can now configure the app via CLI options, environment variables, and a config file. Some people prefer runtime options via the CLI or environment variables; others prefer storing their configuration in YAML or JSON. ecowitt2mqtt now supports all of these! Best part: you can mix and match, which allows you to, say, set defaults in a config file and override them with CLI options.
  • We now have 100% test coverage. In my exuberance to deliver the original ecowitt2mqtt, I broke a cardinal rule: every one of Aaronā€™s open-source projects needs to have 100% test coverage. Over time (and as it became more apparent that Ecowitt devices represent data in a wide variety of formats), the lack of a test harness made it increasingly likely that new changes would break old changes. Not anymore! This harness will ensure a more consistent, less-buggy experience.
  • The Docker image is smaller. We always had a reasonably streamlined Docker image, but we now use multi-stage builds to produce a final image that contains only the code we need and nothing more.
  • The codebase is much easier to understand. This may be relative, but the old codebase had too many ideas smushed together in too many places. Now, the CLI is cleanly separated from the REST server, which is cleanly separated from config management, which is cleanly separated from data processingā€¦you get the idea. This should make future enhancements/bug fixes more straightforward.
  • Many pesky bugs have been fixed. I wonā€™t bore you with details, but this new architecture allowed me to eliminate many bugs that had been lingering.

Try it out, and let me know how you get on! FYI, if youā€™re a Docker user, hang tight while it builds.

UPDATE 1: Iā€™m having challenges getting the multi-arch Docker image to build, but Iā€™m on the case. Iā€™ll post back here when the issue is resolved.

UPDATE 2: The issue is resolved and the Docker images have been published.

UPDATE 3: Already discovered and fixed a critical bug, so be on the lookout for 2022.06.1.

1 Like

Thanks for all your work on the project. Your update convinced me to move over from the stale Ecowitt HACS integration, glad I made the move!

1 Like

hey all, just noticed there was a thread for this integration! I got thiw working on a seperate RPi to mqtt into HA. Works perfectly fine manually (i.e. command line), but iā€™m trying to make it a service on my Rpi and have some issues. hereā€™s what I did:

  1. created a file sudo nano /lib/systemd/system/ecowitt2mqtt.service

  2. placed this in the file:

[Unit]
Description=ECOWITT2MQTT daemon
After=network.target

[Service]
Type=simple
ExecStart=ecowitt2mqtt --mqtt-broker=192.168.1.139 --output-unit-system metric --hass-discovery
ExecReload=kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

save and exit file

  1. then I type

sudo chmod 644 /lib/systemd/system/ecowitt2mqtt.service

  1. then I type:
sudo systemctl daemon-reload
sudo systemctl enable ecowitt2mqtt.service
  1. Reboot the Pi

no updates to mqtt and when I check the status of the service, hereā€™s what I see:

pi@raspberrypi:~ $ sudo service ecowitt2mqtt status
ā— ecowitt2mqtt.service - ECOWITT2MQTT daemon
     Loaded: loaded (/lib/systemd/system/ecowitt2mqtt.service; enabled; vendor >
     Active: activating (auto-restart) (Result: exit-code) since Sun 2022-06-26>
    Process: 736 ExecStart=ecowitt2mqtt --mqtt-broker=192.168.1.139 --output-un>
   Main PID: 736 (code=exited, status=203/EXEC)
        CPU: 3ms
lines 1-6/6 (END)

What do the logs show?

(How to find systemd unit logs: logs - View stdout/stderr of systemd service - Unix & Linux Stack Exchange)

thanks for posting that link:

When I type:

sudo journalctl -u systemd

it says no entries, even after stopping and starting the service

Try:

$ sudo journalctl -u ecowitt2mqtt

ahhh ok, there we go:

its complaing about this:

ecowitt2mqtt.service: Failed to locate executable ecowitt2mqtt: No such file or directory

Jun 26 14:55:41 raspberrypi systemd[1406]: ecowitt2mqtt.service: Failed to locate executable ecowitt2mqtt: No such file or directory
Jun 26 14:55:41 raspberrypi systemd[1406]: ecowitt2mqtt.service: Failed at step EXEC spawning ecowitt2mqtt: No such file or directory
Jun 26 14:55:41 raspberrypi systemd[1]: ecowitt2mqtt.service: Main process exited, code=exited, status=203/EXEC
Jun 26 14:55:41 raspberrypi systemd[1]: ecowitt2mqtt.service: Failed with result 'exit-code'.
Jun 26 14:55:46 raspberrypi systemd[1]: ecowitt2mqtt.service: Scheduled restart job, restart counter is at 4.
Jun 26 14:55:46 raspberrypi systemd[1]: Stopped ECOWITT2MQTT daemon.
Jun 26 14:55:46 raspberrypi systemd[1]: Started ECOWITT2MQTT daemon.
Jun 26 14:55:46 raspberrypi systemd[1414]: ecowitt2mqtt.service: Failed to locate executable ecowitt2mqtt: No such file or directory
Jun 26 14:55:46 raspberrypi systemd[1414]: ecowitt2mqtt.service: Failed at step EXEC spawning ecowitt2mqtt: No such file or directory
Jun 26 14:55:46 raspberrypi systemd[1]: ecowitt2mqtt.service: Main process exited, code=exited, status=203/EXEC
Jun 26 14:55:46 raspberrypi systemd[1]: ecowitt2mqtt.service: Failed with result 'exit-code'.
Jun 26 14:55:51 raspberrypi systemd[1]: ecowitt2mqtt.service: Scheduled restart job, restart counter is at 5.
Jun 26 14:55:51 raspberrypi systemd[1]: Stopped ECOWITT2MQTT daemon.
Jun 26 14:55:51 raspberrypi systemd[1]: Started ECOWITT2MQTT daemon.
Jun 26 14:55:51 raspberrypi systemd[1415]: ecowitt2mqtt.service: Failed to locate executable ecowitt2mqtt: No such file or directory
Jun 26 14:55:51 raspberrypi systemd[1415]: ecowitt2mqtt.service: Failed at step EXEC spawning ecowitt2mqtt: No such file or directory
Jun 26 14:55:51 raspberrypi systemd[1]: ecowitt2mqtt.service: Main process exited, code=exited, status=203/EXEC
Jun 26 14:55:51 raspberrypi systemd[1]: ecowitt2mqtt.service: Failed with result 'exit-code'.
Jun 26 14:55:57 raspberrypi systemd[1]: ecowitt2mqtt.service: Scheduled restart job, restart counter is at 6.
Jun 26 14:55:57 raspberrypi systemd[1]: Stopped ECOWITT2MQTT daemon.
Jun 26 14:55:57 raspberrypi systemd[1]: Started ECOWITT2MQTT daemon.

In that case, where does ecowitt2mqtt exist?

$ type ecowitt2mqtt

Then, try updating the ExecStart instruction with the full path.

thanks, its in this path

/home/pi/.local/bin/ecowitt2mqtt

do I simply replace the ExecStart line to:

ExecStart=/home/pi/.local/bin/ecowitt2mqtt --mqtt-broker=192.168.1.139 --output-unit-system metric --hass-discovery

do I have to add some permissions?

Correct ā€“ that should correct any issues with not being able to find the executable.

I canā€™t say. As I understand it, systemd runs its units by root as default, so as long as root can execute that executable, you should be okay.

(Full disclosure: the systemd docs were contributed by others; Iā€™m primarily a Docker user.)

thanks again.

With the full path, there was another error messageā€¦however, the problem was solved by reinstalling the program using sudo

sudo pip install ecowitt2mqtt

thanks all for your help in getting this sorted!

Got it ā€“ that makes sense. Glad itā€™s working now!

1 Like

Currently running my GW2000 and working perfeclty well. Iā€™d like to add a second device to this (GW1000).

Do I simply fill out the same information in Weather Services/Custom Server on the GW1000? Since ecowitt2mqtt is already running, I assume the second device will show up on HA/MQTT within an update interval as a seperate device.

How will duplicate names be handled?