Dear..
Looks perfect thing for Domoticz.
I should use Zwave and 433Mhz and the ESP
Buy 1 or 2 Motion sensors. 433Mhz
Buy 1 ZWAVE switches.. or Buy a light that you can switch..
Buy a ESP2866 with a servo motor. [ or 2 servo motors ]
Buy some distance sensors
When sun is down, and no motion in the chicken garden for x minutes, close the door with the ESP driven motor.
When door is closed and there is motion [ between x and y time ] in the chicken garden, light on, fox is angry for light...
When the sun is up and there is motion in the chicken house, open the door..
Or build some distance esp sensors to the chicken place where they have to sleep..
When x and y and z is on the place, sensor off.
When 3x sensor is off, close door..
Think this a simple solution ...[ there a a lot.. ]
I think motion 2 lights on @ the outside.. Fox is gone...
And i do not now how your options are?
Can you build?
Do you have Zwave?
Is 433 in the garden?
Is the range of your Wifi in the chickengarden, for The ESP
Etc etc..
http://www.esp8266.nu/index.php/Main_Page
http://www.esp8266.nu/index.php/GPIO#Se ... or_control