Thank you all!

In spite of having had my share of difficulties and hickups with openHAB, most of it actually went pretty well and I now have a system that actually does pretty much what I want. Apart from some things like weather and astro etc that have their own bindings, I mostly use MQTT, as I build most of the peripheral hardware myself (ESP8266, Arduino, with DIY interfaces). To integrate a pre openhab, pre-ESP automation system I also included 433 MHz for communication.

I could not have gotten so far without the help of this community and ofcourse without the work of the very makers of OpenHab.

It might be natural that we mostly publish posts about the problems we encounter so let me definitely celebrate the success as well and really, there is more success than problems.

Initially ofcourse I just started to use openhab to report statusses to me and to be able to switch things on and off.
My pre-openhab system did a lot of control as well, (e.g. imitate my presence when I was not home) and that is a function I now more and more start to build into openhab and therefore I will ned to dive into the ‘rules’ more and more.
Though I am quite OK with C++ and a hoist of other languages, Java is not one of them, so I foresee a steep curve with the rules again, but learning is never bad.

Anyway, I now have a system that controls/regulates:
The lights in my house (the “Hello World” of home automation)
My heating
Knows my day to day habits and anticipates to that
Simulates my presence when I am away (to deter burglars, still have to find a good random function for my rules)
Gards my house, up to including letting a dog bark at specific times
Controls my garden irrigation
tells me when it is time to plant specific crop (carrots e.g. need the soil to be > 7 degrees C for planting, a ds18B20, an esp and a rule tell me)
Controls my aquaponics systems
Keeps tabs on my chickens (currently trying to build something that indicates an egg being layed and to automate the feeder)
Even tells me when a mouse trap cought a mouse.
sends me mai updates on important happenings (e.g. someone at the door, a window was left open )

And
 not unimportant: as i get a bit older and sometimes forgetful, it keeps an on my oven, cooking stove and fireplace to alert me if they stay on too long (i.e., I forgot to switch them off). That is still in an experimental fase though

Have been able to build similar stuff for others (like a showertime controller).

Anyway, it is yet far from complete, but if I had bought it commercially (if available at all) it would have cost me thousands and I probably would have to pay some annual subscription fee.

In spite of my share of frustrations I had fun building it and at my age (>60) it is always good to keep the brain busy.

Now all i need is face recognition of known burglars and attach that to a souped up cattle prod, that I connect to a servo, all controlled by OpenHab.

Anyway, it is probably clear that I am very happy with Openhab and thanks everybody who made it possible. I am sure I am gonna have more questions in the future

15 Likes

I use a bucket full of boiling oil for anti-burglar protection
 medieval style :slight_smile:
Temp sensor of course connected to OH2 to keep the oil temp high enough :stuck_out_tongue:

Nice setup !

2 Likes

before the cattle prod I tried with an old Gatling gun, but that somehow stopped my Aliexpress/Banggood deliveries for a while.

Advice: dont use one of those cheap plastic servos to tilt that hot bucket
 they dont last long

Thanks for the compliment. Thanks to MQTT as well

1 Like

Keep us posted and don’t forget the pictures :grinning:

1 Like

Thanks, most hardware usually is an ESp or Arduino or sensor ‘with wires’ attached, but I will see if there is anything that would be interesting to shoot. Maybe I will just have to pack it all in a big post with illustrated outline of what I have been doing

I can only second your THANKS to the community.
There are specific well-known characters who help and have helped me immensely


I have also strongly adopted MQTT as the core messaging system, with Arduinos and EthernetShields all over the shop. While I am still in the early stages, I may well end up wtih a similar functionality like yours :slight_smile:

2 Likes

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)

2 Likes

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
    rnd.nextInt
    

https://docs.oracle.com/javase/7/docs/api/java/util/Random.html

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

3 Likes

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”)
carrotcold
and
carrot

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

2 Likes

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)
then
    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.

2 Likes

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

2 Likes