HA input_number to DAC

How can I pass an input_number formatted as a percentage from ha to a DAC output on a esp32?
I’m always getting error on the compilation phase.

output:
  - platform: esp32_dac
    pin: GPIO26
    id: dac_output

sensor:
  - platform: homeassistant
    name: "Percentage"
    entity_id: input_number.zero_export_energy
    id: zero_export_energy
    on_value_range:
      - above: 0
        then:
          output.set_level:
            id: dac_output
            level: !lambda 'return id(zero_export_energy);'

error:

/config/esphome/base_esp32.yaml:66:14: error: cannot convert 'esphome::homeassistant::HomeassistantSensor*' to 'float' in return
             level: !lambda 'return id(zero_export_energy);'
              ^

So simple as

output:
  - platform: esp32_dac
    pin: GPIO26
    id: dac_output

sensor:
  - platform: homeassistant
    name: "Percentage"
    entity_id: input_number.zero_export_energy
    id: zero_export_energy
    on_value:
      lambda: id(dac_output).set_level(id(zero_export_energy).state/100);

How the ignorance makes a guy lose the best part of his Saturday :frowning: