MQTT state update problem

Hello. I have a raspberry running HA and Mosquitto and a Arduino sends and receives data but when I publish a state to turn on a light on mosquitto with mqttfx the arduino turn on the light but HA says the light is off and I don’t know how to update this state in HA

Using the ‘state_topic’ in your MQTT device definition in HA will cause it to subscribe to that topic and update the state accordingly. See the MQTT Switch component