Round state number in MQTT publish

I have this YAML code that will publish a JSON when there is a change in the light value

sensor:
  - platform: bh1750
    name: "Illuminance"
    id: illuminance
    address: 0x23
    update_interval: 15s
    accuracy_decimals: 0
    on_value:
      then:
        - mqtt.publish:
            topic: esphome/bedroom/back-motion-light-sensor
            payload: |-
              root["illuminance"] = id(illuminance).state;
              root["motion"] = id(motion).state;

the problem is that the lux value has many decimal places like this

{"illuminance":23.65649,"motion":false}

How can I get the illuminance value to look like this - ie: 23.6xxx will become 24 and 23.4xxx will become 23

{"illuminance":24,"motion":false}

Thanks in advance.

Use a template. See the topic "templating” in the docs.

Thanks for your suggestion.

For anyone has the same need, here is the code I used:

sensor:
  - platform: bh1750
    name: "Illuminance"
    id: illuminance
    address: 0x23
    update_interval: 15s
    accuracy_decimals: 0
    on_value:
      then:
        - lambda: |-
            id(ml_sensor).publish_json("your/topic", [=](JsonObject root) {root["illuminance"] = round(id(illuminance).state);root["motion"] = id(motion).state;});