Soil moisture & automated irrigation

Did you try this stuff from Smartthings?
I personaly am too new to HE so I have no idea how the porting of apps and drivers work but... you know.

Hi guys,

Smartthings is a lot easier as it has built in get weather commands which Hubitat does not. I have written my system using a local temperature device and openweathermap for the forcasting. You will need to get an API key from openweathermap, their basic package is free.

Feel free to use whatever you want from my code.

Mark

1 Like

Thanks, but I want to automate the watering of a covered salad beet. If the soil is to dry give water for x seconds.
But I asume your App is great for lawn.

1 Like

Ambient Weather has released a soil moisture probe that works with their API. It works with their ObserverIP unit or with a small display console that uploads the data to Ambient Weather. The existing Ambient Weather app could be updated to provide that sensor data.

Does this code work for controlling a valve? I have an orbit timer, but it is listed as a valve, and not a switch.

Check out this thread..might be some stuff in there.

Hi,

You will need to change the code slightly. Replace mentions of switch with valve ie input "sprinkler", "capability.switch" should now read input "sprinkler", "capability.valve". The handlers switchOn line 303 and SwitchOff line 311: you should change and sprinkler.on() and sprinkler.off() to sprinkler.open() andsprinkler .close().

Regards,

Mark

Can I change the measurements from Celcious to Farenheight, and mm to inches?

Hi,

The temperature measurement is just a number from your local temepraturemeasurement device, just change the "C" for an "F" in the app.

For the forcast, the temperatures are read in K and converted to C by the lines
def maxToday = weatherNow.main.temp_max - 273.15
def minToday = weatherNow.main.temp_min -273.15

you will need to change that to def maxToday = (weatherNow.main.temp_max - 273.15) Γ— (9/5) + 32

to convert rain from mm to inches the lines before need changing
def Rain24H = "$forcastRain" / 25.4

def Rain1H = weatherForcast.list[0].rain / 25.4
logDebug "rain 1h ${Rain1H}"
if (weatherForcast.list[0].rain != null){
logDebug "rain 1h ${Rain1H.get("3h")}"
Rain1H = Rain1H.get("3h") / 25.4
}
else{
rain1H = 0
}

For anyone else converting this to US format, here are a couple of notes:

I converted the preferences and openweathermap call to use zip instead of city and country

(maybe the app could pull lat-lon from the platform and use this by default?)

The temp conversion tips from @mhutchy above, obviously use * instead of x.

change all the C to F, change all the mm to in

set the input type for maxRain24 and rainForcastAllowed to be decimal instead of number to allow entering rainfall amounts like 0.5 inch

Edit: there are a few more changes needed, ill keep tidying it up and will post the US version here

Hi

Thanks for the help. I have found a few bugs as well, ill post an updated app (still European version, sorry)

Might be a little off topic due to the Bluetooth range limitations, but the really inexpensive Xiaomi Mi Flora sensor looks interesting. There are Homebridge, Home Assistant and MQTT implementations using the BLE from a Raspberry Pi

this is my current working version: I had a problem last night, the internet must have been a bit flakey and the httpget timed out, as a result the weather forcast information was NULL and the app failed to work. I am working on a retry if httpget fails and after a few attempts just assume all is ok for watering.

Did you ever get the spruce sensors up and running? I’m planning on using hubduino with moisture sensors attached if I can get it stable and waterproof to go outside. It’s too late in the season this year so at least I have time. Lol

Not who you asked, but I happened to get my new v3 Spruce sensor up and running. Just put it out in the garden about a day ago, and it's giving me some readings (graph came from Home Assistant--wish there was an easier way to do this):

image

The Spruce manual says "generally, soil moisture will range from 10% to 45%, but can be higher during and after watering." The spike in this graph is when I watered, where it reached barely 40% before dropping more or less exponentially and tapering off down to 12% (I think I started around 3% or 4% before watering).

I don't know how to interpret the readings yet. The manual says it depends on your soil type and how well the sensor probe makes contact with the soil. I started with about 5 days with no watering or rain, so we'll see how long it takes to get back to that level if the weather doesn't have other ideas first, I guess, and see if I can really use this as a good gauge of when I might need to water the garden based on my own habits and recent rainfall.

It's still in my list of things to do...

Did you connect it to HA or is just the graph from HA and you connected it to HE?

It's connected to Hubitat and integrated to Home Assistant via MQTT (I'm glad Hubitat was released and freed me from the nightmare that the ZHA component was on Home Assistant, at least a year and a half ago when I last used it).

And you used a custom driver or something generic?
If I would use the sprouce only with HE, what do I have to expect? just a value? maybe a screenshot of the device page please.

I'm using a driver someone ported from ST in another thread. Thar being said, the Generic Zigbee Motion/Humidity driver works nearly as well, just without rounding the humidity (soil moisture) value to the nearest integer. It just reports that and temperature besides battery, nothing too exciting. Making sense of the moisture values is what I'm trying to figure out now--the Spruce docs say 10-45 is typical, but mine spikes at the upper end of that shortly after watering and quickly bounces down below that. Could be my soil, mostly clay.