-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MQTT notifications #113
Conversation
Nice work!, i just read the whole code and seem to be good, enough to supply the basic information. Just one question, on my case my MQTT broker, every clients connects via an username and a password. To connect it requeries at least 4 fields, IP, port, user, password. |
Thanks for the great work. Any reason why this is limited to OSPI? MQTT works fine with other platforms. |
OS3.0, OS3.2 are also supported. I updated the description |
If you have OS3 install instructions, I'll add them in the description (cc @PeteBa) |
Please add Water Level % and also Operation status (enabled/disabled as on/off) to MQTT notification. |
Hello, this looks interesting. Does this work follow the home assistant topic spec and json payload? |
My broker mqtt need User and password... |
OSPI compilation works flawlessly, but I'm having a little bit of trouble with the demo version: Building OpenSprinkler... I suspect this is happening because the mosquitto lib defaults to 64 bit for ubuntu. Are you aware of any workarounds for this? Eclipse doesn't seem to have a multilib version available for download for any OS other than windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Thanks for the contribution!
@rayshobby |
Please, the firmware has not been officially released. You need the App change to go together with the firmware change. Could you just be a bit patient and wait for the official announcement? |
@rayshobby I used the gui app version for configuration, nut not work... |
Thanks @rayshobby for the merge in master ;) |
What is the goal behind the error regarding OpenSprinkler-Firmware/mqtt.cpp Lines 31 to 33 in d4fc63c
Is the user supposed to make changes in headers from downloaded dependencies? Is there any reason not to set it like this: #define MQTT_KEEPALIVE 60
#include <PubSubClient.h> Also, I couldn't find the new dependency on |
Please have a look at this proposal #134 and give comments there |
Send MQTT messages. This implements this feature #103
Events can be subscribed (like IFTTT).
Note that this PR does not allow for controlling an OpenSprinkler unit but rather generating notifications when its activity changes.
Supported platforms: OSPI, OS3.0, OS3.2
On OSPI, it requires libmosquitto.
I also rewrite some IFTTT string message generation to use the standard sprintf instead of non-standard itoa.
This replaces my initial PR: #102
This replaces enhancement PR done by PeteBa: #108 Thanks to PetaBa for the review and improvements as well as the implementation for OS3
OSPI instructions
If anyone wants to try out the PR. I suggest using a new SD card with the latest Raspbian Buster so that you can go back to your original setup when finished trying.
Firstly, ensure you have the right dependencies:
Next, clone the OpenSprinkler repository and download the PR branch:
The PR is meant to be used with an equivalent PR on the App so that you can configure your MQTT server IP and Port address via the UI but if you just want to try this out then you can change line 567 in main.cpp from os.mqtt.begin(); to os.mqtt.begin("server_ip", server_port, 1); where you replace server_ip with the ip address of your MQTT Broker and server_port with the port number (usually 1883). Note that the "1" is needed to set mqtt active.
Then build and run:
You should see MQTT messages arrive in your broker when you turn stations on/off. let me know if you have any issues.
OS3.x limitations
The connection to the MQTT broker in this implementation is not asynchronous. This is because WiFi and Wired connection is supported and current arduino core doesn't support yet native wired connection (note there is a wip on core for esp8266: esp8266/Arduino#6680) This requires to have a reliable connection to your MQTT broker otherwise your OS system could hang trying to reconnect until timeout.