Light controlled by serial bus

I’d like to show and change the status of a light connected to esphome via a serial bus.

In Esphome, I set up the light and an output as follows:

light:
  - platform: monochromatic
    name: Accent Light
    id: accent_light
    output: accent_light_output

output:
  - platform: template
    id: accent_light_output
    type: float
    write_action:
      # called when user changes light state from Home Assistant
      - lambda: "transmitter->set_level(26, state);"

The code works fine for controlling the light from homeassistant with thetransmitter->setlevel command.

When the status of the light changes (e.g. via a local switch), the script below is called. How do I set the new brightness in esphome so that is will be reflected in Homeassistant?

script:
  - id: dimmer
    parameters:
      value: float
    then:
      # set the new brightness of the light in homeassistant
     ...

I tried calling turn_on on the light, but this will call the write_action and result in an infinite loop.

I must be missing something trivial …