Closed sinker1345 closed 4 years ago
I will look into that.
Thank you for taking the time, I don't know python but if you need help testing or anything let me know
I updated the code and it now supports long-lived tokens. I've tested it and it works locally.
It looks like calling scripts with IFTTT using long-lived tokens is not as straight forward as with legacy API. It's possible, but I don't have much spare time at the moment to give an exmple.
If you have time and can provide an example I would greatly appreciate it.
I may not be able to update this and mess with it any time soon but as soon as I am able to play with it I will provide an example
OK so I sat down and worked through this.
You do not need to send the header through IFTTT. I use the IFTTT webhook recieved trigger. I have more then one of these so I have to make conditions to ensure only one runs at a time (as they use the same webhook). I have included an example code below.
- alias: "IFTTT"
trigger:
- platform: event
event_type: ifttt_webhook_received
event_data:
action: call_service
condition:
condition: and
conditions:
- condition: template
value_template: "{{ trigger.event.data.service != 'script.download_movie' }}"
action:
- service_template: '{{ trigger.event.data.service }}'
data_template:
entity_id: '{{ trigger.event.data.entity_id }}'
- alias: "IFTTTmovie"
trigger:
- platform: event
event_type: ifttt_webhook_received
event_data:
action: call_service
condition:
condition: and
conditions:
- condition: template
value_template: "{{ trigger.event.data.service == 'script.download_movie' }}"
action:
- service_template: '{{ trigger.event.data.service }}'
data_template:
movie: '{{ trigger.event.data.movie }}'
on IFTTT my webhook has a link in the following format
https://HA_WEB_ADDRESS/api/webhook/IFTTT_WEEBHOOK_ID
the method is still POST and content type is still application/json
The body has changed to
{ "action": "call_service", "service": "script.download_movie", "movie": "{{TextField}}"}
using this method I am able to call the downloader script and get a response as well as call other applets that do not need the addidional movie: field in HA without error
Sorry for the long delay on working through this.
Thank you for taking the time to provide a detailed example. This actually helped me to update my setup, and I'm sure it will help others. I'll link your post in the project description as a reference to how integrate this with IFTTT.
Im nearly done, I set everything, one by one everything working except the the movie name. If I fix the movie name in the shell script I can use with IFTTT and downloads it, but if I write back $1, It does not recognize movie name, and drops error.
Im nearly done, I set everything, one by one everything working except the the movie name. If I fix the movie name in the shell script I can use with IFTTT and downloads it, but if I write back $1, It does not recognize movie name, and drops error.
Can you share your automation code and IFTTT setup. Make sure to delete any sensible information like your HA_WEB_ADDRESS and IFTTT_WEEBHOOK_ID
Hallo my friend,
I was able to make it work from HA Terminal, but as soon I run it from HA with automation, its not working. The parameter movie name and 0 is failing because of qoutes im nearly sure.
Here is the issue I opend: https://community.home-assistant.io/t/quotes-ssh-and-docker-shell-commands/234935
Thank you mate :)
Can we please update this script to remove the reliance on the legacy API key? It is supposed to be deprecated soon and I currently only need to keep it active because of this integration.