Thank you all!

What I find very convenient with OpenHab and MQTT… you can already setup a full application of what you want and then fill in the hardware later, say by functionality or by room, so in fact it was Openhab that kept me on track with developing hardware, which in my case is the usual ESP or an Arduino (and ofcourse a raspi) plus some switches, optocouplers, relays and 433Mhz Switches as sensors and actuators.
Enables you to have a system with all the ‘software’ functionality and as soon as you put in a new ESp or Arduino, it works (usually)
So I could already visualise what I wanted and then just fill it in.
Perhaps … if I find some time… I will start to publish some of the the things I did, which may give other people some inspiration on how to tackle things (not saying my way is the best)


Same here… :slight_smile:

I basically settled on what I call dumb controllers… they are autonomous; e.g. if OH would vanish, they still do their job, by talking MQTT to each other; e.g. I have tanks that state their level; a hub (distribution) that listens to the tank demand, and tells the pump to go ON.
They send and listen to each others heart beat, and if not recieved STOP what they are doing.
OH’s role is to put a timer or condition around it; e.g. allow to fill only when…
OH becomes the config, UI, interface and command tool for the hardware.

So, I tend to say this is one of the best ways… if you can responsibly design hardware, and I really debated this to death, to the point that it is actually a very good approach.

Good thinking, I have mix, most work totally autonomously with OH just being the interface, some work via the broker with other controllers, again with OH being an interface, and then there are the OH rules that connect specific actions and only those will suffer if OH fails.

Obviously some functions such as ‘Switch on the light at dawn’ rely on OH and the astro binding, but even then I have an autonomous override that if no command comes, the light will go on anyway… depending on if I set it in override mode or not.

If OH fails, I still have switches for most of my lights and I can immediately put in a small RF/Arduino based device with BT phoneapp control that will take over or I use an MQTT phoneapp
got to be spouse friendly.
Nevertheless Openhab is great truly great as indeed interface/config and command tool, but if it stalls, my plants still get watered, my house heated and my chickens still fed

I really like your ideas (especially the indication if eggs are layed), so I want to share my own dumb ideas: “You’ve got mail”.
A door window sensor, connected to a reed sensor with a magnet on the flap of the postbox:

Originally I did set up an ESP8266, but because I could not use deep sleep in this project the batteries were flat after two weeks, so I switched to a zwave sensor.

1 Like

As long as it is working… but if there are people who want to do it with an ESP-01 and batteries, they may want to have a look here

With regard to the egglaying… I have rather autonomous chickens. They do not lay their eggs in the designated area ( an eggbox in their coop), but have found a spot in the garden, where they lay their eggs.

I am hesitating between between a few optical sensors that either see if the light is blocked (but then they they would register the chicken as well) OR some reflection sensors (my Brabanters lay white eggs).

Just to avoid confusion, Rules are not written in Java but a specially designed language we call around here the Rules Domain Specific Language (DSL). It is based on Xtend, it runs on the Java Runtime Environment, and it has access to Java classes and Objects, but it is very much unlike Java in all other respects.

If you are more comfortable with Python or JavaScript you might want to look into the JSR223 plugin. I find that those who come to OH Rules with a C/C++ background struggle mightily with the constraints of the Rules DSL.

import java.util.Random

val rnd = new Random(now.millis) // I know, the timestamp is a really bad seed, but it is better than nothing and does it really matter how mathematically provably random these numbers are?


    // In a rule

Also, have you see things posting?

Read the whole thread, lots of good ideas there.

I would love to see more specifics on this one. I’ve such a short growing season here that if I could base this on actual soil temp rather than just waiting until mid-May I might get an extra week of outdoors growing. If you are willing this would make an excellent new Thread in Examples and Tutorials.

Did you just bury the sensor in the ground? How deep? Did you include a moisture sensor as well? If I threw in a pH sensor I could maybe grow blueberries. :slight_smile: Did you encounter any unexpected problems?

This is another one I’m sure a lot of people would love to know more about.

1 Like

Yes… I’d love to hear more about this too! :slight_smile:

Your list, seemingly ‘flat’, contains quite some nice projects…

Rick, thanks for the extended info, I guess it is because of my unfamiliarity with Java that I didnt recognize it as non Java, I will look into Xtend a bit more, just started python, but I am much more a Pascal, Ada, Cobol, C and C++ man, but one is never too old to learn. I can hardly start asking for help on every rule, I want so I have to learn myself.

Thanks for the random function, I had tried inserting a random function like Thread::sleep(random.nextInt(1000)) but got nowhere. I will read that posting. I did my Presence simulation with an atmega controlling lights, movement, a fake tv and a dog barking and gradually that is all taken over by OH

Regarding the garden/aquaponics… in fact that is so simple that I am almost ashamed to make it an item, but yes i do have a moisture sensor as well as a ds18b20 in the soil, I think it is about 10cm. I have experimented with resistive sensors as well as capacitive and though capacitive has a lot of advantages, i decided to stick with resistive. To avoid electrolysis I switch power to the sensor for just a few milisecs overy few hours. OH is acting as interface with which i can select 1-6 hrs interval, but the actual control is done with an ESP8266, I am experimenting to have OH send the weatherforcast so my peripheral ESP8266 can take into account if rain is expected and then decide to postpone irrigation. I can also set it such that irrigation is regularly… say every 6 hours a few minutes… or strictly driven by the soilmoisture level.
With regard to the temperatur the soil… I know get a mail message from OH when the soil temperature is the right one. In due course i will add more crops and find another way of signalling: perhaps use the ‘visibility’ element to have icons of veggies pop up.
Aquaponics very simple: I have given up on Bell siphons, but use a selfdraining pump in my pond that pumps water every hour and then lets it drain out. I do not ue pH meter, I may in future.I more go by soil type and add lime from time to time.

In due course I plan postings on all systems I control with OH. Maybe not the lights, that is too simple but other systems may help people to tackle issues they are working on.

Thanks for your info


Thanks Max, actually that one is extremely simple, so simple even (from an IT point of view) that I am almost ashamed to explain, but it is basically a selfdraining pump that is switched on at regular intervals. OH is serving as an interface for the various settings (constant flow, or once every 1, 2, 4, 6 hrs)

Rik, @Max_G

This is what it looks like: ( “Achtertuin”=“Backyard” / “Grond”=“Ground/Soil”)

I have an ESP measure the soil temperature and when >= 7 degrees, it sends an MQTT to my carrot item.
I defined it as a contact in order to be able to use dynamic icons.
I could ofcourse have a rule set String item to ‘plant’ or ’ wait’ but no icon change then I think.
I want to add more vegetables. The problem with that is that it is not always clear what soiltemperature several veggies need, some need a specific length of day.
Anyway, i will add more veggies, based on whatever they need, be it soiltemp, or length of day or date.
I am not totally familiar with the possibilities of persistance yet, but I am wondering if i can use it to have OH trigger me to harvest as well. It might be pushing the boundaries of what OH was meant for, but personally I do not see ’ boundaries’ for its use.
I may add a ‘visibility’ element: to have the proper icon/item pop up when the right conditions are met.

Will add a picture of my soil probe later. Though I could just have put a ds18b20 in the soil, i was in the mood for something ‘nicer’ so i made something like this: probe


This is a tough problem I know. I currently have a book written by a relatively local farmer I use that has a month by month list of stuff you should be doing that month and I’ve been looking to automate that a bit. But even though he gardens a mere 20 miles (32 km) from my house, he is 1000 ft (305 m) lower in elevation which gives him an extra week or two on both ends of the season. I don’t have a cold frame yet so I have it a bit harder.

I also need to take into account more than just soil temp but whether a blizzard or hard freeze is in the forecast. So my rule would need to be something like:

if (it is between May 1 and May 15) and (soil temp > 7 degrees C) and (minimum temp forecast for the next two weeks > 0)
    It is OK to plant carrots

Throw in spinach, zuccini, and such and the rules get rather complicated fast. But that is the sort of problem I like to solve. The sensors are not too expensive as long as I don’t mind dealing with the shipping times. I might have to use something other than ESPs though as I don’t think my wifi reaches the garden beds. Luckily I already have an RFM69HW wireless network already set up with arduino sensors reporting and I think that signal will reach. If not I can switch from 915 MHz to 433 MHZ and get a little more range, though I will have to redo all my antennae.

This reminds me, it’s time to plant the garlic. :slight_smile:

So persistence is primarily used to log the states of your Items. This data can then be used to:

  • restore the states of your Items to what they were before OH restarted or your .items files were restarted
  • make decisions in Rules based on historic data
  • create charts and graphs of data for display or analysis

Knowing when to harvest seems more like a calendar/time problem than a persistence problem, though the forecast can play a role as well.

Thanks for the link. I might build one myself. I think I’ve all the parts.

Fully agree on the “more than one factor” Zucchini for instance: preferably after May 6 but soil temperature >20 degrees. May 6 has to do with the chance of Frost, which is very much depending on localisation. Tomatoes again need a specific temperature, but also length of day, so any type of multifactorial weighing in Openhab probably needs a lot of local tuning.
nevertheless, I will give it a try.

RFM69… I have an 868Mhz module and a gateway, interesting stuff, but for now my WiFi does reach into the garden.

Garlic… now that is illustrative. For where I live September is recommended

yes, I understood that part of persistence, but I was more referring to the practical way in which to store say plant dates and then calculate possible harvest days from that in openHab. have to get a bit more practice in that. I do not think the RRD4J is practical for that as it doesn’t keep data that long. Maybe I will use MariaDB… or, I will export it to Thingspeak, do the calculation and import it back (limited number of channels though)

Regarding the probe, in fact you can keep the DS18B20 separate… it is just a bit neater to put it all in one probe.
No doubt you realize that a DC current will eventually eat your probe away, but I feed mine for a few milisecs, just enough to take a reading and then I switch off the power to the rods, lasts for years.
If you really want to be a perfectionist then you can feed the rods from an H-bridge, Switch it ON, take a reading and reverse the polarity and take another reading, just to balance the potential going both ways and then Switch it OFF again. in practice though, a few mSec on say a 6 hr interval is not going to kill them.

Darn. I just see that I mentioned a lot of the above already… must be age, repeating myself

1 Like

I’d love to be able to start that early. Our last blizzard (not just snow, it is usually a doozy of a storm) and hard freeze is usually around May 15th. I’ve lost several seedlings trying to move them out too early. I gave up on tomatoes, at least from seed. The season is too short and I don’t have a good enough setup to start them indoors early enough.

It’s mid-August to early September for us.

I think that could be managed. I would go about it as follows:

  • set up DateTime Items for each planting type
  • make sure they are configured with persistence and restoreOnStartup, MapDB would be more than adequate for this
  • create a Switch to press when you do plant
  • create a Rule that fires when the Switch receives an ON command that postUpdate(new DateTime(now.plusDays(180).millis)) to the DateTime Item corresponding with that Switch. Obviously use the appropriate number of days
  • create a Rule that triggers once a day that checks whether one of the DateTimes is today and if so send an alert

One can use Groups to make these rules a little more generic, but given the multiple additional criteria it might be easier to treat each crop separately.

It keeps the data for ever. But what it does is decimate the date as it gets older, replacing several data points with one point calculated as the average. Since rrd4j requires saving the data every minute but your DateTime will not be changing, the averages calculated will be the same value as the original DateTime so you won’t be losing any data or precision.

But in this case, all you care about is the most recent DateTime so MapDB is a better choice.

Lots of people, including myself, are really happy with InfluxDB. And I recommend using more than one DB anyway.


This is a fabulous forum, now we even get some insights about farming :+1:
:carrot: :cucumber:


Not the only one. I have lost my entire seedstock this year that I had started early, by planting them may 7… only to be hit by frost 2 nights later. Weeks of work gone and a 6 weeks back lag in my crop

Some pretty good suggestions… a Switch to press when seeding, yes, good suggestion
I currently have a couple of crops in openhab, the ones I plant most, gradually trying to implement the various conditions. Currently already happy with just indicating plant time, but I may try to pull te weatherforecast in it as well. have to find a way to cycle through say 14 days of forcast and see if frost expected. I still have a lot of time till next spring, but the button with postupdate definitely seems an easy addition.

Now all I need is to write a binding to FarmBot and let that take care of everything.

Farming and gardening is the super secret killer app for home automation. :slight_smile:

1 Like

It will depend on what weather service you use and what they provide in their API calls or what binding you use supports. I use the HTTP binding with WeatherUnderground to pull the forecast as JSON. I’ve not tried to use this data yet as anything more than one day in the future is only about 60% accurate. But the way I would handle this would be to follow what I currently do:

  • HTTP binding configure with caching of the forecast
  • Items with JSONPATH transforms to extract the relevant information
  • Add the predicted lows to a Group: Group:Number:Min gForecastLows
  • The state of gForecastLows will be the lowest of all the forecast low temps which I can use in my Rules.

You get up to 200 api calls for free per day from WeatherUnderground.

Detailed documentation for it is here.

For what it does that is surprisingly affordable. Beyond my price range but not as much as I expected.

It doesn’t have an API per se, but all the software is open source and it uses MQTT to communicate with its cloud servers so I suspect it would be relatively easy to integrate with OH.

Thanks Rich, Yes, I use WU as well. Initially on stand alone projects from even before I started openHab. I think they go 14 days in the future but yes, reliability is a factor, but, at least the info is there and up to the user to weigh the importance of its.
I have not checked their full JSON lately but if the 14 day forecast is in there indeed should not be too difficult.

I was a bit semi joking on the farmbot, but it is an amazing piece of machinery, kinda like a CNC router but then for plants :slight_smile:
If I had more time I’d built something like that. Didnt realise they used MQTT, that sure opens a lot of perspective.
Most of my ‘farming’ is done on raised beds anyway and farmbot is definitely suited for that. Just got to make sure it doesnt accidentally pierce my chickens

Judging by the number of ‘automatic plant waterer’ projects on the net, automation was solely invented for gardening

1 Like

Alas, their API only supports 10 day:

But they do provide a day and night forecast for each forecasted day.