Restoration of lighting

Hello, I made a scene that became difficult but still works. I would appreciate it if you could suggest something easier.
My question is how it can be done, for example, with a mini R4 that is located at the exit of the gate. When I leave the house and turn it off to turn off all the lights that are set in a scene when I come home all the lights turn on, so far so good but I want if the lighting in the kitchen is on when I come back to turn it on again, more precisely it stays on as left on exit and restored on entry. Of course when I go out it’s always off in the kitchen. I hope you understood me.

I forgot to write that behind the power switch there is no place for a second device.

Hi there, it sounds like you want the light in the kitchen already on when you come back home to turn all lights on, do you have door sensor in home? if so, you can create a scene this way:
door sensor is detected as opened
The lighting in the kitchen ON

Thanks, this looks very easy which would be great.
To have a door sensor.
But if I’m at home and I turn off the kitchen light and when someone rings the doorbell and I have to open the door, then the kitchen will light up. I’m giving the kitchen as an example, otherwise the idea is to leave the living room, bedroom … on when you get home to light up. Another example if I left the kitchen on and the bedroom off (or vice versa) when I get home they turn on as I left them. It would be easiest if I installed a second device that cuts off the power supply to the main one and when I get back it restores the latter, but there is no room for this task.

The most difficult thing is to let the device determine the intention of “entering”. Currently, we let the device do a certain thing relying on certain trigger conditions, which may be entering a certain area (this can rely on IFTTT location service), it may be a certain detection result of the door sensor, but I think there is currently no way to achieve the effect you expect.

My intent to enter is a mini r4 power switch next to the front door that when I enter I turn it on and when I leave too.
But you obviously have something else in mind because I wrote above that there is a MINIR4 for input and output
So later I will write how I did it, I was hoping for an easy way but… :slight_smile:

Here is my solution:
As I wrote on the door entrance, I have a MINI R4 that I use as the main power switch.
I will give an example of the lighting in the kitchen, if it is left on, when I turn off the switch next to the front door, it turns off, when I get home and turn on the switch next to the front door, then the lighting in the kitchen turns on again, and vice versa, that is, it restores the last which is left but always turn off when exiting.
For this I needed an additional relay that I only use as a bridge afterwards, in my case R2 which I connected to the network and hid in the cabinet.
I made two scenes if the MINI R4 in the kitchen is off - then R2 is on and the second if the MINI R4 in the kitchen is on - then R2 is off. That is, to follow the kitchen but in reverse.
Two more scenes and we’re done.
If all conditions are met:
1… The MINI R4 to the entrance door is off
2… R2 is off
Then the MINI R4 kitchen turned off
Second scene
If all conditions are met:
1… The MINI R4 to the entrance door is on
2… R2 is off
Then the MINI R4 in the kitchen turned on

Finally, don’t forget to set up all devices - Initial state to Restore last!