How to create custom serial light

I’m a new Home Assistant user who is looking to migrate his home automation (all written in C) to this much more flexible and modular platform.

I’m trying to create a “light” device that communicates with my personal SCS Biticino gateway that accepts and sends ASCII strings over the serial port.

I should use the ttyAMA0 serial port (Pin 15 and 16) with bitrate 115000.

To turn on the light I have to send the following ASCII string: “@W7light01
To turn off the light I have to send the following ASCII string: “@W7light00

When the light is turned on by a generic button (physical house button) I receive the following string “W6light01” on the serial link, when it is turned off I instead receive “W6light00”

How can I create this light device?

I’ll actually have to create one for every light in the house.

I installed the latest version of Homeassistant on raspbery pi 4, and I was unable to access the serial port.
Are pins 14 and 15 blocked by another software?

Thanks in advance

Any suggestion/ideas?

Is this thread of any help?

This is the code that I’m facing off!

IT works, but it doesn’t update the light status. When I turn on, the light goes on but after fews seconds the switch turn of (the light stay on).

Any ideas ?

configuration.yaml

light:
  - platform: template
    lights:
      luce_sala:
        friendly_name: Luce Sala 
        value_template: "{{ is_state('light.luce_sala', 'on') }}"
        turn_on:
          service: shell_command.accendi_luce_sala
        turn_off:
          service: shell_command.spegni_luce_sala


shell_command:
  accendi_luce_sala: "echo '@W7A88780120015A3' > /dev/ttyS0"
  spegni_luce_sala: "echo '@W7A88780120114A3' > /dev/ttyS0"