Alright. First things first. Let me show you my script:
stairsmotion:
alias: Stairs Camera Motion Detection ON
sequence:
- service: notify.jarvis_lenovo
data:
data:
method: alarm
message: chime
- service: light.turn_on
entity_id: light.office_screen
- service: light.turn_on
entity_id: light.bedroom_screen
- service: light.turn_on
entity_id: light.entrance_screen
- service: shell_command.cctv_kodi_stairs
- service: counter.increment
entity_id: counter.motioncounter_stairs
- service: automation.trigger
entity_id: automation.sys_stairs_camera_snapshot
This script runs a numerous of services that I want to run everytime a motion is detected from my stairs cam. There is nowhere a service to “turn on” the script like you thought ( I will explain later what script/turn_on does.
So, all you have to do is to create a script and tell it what to do when motion is detected. You will later connect this script to Motioneye. I will show you how.
The name of my script is stairsmotion. Yours can be anything.
Now you need to create a long-lived token from HA. Tokens in a simple explanation are something like a password. They give access to applications.
Go to Homeassistant and click to your profile like this:
Now go to the bottom of this page and create a long-lived token.
Name it as you like. It doesnt matter. COPY THIS TOKEN SOMEWHERE until you paste it to Motioneye because you wont be able to copy it again. This is for one time only. If you lose the token, you have to create a new one.
Now, lets go to Motioneye:
Go to Notifications and turn on Run a command
What you have to paste here is the command I told you on my previous post.
Let me explain you what it means:
curl -X POST -H "Authorization: Bearer TOKEN" -H "Content-Type: application/json" -d '{"entity_id": "script.yourscript"}' https://yourip:8123/api/services/script/turn_on
curl is a command for linux to send data using various protocols. We use POST here.
TOKEN is where you paste your long-lived token I told you before.
-d ‘{“entity_id”: “script.stairsmotion”}’ is what I put here because the name of my script is stairsmotion (see at the start of my post for the name)
https://yourip:8123 is your Homeassistant IP.
Now something I noticed here:
In my configuration.yaml I have setup a base_url according to this documentation:
https://www.home-assistant.io/components/http/#base_url
So… my base_url is my ddns name
I have noticed that using IP is not working for me, probably because I have this setup for remote access. If you havent setup like this, then IP will work for you maybe.
Finally, ** script/ turn_on is a trigger to activate the script. You dont have to reference it anywhere. It just tells HA to run the script.
Feel free to ask anything if I got you messed. I know it is a lot, but I wanted to make sure you understand what you are doing.