Change numeric MQTT values to TRUE or FALSE value

Hi all,

I have a sensor declared over configuration.yaml:

- name: AC200MAX ac output status
  unique_id: "ac200max_ac_output"
  state_topic: "bluetti/AC200M2142000119216/state/ac_output_on"

The state of the sensor is received as 1 or 0. How can I “cast” or change the received value to TRUE or FALSE or UNAVAILABLE at the configuration.yaml?

True/false : Make it a binary sensor instead of a sensor.
unavailable: add an availability template

Hi there,

When I config as binary with the following confinguration:

binary_sensor:
  name: AC200MAX ac output status
  unique_id: "ac200max_ac_output"
  state_topic: "bluetti/AC200M2142000119216/state/ac_output_on"

Even getting state messages of 1 and 0 the binary_sensor gets unavailable

binary_sensor:
  - name: AC200MAX ac output status
    unique_id: "ac200max_ac_output"
    state_topic: "bluetti/AC200M2142000119216/state/ac_output_on"
    payload_on: 1
    payload_off: 0

Thank you!!! it worked like a charm