Custom Light update brightness from esp to ha

hello is it possible to update the state of the brightness from esp to ha?

With a custom switch i can update the state like this(just a example):

    void loop() override 
  {	
if(i_feel_like_it==1)
{
publish_state(1);
}	
  }

Is there some way to do something similar with a custom light brightness?