ThomDietrich / miflora-mqtt-daemon

Linux service to collect and transfer Xiaomi Mi Flora plant sensor data via MQTT to your smart home system, with cluster support 🌱🌼πŸ₯€πŸ‘🌳
MIT License
609 stars 140 forks source link

Add Custom Property fo MQTT Message #54

Open githubhohdorfnet opened 5 years ago

githubhohdorfnet commented 5 years ago

Hello,

is it possible to add a custom property like "Watering Duration" to the mqtt message? I would like to set a specific watering duration per sensor in the config file and add this watering duration to the mqtt messages.

Thanks

Frank

ThomDietrich commented 5 years ago

Hey @githubhohdorfnet, I understand your request but do not get the meaning of it. I would manage something like this in the higher management software you use - if you do (like openHAB). Could you please describe your use case?

githubhohdorfnet commented 5 years ago

Hi Thomas,

I have built several watering systems based on ESP8266 for all of my plants. They listen to the mosquito server for messages created by your miflora-mqtt-daemon. If they find a message for the specific plant they take the humidity out of this message, compare it to a fixed value (hard coded in the software of the ESP8266) and if the humidity in the message is lower than the hard coded value they start watering. This works very good so far. Problem is, in winter i.e. I would like to reduce the humidity for the plants. Actually I have to reprogram every single ESP8266 with the new value. Therefore it would be great if I could configure such a value in the config of your miflora-mqtt-daemon, so the humidity could be changed very simple. Thanks

ThomDietrich commented 5 years ago

Actually I have to reprogram every single ESP8266 with the new value. Therefore it would be great if I could ...

Here lies the actual issue for me. I have the believe that your whole setup would become way more flexible, powerful and user-friendly if you added a middleware component to the mix. Some software that subscribes to all MQTT topics related to your plants, then evaluates them, then sends commands to your watering component. That would

  1. loosen additional requirements on the (preferably!?) dumb sensor
  2. enable strong intelligent and quickly changed rules (water less or more based on sensor data, forecast, your vacation plans,....)
  3. relieve you from programming your watering ESPs over and over again.

Of course I recommend openHAB for that but you could also use any other for such a simple task.


That said, if you still want to continue down your path, the easiest option for you might actually be to publish retained messages manually. Just take any MQTT desktop client software and publish a retained message like "15" minutes to a topic like miflora/petunia/waterduration. Your broker will retain this message indefinitely and your ESP could use a default value in the case when it is indeed not available. Wdyt?