Projector 12V Trigger to control lights in cinema room

I made this little circuit

It takes the 12V trigger signal from a JVC DLA projector when its on, feeds it through optocoupler and then switches the external dry contact pins on Aeotec Door Sensor 7.

The 12V 100 mA trigger also drives a DC-DC CC module that charges a 40 mAh lipo battery that drives the sensor when the trigger doesnt deliver power.

The contact sensor then controls a simple groovy user app that turns off all lights in cinema room that is on. When the contact sensor reports thats the projector is turned off then the lights that was turned off are turned on again.

The app:

definition(
    name: "Projector automation",
    namespace: "HomeCinema",
    author: "Anders",
    description: "Turn off lights when projector starts and turn them back on when it turns off",
    category: "Home cinema",
    iconUrl: "",
    iconX2Url: "")

preferences {
    page(name: "mainPage")
}

def mainPage() {
    dynamicPage(name: "mainPage", title: "Settings", install: true, uninstall: true) {       
        
        section("Projector and Lights") {
            input name: "triggerType", type: "enum", title: "How do you want to detect projector on/off state?", 
                  options: ["power": "Power Meter (Watt)", "switch": "Switch (On/Off)", "contact": "Contact sensor"], 
                  submitOnChange: true, required: true
        
            if (triggerType == "power")
            	input name: "projectorPower", type: "capability.powerMeter", title: "Projector (Power)", required: true
            
            if (triggerType == "switch")
           		input name: "projectorSwitch", type: "capability.switch", title: "Projector (Toggle event)", required: true
            
            if(triggerType == "contact")
    			input name: "projectorContact", type: "capability.contactSensor", title: "Projector (Contact sensor)", required: true

            input name: "lights", type: "capability.switch", title: "Lights", multiple: true, required: true
        }
        
        if (triggerType == "power") {
            section("Power thresholds") {    
                input name: "powerOn", type: "number", title: "What power count as on (W)", defaultValue: 150, required: true
                input name: "powerOff", type: "number", title: "What power count as off (W)", defaultValue: 10, required: true
            }
        }
	}    
}

def initialize() {
    state.running = false
    state.affectedLights = []
    
    if (triggerType == "power")
    	subscribe(projectorPower, "power", powerHandler)
    
    if(triggerType == "switch")
    	subscribe(projectorSwitch, "switch", switchHandler)
    if(triggerType == "contact")
    	subscribe(projectorContact, "contact", contactHandler)
}

def installed() {
    initialize()
}

def updated() {
    unsubscribe()
    initialize()
}

def uninstalled() {}

def powerHandler(e) {
    toggleState(e.doubleValue > powerOn,  e.doubleValue < powerOff)
}

def switchHandler(e) {
    def on = (e.value == "on")
    toggleState(on, !on)    	
}

def contactHandler(e) {
    def on = e.value != "open"
    toggleState(on, !on)    	
}


def toggleState(on, off) {
    if(!state.running && on) 
        onPowerOn()
    else if(state.running && off)
        onPowerOff()
}

def onPowerOn() {
	state.running = true
    
    def onLights = lights.findAll { it.currentValue("switch") == "on" }
    onLights.each { light ->
        light.off()
    }
    state.affectedLights = onLights.collect { it.id }
}

def onPowerOff() {
	state.running = false
    
    lights
    	.findAll { state.affectedLights.contains(it.id) }
    	.each { it.on() }
}

I got asked what components I used so here goes

For charging I use a LM2596 the type with constant current limiter. You can find them on AliExpress and elsewhere

I limit the CV to 4.0V and CC to 10 to 20 mA which is safe for a 40 mAh li ion.

To switch on the dry contact on the Aeotec sensor I use a optocoupler module ready for 12V, make sure its configured for NPN

Parallell connect 12V input to DC CC module and input on optocoupler. Connect sensor VCC (3.3V) to Out and Gnd to digital in on the sensor. Leave the VCC pins unused.

The sensor needs 3 to 3.3V and the DC battery and DC module delivers up to 4.2V. so you need a regularator between the battery and the sensor.

I used a HT7333-1 LDO, which has a power draw of only around 2 uA. To stabalize voltage output i use a 10 uF ceramic condensator on both input and output from the LDO.

To connect everything I used a 30AWG silicone copper cable.

Almost forgot, between DC module and battery I use a 1N4007 diod to prevent power going back from battery into DC module when its not being provided power from 12V trigger.