Is it possible to send a trigger to Ha depending what serial input a esp32 get with esphome

Hi, I like to send different triggers to home assistant depending on what serial input code a esp32 or esp8266 gets. So, every serial input code generate a corresponding trigger in home assistant. I like to make it in esphome , is that possible?

Are there some samples where I can see how to start?
Thanks.

Of course you can handle serial commands feedback in ESPHome but you’ll have to use lambdas which is really not easy to code ! What device are you controling ?
Did you get a look at that page ? UART Bus — ESPHome

I like to make a bus system around my house that is connected with wall push buttons. So in the living I like 3 times a 6 gang push buttons panel. Every button sends a serial code to a esp32/8266 that generates, depending on the code, a trigger in home assistant.
I have now a zigbee system, but have interference problems. I changed the channels already from low to middle to high number, but always with problems.

Much easier to send the serial code straight to HA and let it work out what to do with it. Give us some examples if you need help.

The serial code, comes from an arduino or attiny85 and send it with a open collector transistor to the serial input of the esp32 or to the raspberry pi. We never pushes 2 buttons at the same time. so collision is no problem.
I never used the hardware ports on the raspberry pi with home assistant. That’s new for me.

To be clear, I meant “receive the serial code on the ESP and send it to HA as a sensor output over the API”.

Ok, I was thinking to make a trigger, but I’m new to that subject and don’t know where to start and where the final end could be.
So, my goal is, I push a button, a unique serial code for that button is sent to a esp32 that is sending ??? ( something ) to home assistant thats start an automation.

Yeah: send the unique serial code to HA, and choose what to do there in one or more automations:

trigger:
  - platform: state
    entity_id: sensor.SERIAL_CODE_FROM_ESP
    to: "SPECIFIC CODE"
action:
  - ACTION HERE

How do I have to setup esphome for my esp32

OK: you haven’t got as far as the ESP device yet.

Probably start here:

I have a look, I’m a hardware man. Software and home assistant is in startup. Many thanks for the help

trigger:
  - platform: state
    entity_id: sensor.SERIAL_CODE_FROM_ESP
    to: "SPECIFIC CODE"
action:
  - ACTION HERE

Where do I have to put the code from above? In configuration.yaml?

You don’t do anything with that until you have got the data coming into your ESP, and have a sensor in HA that is showing the data.

Once you have that sensor showing the serial data in HA, you can create automations via the UI:

image

Obviously, it’s throwing an error for me as I don’t have that sensor.

Ok, it starts to get clear.

Is that a possible problem? => Custom UART Device — ESPHome
stating that they will stop?