MQTT Binary Sensor Integration in HomeAssistant

I’m currently working on integrating an MQTT binary sensor into my HomeAssistant setup, and I’m running into a bit of a snag. Let me walk through what I’ve done so far and where I’m getting stuck.

First, I set up my MQTT broker and made sure it’s communicating correctly with HomeAssistant. I have a binary sensor that’s supposed to report the online status of an inverter, and I’ve configured it using the HomeAssistant discovery syntax. Here’s the channel configuration I’m using:

yaml
id: z_online
channelTypeUID: mqtt:ha-switch
label: Inverter Online
configuration:
component: binary_sensor
config:
- |
{
“name”: “Inverter Online”,
“unique_id”: “z_online”,
“state_topic”: “aps/x/y”,
“value_template”: “{{ value_json.online }}”,
“device”: {
“identifiers”: [“y”],
“name”: “APS Inverter y”,
“manufacturer”: “APsystems”,
“via_device”: “x”
},
“availability_topic”: “aps/status”,
“payload_available”: “online”,
“payload_not_available”: “offline”,
“payload_on”: “true”,
“payload_off”: “false”,
“icon”: “mdi:power-plug”
}

The MQTT message I’m receiving looks like this:

{
“online”: false
}

Everything seems to be in order on the MQTT side, but when I try to bind this to an OpenHAB channel, I get an error: Command 'True' from channel 'mqtt:homeassistant:x:y:z_online' not supported by type 'OnOffType'. It seems like OpenHAB isn’t correctly mapping the true/false boolean values to the OnOffType.

I’ve tried using different profiles and configurations, but the issue persists. The event doesn’t even reach the profile step, which suggests there’s something fundamental I’m missing in the setup. I’m wondering if there’s a specific way to handle boolean values in MQTT bindings or if there’s an alternative approach to ensure compatibility with OpenHAB’s OnOffType.

Has anyone encountered a similar issue before? Any insights or workarounds would be greatly appreciated!