Door contact to turn light on off via IR so need an on off

Hi guys, I have a D1 mini with an IR shield, I have a door to the room my hotub is in. currently when you open the door (then Close the door) this toggles a light to come on and when we come out the Door Opens and Closes the lights go off. works great. We have introduced some new lights that are IR controlled, the issue is turning on is 1 button Turning off is another button so open the door to go in I need it to turn on, We always close the door and when we open the door again it should turn off the light, but I cannot fugure out how to ahive this, we could be in the room 15mins or 2hours so dont really want a timer, any ideas appreciated, the IR works well.

Can you be a bit clearer on exactly what are the inputs to this logic and what the outputs should be please.

I'll do my best.
I have a Xiaomi door contact (Event State Node) that when it opens, it toggles a a couple of Zwave switches to turn on some lights, (we then close the door) then when the doorOpens again the lights toggle the other way using a (Call Service Node)
I Now have a D1 Mini with an IR shield that mimics an IR remote control for control of some string LED lights, I have recorded the IR Code sucessfuly and the on/off works perfectly, To turn on the LED lights you have to Press the ON button and to turn off the LED Lights you need to press the Off button, these buttons are set as 2 switches in HA (switch.azealea_thin_lights_off & switch.azealea_thin_lights_on) Obviously I cannot use toggle, as we always go into the room and shut the door, This is normally shut within say 20seconds, so that may be a route. We spend random amounts of time in the room, so dont want it on a timer, I just cannot get my head around how to approach this, I hope this seems clearer thanks in advance

It will be difficult to use a door sensor as you never know if somebody is joining or leaving.

I have a similar challange at my frontdoor .. I use a motion sensor to identify if the entrance area is occupied. As soon the motion is detected I switch the light on (and keep it on for 2min) ... every movement is reseting the timer for another 2min). This way the light keeps on while there is movement ... can be 2min .. but can be 20min

Thankyu, I have many such automations, this is for our hot tub room, the problem is once in we dont move too much. hence my struggle we dont take phones in, I could use voice but where is the fun in that.
there is no real sequence we do other than open close the door

Surely you would have the hot tub running (blower/heater) when you were in there ?

Measure the current from either the Blower or the heater and when that falls below a certain threshold for a period of time (and the door IR has been triggered) initiate your leaving actions.

If you do not have any way of measuring the current then wire a 5v USB charger inline with the Blower motor and have the +ve of the USB charger come out to an input on your Wemos D1 Mini.

When the door IR is triggered - look for the pin coming high on the USB charger (may need a voltage divider as i believe the Wemos is only 3.3v compliant) and then set a trigger node that is reset eveyr couple of minutes based on the state of the IO pin - if the trigger timesout - you know the Blower is no longer on

Craig

I was hoping for a far simpler solution, I can put a Pir in the room too.
Is there a way to use NR to say
If the Door opens then the Pir activates do XYZ
If the Pir Activates then the Door Opens do XYZ
In an ideal world I want the light on as soon as possible, if we go out at say 8pm it can be dark, I dont want to have to open the tub turn on the blowers before lights come on, and sometimes we sit n the room just having a drink or BBQ food when the temperature drops a bit

It is easy to generate a software toggle, if that is all you want. Save the current state in a context variable and flip it each time.

Thankyou, but I have no idea how to do that sorry, A pont in the right direction there would be appreciated

Use a change node - grab the incoming message that the Door activates and use the change message to set a context environment variable (lets say call it Door.Status) and set it to Open

Then next time you see the message you flip the Door.Status using a switch node (if flow Door.Status = open) - go to change node to set it to close and vice versa

Craig

Here is a quick sample, it will keep the light on for at least 5min (trigger node) whenever there was a sensor ON (from Door or PIR) input

The light will switch off when the TUB pump is switched off (if you have a sensor for that) :wink:

[{"id":"893bc30b22d76495","type":"switch","z":"d5acb9a9f2d21fb0","name":"Light","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":730,"y":720,"wires":[["785c487a2f4b17c2","2bbc7f67f6d061b7"],["2f454e961ba73e2a"]]},{"id":"785c487a2f4b17c2","type":"debug","z":"d5acb9a9f2d21fb0","name":"Light ON","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1060,"y":640,"wires":},{"id":"2f454e961ba73e2a","type":"debug","z":"d5acb9a9f2d21fb0","name":"Light OFF","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1260,"y":740,"wires":},{"id":"2a92bdf9bb4639a4","type":"inject","z":"d5acb9a9f2d21fb0","name":"Door Sensor","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":490,"y":720,"wires":[["893bc30b22d76495"]]},{"id":"de48b043c3c5fa6b","type":"inject","z":"d5acb9a9f2d21fb0","name":"PIR-Active","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":480,"y":760,"wires":[["893bc30b22d76495"]]},{"id":"9b8622ce2d7a874a","type":"inject","z":"d5acb9a9f2d21fb0","name":"PIR Not-Active","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"oyher","payloadType":"str","x":500,"y":800,"wires":[["893bc30b22d76495"]]},{"id":"6ff780b8c22ebedc","type":"inject","z":"d5acb9a9f2d21fb0","name":"Manual OFF","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":490,"y":680,"wires":[["893bc30b22d76495"]]},{"id":"2bbc7f67f6d061b7","type":"trigger","z":"d5acb9a9f2d21fb0","name":"","op1":"","op2":"OFF","op1type":"nul","op2type":"str","duration":"5","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1050,"y":680,"wires":[["2f454e961ba73e2a"]]},{"id":"6881d618b8a74cb0","type":"inject","z":"d5acb9a9f2d21fb0","name":"TUB Pump ON","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":500,"y":640,"wires":[["893bc30b22d76495"]]}]

Sorry, Door.Status will not work as you never know if somebody is joining or leaving... e.g. 1st Person is entering => light on than a few minutes later 2nd person is joining => Light would go OFF

Wouldnt it be easier to just get a button (whatever technology you use - Zigbee, etc etc) and put it on the outside of the door - hit it when you enter and when you leave ?

Craig

Hang on - you state in the last answer down below you want to cater for a 2nd person entering - based on your statements above - the current solution can not work for this ?

Craig

What is the difference between that and what you said was working in the first post?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.