I configured a webhook to pass my Skylink Door Sensor trigger to Hassio and turn on a light when the door is open and turn off the light 5 mins AFTER the door is closed. I cannot figure out how to add the delay.
Re-Reading your post I assume the trigger quoted is the door now closed, so you shouldn’t need the light.turn_on part as presumably it’s already on
Edit: summary of thread; ifttt will provide a trigger, but it’s meaningless unless you read the payload (I didn’t above) see mo’s solution at the end for circumventing this.
That is correct. Basically when I enter the house through the side entrance I want the light to turn on. and then when I close the door behind me, I want the light to turn off after 5 mins. Those are the two triggers for me from IFTTT. I have to use IFTTT because there is no integration for skylink in Hassio.
No wait…I don’t think that will work. The way I understand it is in the webhook 1 (when the door opens, turn on light) it is sending the service variable "service": "light.turn_on" and in the webhook 2 (when the door closes, turn off light) it is sending the service variable "service": "light.turn_off".
In my existing code I read this variable to take the approporiate action. service_template: '{{ trigger.event.data.service }}'
But in your code, any trigger on the event_type: ifttt_webhook_received would turn off the light after 5 mins, right?
I basically want, if the sensor is active (door is opened), the light goes on. and if the sesor goes back to normal (door closed), the light goes off after 5 mins of closing the door.
What really needs to happen is that when I read this service variable sent from IFTTT, I have to take action based on that. if it is the “off” service i have to add 5 mins delay.
I agree with you on the two automation. But how do I do that setup? What would I send from the webhooks? what do I put in the body of the ON webhook and OFF webhook to differentiate them? I followed the instructions from here: https://www.home-assistant.io/integrations/ifttt/
and those instructions allow to send all the data required to trigger the automation.
from what I am understanding you are saying is that maybe just send trigger words from webhook 1 and 2 and catch those in the automation 1 and 2 somehow.
Can you please point me in the right direction on how I can do this?
No, I don’t use ifttt but from what I’ve read you can publish to ifttt which will then talk to some of your iot devices “open the garage door”
Similarly they can tell ifttt that the garage door is closed
So the garage door opening triggers the light going on and the closing triggers the delay and off.
I must have missed something here let me read the who thread again
Okay, I’ve skimmed the IFTTT docs.
Your original code was as per the docs and completely useless to you needs.
The reason being that these are direct service calls set to use a generic handler operate on multiple devices and as such it has to operate as and when it’s received.
Far better would be triggers into different automations (well they’d all get it but we can filter) and then act specifically ie delay then off.
The calls seem flexible enough
Someone with actual experience of this may come by in the next 5 mins and solve this, I on the other hand have to go to bed AND think about this. It looks like it will have to parse the payload, test against expected and trigger the appropriate script. Hmmmmm !
Thank you very much! Love that you will be thinking about this in your sleep! I will also do some reading. Learning about templates etc…Maybe this will kick start my training into scripting…
so basically, since the turn on trigger does not require any delay, i am passing the service call directly. and for the turn off to day the delay I am using to call a script instead.
If there are better ways to do this, please reply with it. This stuff is exciting!
That’s as good as what I was going to suggest.
I was going to suggest creating an input boolean turning it on from ifttt when the door opens and using the input boolean turn on as a trigger for the light (bear with me I’ve not finished, as I know you can do this directly)
BUT
getting the garage door closing to turn off the input boolean which can trigger your delay.
Your way is better as it just creates a script, my way would need an input_boolean AND an automation (less is MORE )
AND you solved it yourself, how good is that!
Please mark your thread as self-solved (actually true in this case), it will help others
sounds good!!! I am also reading more and it seems like there is a way to create binary sensors using ifttt. If that is the case then a better approach would be to create binary sensor for the door and use that for automation of state change. that will also give me a sensor status of the door in HA.