I will briefly tell you about the idea and give you the opportunity to work with only lua script.
Almost all DVR have alarmIN or another device therefore
First (esp8266 only relay NC) is host with static IP or AP mode, relay wire to alarm In pin on DVR its function is to expect a response relay status from the client to activate High relay
Second esp8266 with PIR sensor is client , and the idea is to enable the server's relay on the detection move
we have two simple devices , and of course, the effect we can achieve is that the entire wiring has disappeared or not exactly
What do you think?