Hi,
I want to create a little advent surprise so that when a user hits a static page home assistant will start playing a video on the TV.
So I’ve got a script to play a video via Chromecast and that works.
Now I want to be able to execute the script when the user goes to a webpage. So I have created a static page in ${ha_config}/www/advent.html now how can I execute the script when the user requests the page? I tried using a Ajax post request but I get an authenticaion error:
$.ajax({
url: 'REDACTED_URL/api/services/script/turn_on',
type: 'post',
data: {
"entity_id": "script.advent_script",
},
headers: {
'Authorization': 'Bearer REDACTED_TOKEN'
},
dataType: 'application/json',
success: function (data) {
console.info(data);
}
});
Any ideas what I need to do? I can also run this on another web server if required but I figure with cross site scripting issues this will be easier.