Page 1 of 1

Rain bird garden system

Posted: Monday 09 May 2022 22:12
by hendrikenrenny
Hey,

Is there anyone that connected the rain bird garden system to Domoticz?

How is that done?

I ordered the Rain Bird beregeningscomputer, type ESP-RZXe4i with a wifi module.

Thanx!

Hendrik

Re: Rain bird garden system

Posted: Tuesday 10 May 2022 8:57
by waltervl
There is a Python library https://github.com/jbarrancos/pyrainbird
Perhaps that can be used to make a python plugin or a python script.

Re: Rain bird garden system

Posted: Sunday 22 May 2022 20:13
by solarboy
I have this irrigation controller, the wifi connection is terrible (short range and lots of dropouts) and the "app" is extremely slow, can't recommend it at all.

Re: Rain bird garden system

Posted: Saturday 28 May 2022 23:33
by BarryT
Just take away the controller and make 1 by yourself.
Its 12/24v with valves mostly, so easy done with some relais or ethernet board.
Made many irrigation systems this way, and it works perfectly.
Just some scripting with time based zones or even with soil moisture sensors if you want it full automatically.

Re: Rain bird garden system

Posted: Tuesday 31 May 2022 3:16
by solarboy
Agreed, I will be moving to a couple of 4 way zigbee relay pcbs, they can be powered with the same 24V AC as the irrigation valves.

Re: Rain bird garden system

Posted: Wednesday 01 June 2022 18:20
by BarryT
solarboy wrote: Tuesday 31 May 2022 3:16 Agreed, I will be moving to a couple of 4 way zigbee relay pcbs, they can be powered with the same 24V AC as the irrigation valves.
Good job ;-)
Succes!

Re: Rain bird garden system

Posted: Thursday 08 February 2024 19:10
by Tuk90
hendrikenrenny wrote: Monday 09 May 2022 22:12 Hey,

Is there anyone that connected the rain bird garden system to Domoticz?

How is that done?

I ordered the Rain Bird beregeningscomputer, type ESP-RZXe4i with a wifi module.

Thanx!

Hendrik
Yes, and I got it working, if your still interested I can show what I did

Re: Rain bird garden system

Posted: Friday 09 February 2024 0:08
by waltervl
There will be always someone interested in your setup so please share it.

Re: Rain bird garden system

Posted: Friday 09 February 2024 21:51
by BazemanKM

Re: Rain bird garden system

Posted: Monday 26 February 2024 20:02
by Tuk90
A bit late but my setup:

I have created a dummy hardware and in my case three devices for the three zones which I have in my garden. I have a script that is initiated on start, on stop and also a dzvents script. All these scripts are calling the python module of https://github.com/allenporter/pyrainbird.

You need to install this module on your device before you can use it.

My on start invoke script: script:///[path]/rainbird_start.py 2 30 192.168.1.1, where two is the zone, 30 is the time and the last one is the ip adres.

Code: Select all

#!/usr/bin/env python3
from pyrainbird import RainbirdController
import sys
import time
import logging

logging.basicConfig(filename='pypython.log',level=logging.DEBUG)

#gets the given arguments and puts them in the right variable
zone = sys.argv[1]
minutes = sys.argv[2]
ipadress = sys.argv[3]

_LOGGER = logging.getLogger(__name__)
_LOGGER .setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
_LOGGER.addHandler(ch)

#starts irrigate zone for the given zone and minutes
controller = RainbirdController(ipadress,'password')
controller.irrigate_zone(int(zone),int(minutes))

Mind the second last line, there you need to fill in the password of the controller

The off action invoke script: script:///[path]/rainbird_stop.py 192.168.1.1, it only needs the ipadres

Code: Select all

#!/usr/bin/env python3
from pyrainbird import RainbirdController
import sys
import time
import logging

logging.basicConfig(filename='pypython.log',level=logging.DEBUG)

_LOGGER = logging.getLogger(__name__)
_LOGGER .setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
_LOGGER.addHandler(ch)

ipadress = sys.argv[1]

#stops all the irrigation
controller = RainbirdController(ipadress,'password')
controller.stop_irrigation()

Mind the second last line, there you need to fill in the password of the controller

And I got a get status dzvents script, but I have not used it for quite sometime because occasionally it did crash domoticz:

Code: Select all

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
        
},
    execute = function(dz)
        local GazonAchter = dz.devices('Gazon achter')
        local GazonVoor = dz.devices('Gazon voor')
        local Druppels = dz.devices('Druppels')
        
        --function to execute a local script with logging
        local function osCommand(cmd)
            if dz == nil then dz = domoticz end -- make sure dz is declared as domoticz object if not already done earlier 
            dz.log('Executing Command: ' .. cmd,dz.LOG_DEBUG)

            local fileHandle = assert(io.popen(cmd .. ' 2>&1 || echo ::ERROR::', 'r'))
            local commandOutput = assert(fileHandle:read('*a'))
            local returnTable = {fileHandle:close()}

            if commandOutput:find '::ERROR::' then     -- something went wrong
               dz.log('Error ==>> ' .. tostring(commandOutput:match('^(.*)%s+::ERROR::') or ' ... but no error message ' ) ,dz.LOG_ERROR)
            else -- all is fine!!
                dz.log('ReturnCode: ' .. returnTable[3] .. '\ncommandOutput:\n' .. commandOutput, dz.LOG_DEBUG)
            end

            return commandOutput,returnTable[3] -- rc[3] contains returnCode
        end
        
        if GazonAchter.state == 'On' or GazonVoor.state == 'On' or Druppels.state == 'On'
        then
            osCommand("python3 /home/pi/pyrainbird/rainbird_get_state.py")
        end
    end
    
}
and the python code looks like this:

Code: Select all

#!/usr/bin/env python3
from pyrainbird import RainbirdController
import requests #used for the api calls
import sys
import time
import logging

ipdomoticz = '192.168.1.1' #ipadress of domoticz
portdomoticz = '8080' #port on wich domoticz is running

zones = {
    "1": "229", #Gazon achter
    "2": "230", #Gazon voor
    "3": "228"  #Druppels
}

#puts it in a dict so that it can be used in an for loop
zones = zones.items()

logging.basicConfig(filename='pypython.log',level=logging.DEBUG)

_LOGGER = logging.getLogger(__name__)
_LOGGER .setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
_LOGGER.addHandler(ch)

#credentials to connect to the controller
controller = RainbirdController('192.168.2.1','password')

#for loop to update the device states in domoticz
for zone, devidswitch in zones:
    zonestate = controller.get_zone_state(int(zone))
    print(str(zone)+' heeft als status '+str(zonestate))
    devreq = requests.get("http://"+ipdomoticz+":"+portdomoticz+"/json.htm?type=devices&rid="+devidswitch).json()
    devstatus = devreq["result"][0]["Status"] #gets the status value in the first array of result
    if zonestate == False and devstatus == "On":
        requests.post("http://"+ipdomoticz+":"+portdomoticz+"/json.htm?type=command&param=switchlight&idx="+devidswitch+"&switchcmd=Off") # update device
    elif zonestate == True and devstatus == "Off":
        requests.post("http://"+ipdomoticz+":"+portdomoticz+"/json.htm?type=command&param=switchlight&idx="+devidswitch+"&switchcmd=On") # update device

It is not really clean, but it does the job, I think this logic could be setup in a python plugin fairly easy, the only problem is that you do need an external library.

Re: Rain bird garden system

Posted: Monday 09 June 2025 20:41
by marcin2
For those who use Rainbird ESP-RZXe Series, see the following to control the RainBird irrigation system via MQTT and Domoticz:

https://github.com/KD377/mqtt-rainbird

Cheers,
Marcin