Regardless of whichever type of condition you choose to use, the point is that to achieve your goal you must insert a conditionbefore the final service call (shell_command). What you currently have is a template that is not part of anything and makes the automation invalid.
action:
- device_id: 2c136e2a7xxxxxxxxxxxxxxxxxxx
domain: lock
entity_id: lock.portone_di_casa_2
type: unlock
- condition:
condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
- service: shell_command.luce_salotto
mode: single