PWM exercise, how to manage using a imput number helper

Hello,
I’m new on this platform, I come from experiences in other less younger prorgamming, management language.

So, I’d like ask for some indications to reach this target

  • Using an helper I can have slider that varies from 0 to 100
  • Using the “light” component as monochromatic I’d like to drive it by a PWM previously defined.

output:

  • platform: esp8266_pwm
    pin: GPIO4
    frequency: 1000 Hz
    id: PWM_GPIO4_D2
    inverted: False
  • platform: gpio
    pin: GPIO2
    id: GPIO_D2

So, using the automation I’m able to modify the PWM duty cycle value using something like but the variable myBrightness (the duty cycle control variable) is like fixed.

trigger:

  • platform: state
    entity_id:
    • input_number.mypwm
      from: null
      to: null
      variables:
      myBrightness: 80
      condition:
      action:
  • service: light.turn_on
    data:
    transition: 1
    brightness_pct: “{{ myBrightness }}”
    target:
    entity_id: light.esphome_pwm_e792ed_my_pwm_on_gpio4

The target is to modify the myBrightness variable accordingly to the slider value.

I googled a lot, I tried to look in the community guides, but, regrettably without success.

So, could some one suggest me where to investigate, some suggestions.

Thanks in advance

https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16