What is the motion detector’s entity_id? Does it begin with sensor or binary_sensor?
Go to Developer Tools > States, scroll through the list of entity_ids until you find the one that’s your motion detector. Tell me what it’s reporting as its current state value.
It is best to avoid devices in automations any time you can.
For triggers and conditions, state or numerical state are most used. For motion, it would most likely be state. From there you can pick the entity.
For actions, services are most used. To turn a light on, light.turn_on would be the right pick (unless it is defined as a switch, then switch.turn_on). There too the entities can be selected, along with service specific other options (e.g. light brightness if it supports that).
Services also support templates, this is a relevant example automation for just your use case:
I suggest you use a State Trigger and, for the trigger’s entity, pick binary_sensor.elkm1_basement_motion. In the To field, pick On.
The result will be a State Trigger that triggers when the binary_sensor turns on (i.e. motion detected).
The YAML version will look like this:
trigger:
- platform: state
entity_id: binary_sensor.elkm1_basement_motion
to: 'on'
Here’s a slightly better version that explicitly indicates it will trigger only for a state-change from off to on (not from any other state such as unavailable).
trigger:
- platform: state
entity_id: binary_sensor.elkm1_basement_motion
from: 'off'
to: 'on'
YAML relies on proper indentation. If something is indented too much, or too little, it takes on a different meaning, typically something that’s incorrect.
Move the last two lines to the left by two spaces so that it looks like this:
platform: state
entity_id:
- binary_sensor.elkm1_basement_motion
from: 'off'
to: 'on'
The faulty example you posted is not what I had suggested. Compare what you posted to what I suggested, line by line. See the difference?
I hope so; that’s the most basic form of State Trigger. However it’s also the most permissive and will trigger for any kind of state-change as well as any change in the value of any of its attributes.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.