Complete watering system based on openHAB

thanks for sharing. I’ve some comments.

Do not include these imports in OH 2.x

This could be just

Item RainSensor changed to OPEN

This could be just

Item RainSensor changed to CLOSED

Where is the definition of the RainSensor Item? I do not see it above in your items listing. Assuming it is a Contact, which is what it must be to use the from and to like this. Note the CLOSED and not CLOSE.

This applies across the whole rules file.

You could combine the two rules and save some lines of code if you wanted to.

Everything else was translated to English.

This could probably be significantly reduced by using a Map<String,Timer> and then looping through the members rather than reproducing the same lines of code over and over.

Move these to the top. You don’t want an error in the previous code to prevent your valves from turning off.

This can be reduced to

WtrLastDate.sendCommand(new DateTimeType)

You could use Design Pattern: Cascading Timers to make this part more generic which would make it easier for other users to adopt.

Without that, a lambda would be useful here to avoid duplicating code for each zone.

Could use a Timer for this rather than a polling cron trigger.

I would recommend using one of the Weather bindings for this rather than using HTTP directly. Or if it were acquired separately using HTTP, move this to a special weather set of rules so you don’t need to modify your irrigation rules if you choose to use a different weather service.

Thanks for sharing this example. There were only a few bugs and a few opportunities to make the code a little more generic.

1 Like