Getting the state of a float output

Hello

Anyone know how to get the current state of a float output?

This is my output:

output:
 - platform: custom
   type: float
   lambda: |-
     auto digipot = new DS3502_Component(0x28);
     App.register_component(digipot);
     return {digipot};
   outputs:
     - id: dc_fan_output

This controls a fan, which a PID controller is using. But I don’t know how to get the fan speed (the float output state) for use elsewhere in the program.

id(dc_fan_output).state doesn’t work:

config/esphome/datacenter-fan.yaml:149:36: error: 'class esphome::output::FloatOutput' has no member named 'state'
  149 |       float speed = id(dc_fan_output).state;
      |                                    ^~~~~
*** [/data/datacenter-cooling/.pioenvs/datacenter-cooling/src/main.cpp.o] Error 1

Thanks