How to pass the state_value of an entity as a parameter into a Custom componet class

I have this situation

I would like to pass several H.A. entities value to the class of my custom component library into the YAML code
let’say the entity is given by a helper
her my C code

---C code---
my personal .h file 

class cESPCustomDevice : public PollingComponent, public Sensor { 
  public:
    float param1, param2, param3;
    cESPCustomDevice(float p1, float p2, float p3) : PollingComponent(100) { //costructor
      param1 = p1;
      param2 = p2;
      param3 = p3;
    };
	Sensor *MySensor = new Sensor();
....
	MySensor->publish_state(val);
}

so once defined in H.A. a helper “input_number.param1”
I have this YAML

---YAML code---
#definition of a "local" entity 'par1' equal to the global H.A. entity input_number.param1
sensor:
- platform: homeassistant
  name: "Param_1"
  entity_id: input_number.param1
  id: par1
	
- ...Param_2
- ...Param_3

#using the local entity id(par1).stateto pass at the my class "cESPCustomDevice" the value of
# global entity input_number.param1 (H.A. helper)

- platform: custom
  lambda: |-
    auto esp_customcomponent = new cESPCustomDevice(id(par1).state, ... , ...);
    App.register_component(esp_customcomponent);
    return {esp_customcomponent->MySensor};

This trick WORKS fine but my question is:
There is a EASIER and DIRECT solution to pass the entity value “input_number.param1” in the YAML file instead to define a local entity “par1” and passing it ???
I guess this is a bit redudant and there shoul be an simpler way.
I tried with

- platform: custom
  lambda: |-
    auto esp_customcomponent = new cESPCustomDevice(id(input_number.param1).state, ... , ...);

and also

  auto esp_customcomponent = new cESPCustomDevice(id(input_number.param1).currentstate, ... , ...);

But it doensn’t work

Somebody have a suggenstion?

I suggest that this is the way to do it.

Checking better, I was wrong it doens’t work @nickrout

If I print the directly into the C code id(par1).state it work th lgo is pronted correctly
Unfortunatly this is a hardcoded solutions, not flexible.
I would like to pass the parameter to the class instance delaration in th yaml

 auto esp_customcomponent = new cESPCustomDevice(id(par1).state, 123 , 345.);

If I pass a constant parameter (such 123 or 345) when I define the class,
the value is logged correctly but it doesn’t recognize the value of instance par1
In this case the LOG stamp indicates me value “nan”.
Do I miss something?

Hello, nobody has ever faced up this issue?