Automation when light turn on

why i got an error with this

  • alias: Ligar luz Candeeiro
    initial_state: ‘on’
    trigger:
    • platform: state
      entity_id: light.sala_candeeiro_11
      from: off
      to: on
      action:
      service: scene.turn_on
      entity_id: scene.Chegar_a_Casa
Looks like the indents are out of place. Try this:

 alias: Ligar luz Candeeiro
 initial_state: ‘on’
 trigger:
  -  platform: state
     entity_id: light.sala_candeeiro_11
     from: off
     to: on
 action:
   - service: scene.turn_on
     entity_id: scene.Chegar_a_Casa

First of all, it’s always great to post your config preserving formatting - just put 3 single backquotes around it.
Secondly, it’s vital to post as much info that is related to your question as possible. you said “an error with this” but haven’t posted any more info on that…

At this stage I can only add that according to the docs it’s advisable to enclose all states’ names in single/double quotes for automations to work.

the formatting of the code you suggested is also incorrect. And be wary of which style of quotation marks you are using there are the standard text style and “fancy” style. the fancy style won’t work.

to the OP, you can’t use capital letters in your entity_id’s. And we can’t tell if there are other errors in your syntax because you didn’t properly format your code as pointed out above. But based on the limited information you provided then try this:

   - alias: Ligar luz Candeeiro
     initial_state: 'on'
     trigger:
       - platform: state
         entity_id: light.sala_candeeiro_11
         from: 'off'
         to: 'on'
     action:
       - service: scene.turn_on
         entity_id: scene.chegar_a_casa