Door sensor, current state, not change of state

Hello,

I’m having an issue with my door sensor which controls my aircon. I can only get it to turn OFF the AC when the state CHANGES to OPEN but what I basically need is for the door sensor to trigger OFF if the door is not closed e.g. more than 1 min. regardless of it’s being opened (new state) or simply is open already.

I can’t find a way around that, any ideas will be much appreciated.

1 Like

If I understood you correctly, you want to turn off AC is the door stays open for more than 1 minute, right?

It that’s the case, you need to add a delay to the condition so it only gets triggered after being “open” for 1 minute:

2 Likes

Hi,

Thanks for your input, much appreciated.

That’s definitely a possibility but will it sort out the issue of a NON CHANGE OF STATUS? Imagine that the AC is turned on with the door open, in that case there’s no change of status, that’s my main issue.

In other words, if the AC is on with the door closed, and the door is then opened, then it will trigger turning off the AC. But if the door is already open when the AC is turned on, and even left open with the AC on then I guess a delay function will not solve this?!?!

2 Likes

What do you want to happen if the door is open and you turn on the AC? Turn it off immediately? Or after 1 minute too?

Hi,

Yes, that’s right. If the AC is turned on with the door already open it shouldn’t disconnect immediately, a 1 min. delay would be practical.

I think that a 1 min. delay in general is practical, also in the situation when the status of the door sensor changes from closed to open. The 1 min. delay in this specific situation you’ve explained well above, my problem is in the case of no change in status meaning that the door is actually already open when the AC is being turned on.

In other words, the idea is that the AC is turned off when the room is not occupied, that could also be done with a movement sensor but the problem is in the case that people sleep, thus very limited movement that would result in turning off the AC while they sleep, I could then make a feature saying “don’t turn off if no movement between 00 - 08 hrs.”, but the problem here is that the sleep pattern of these guests is very irregular.

Thus, the optimal solution is turning off the AC when the door is open, being in the case be status change (closed to open), and in the case that the door is already open and left open.

Thanks!

The solution would be to set the “door is open for at least 1 minute” condition to FALSE and then TRUE when the AC is turned on while the door is open, so that the 1 minute timer starts again… BUT you can’t do that because that condition is linked to a Tuya device. So you need to a create an auxiliar condition that can be controlled.

I would create a new auxiliar condition called ‘cond_door_open_1min’ linked to a new variable ‘var_door_open’, that would be set to TRUE or FALSE by a logicblock when the door sensor opens/closes.

This condition (‘cond_door_open_1min’ ) would have the 1 minute delay, rather than the original ‘cond_door_sensor_tuya_open’ linked to the Tuya device.

If the door is open when the AC is on, I would set that variable (var_door_open) to FALSE and then TRUE, so that the 1 minute delay in the ‘cond_door_open_1min’ starts again.

Check this:

Variables

  1. var_door_open (boolean)

Conditions:

  1. cond_door_sensor_tuya_open_trigger (linked to your Tuya door sensor device, “trigger”, no delay)
  2. cond_door_sensor_tuya_open_notrigger (linked to your Tuya door sensor device, “no trigger”, no delay)
  3. cond_ac_tuya_on (linked to your Tuya AC device, “trigger”, no delay)
  4. cond_door_open_1min (linked to boolean variable ‘var_door_open’, “trigger”, delay=1 min)

Logicblocks:

1. LB_update_var_door_open

Conditions:
[ x ] cond_door_sensor_tuya_open_trigger

Actions:
TRUE:
Set variable var_door_open to TRUE
FALSE:
Set variable var_door_open to FALSE

2. LB_turn_off_AC_if_door_open_1min

Conditions:
[ x ] cond_door_open_1min

Actions:
TRUE:
Turn off AC

3. LB_restart_door_1min_timer_when_AC_is_turned_on_while_door_is_open

Conditions:
[ x ] cond_ac_tuya_on
[ x ] cond_door_sensor_tuya_open_notrigger

Actions:
TRUE: (2 actions, one after the other)
Set variable var_door_open to FALSE
Set variable var_door_open to TRUE

Is it clear?

1 Like

@teknofilo to the rescue! :slight_smile: Very ingenious solution as always! :+1:

I’m thinking of a different approach with the basic idea: “Whenever the AC is turned on, turn if off after one minute, unless the door is closed”.
But if that work depends a bit on the devices:

  • Are you able to send AC on/off to Apilio? Is it a Tuya device or can you send it via IFTTT or webhooks?
  • I guess the door sensor has explicit states for closed and open?

I also thought about that but if you turn on the AC and, 55 seconds later you open the door, AC will turn off even if the door has been open for only 5 seconds

I’m thinking of using action delays, not on the condition, so it should work - but let’s see if @Jan has the AC state and if yes, I will try to post a configuration to try out :slight_smile:

Hi everyone,

Thanks a lot for the inputs.

Just a few words on the ACs. These are normal (non smart) split ACs usually controlled by an external remote control. What I have done thus far is to purchase door/window sensors and an IR Remote control.

In other words, the current action is to put the AC into off mode if the door is opened. In other words, the door/window sensor doesn’t know if the AC is actually on but it will regardless turn it off if the door is opened. That works alright not actually knowing if the AC is on as long as it’s being put into off mode regardless.

I’m not sure if that’s the information about the AC you are asking for, otherwise do let me know.

At the very core of this it’s a matter of the ACs being turned off if the door is not closed regardless of the ACs being turned on with the door closed or open (with a delay of 1 min.).

Does Apilio know when the AC is turned on? If not, you can’t implement the ‘cond_ac_tuya_on’ condition, so my solution does not work.

If the AC state change is not known to Apilio you have a basic problem. There is no “anchor” that can trigger any timer or check in Apilio if the door is not moved.
You could overcome this by having a smart plug with power meter. That way you could sense on/off and feed that information to Apilio.

The last workaround is to have a timed check (e.g. every minute). So you would check every minute (with a time condition) if the door is open for longer than a minute (with a condition with delay) and if yes, send an “AC off” command.

Yes, Apilio doesn’t know if the AC is on or off, the simple command if the door is opened is to put the AC into off mode - in other words, if the AC is off when the command is sent then it will stay off.

I was thinking earlier about the time check, every x-minute, as a solution - could you share an Apilio link to a document I can study on how to do this?

Also the smart plug with power meter sounds very interesting - can you by any chance suggest such smart plug?

For info on how to set up a condition that is triggered every x minutes, check Cron time conditions - Intro and how to set them up

For every minute, cron expression would be * * * * *

For every 5 minutes, it would be */5 * * * *

With regards to smart plug, I have one but unfortunately Apilio reads ‘0’ values for all parameters (current, voltage, power,etc.), so it is not a good option for you.

1 Like

I have this Tuya-based smart plug here: https://marmitek.com/collections/smart-plug/products/power-si-smart-plug-energy-meter-2x-usb-15a.
It works ok, but it is not super quick to respond to consumption changes. There are many Tuya-based products around. A good way to discover them is to search Amazon for “Smart Life” products, because very often they are advertised with that keyword.