Recreate Homebridge Plugin automation.

Hi, all.

I’m after a little help with an automation please. I previously got some guidance on this via HA Reddit community but it’s not working quite as well as I think it could do.

I’m trying to effectively recreate this Homebridge automation in two rooms. One room has 2 motion sensors in, the other has 1 sensor in:

https://github.com/archanglmr/homebridge-occupancy-delay

Effectively I want the following: When sensor(s) detect motion turn on light. When motion not detected begin countdown (using internal sensor countdown on top of any additional countdown I need. When countdown expires turn off light. Simple, right? Well no, as you’ll see from the plugin page attached.

I want to set this up so that when the countdown timer starts but then it detects more movement, the timer resets and begins countdown again - thus ensuring lights won’t go out on you if encounter one of the scenarios mentioned.

I’ve kind of got a very clunky not working well version of this, but I’m hoping you wonderful people can help me recreate this plugin for HA. I need one automation for 1 room with 1 sensor and another automation for 1 room with 2 sensors working in conjunction. Again, the plugin attached provides capabilities for multiple sensors in the same room for the automation.

Can you assist me on this? I’m afraid it’s a little over my skillset at present.