Working binary sensor in ESPHome is "unknown" in HA

ESPHome 2022.12.3
Home Assistant 2022.12.8

I have a strange issue.
I use ESPHome to read modbus values.
Several errors are coming in a bitmask. I used the ESPHome howto to read out the bitmask.

binary_sensor:
  - platform: modbus_controller
    modbus_controller_id: mtec
    name: "MTec Mains Lost"
    entity_category: diagnostic
    device_class: problem
    register_type: holding
    address: 10112
    bitmask: 0x1
  - platform: modbus_controller
    modbus_controller_id: mtec
    name: "MTec Grid Voltage Fault"
    entity_category: diagnostic
    device_class: problem
    register_type: holding
    address: 10112
    bitmask: 0x2
  - platform: modbus_controller
    modbus_controller_id: mtec
    name: "MTec Grid Frequency Fault"
    entity_category: diagnostic
    device_class: problem
    register_type: holding
    address: 10112
    bitmask: 0x4
[...]

The sensors are read perfectely on the web server of the ESP:

However, Home Assistant does not recognize the value and states “unknown” for all thoses ESP binary sensors:

If you have not done so already, try deleting the integration for the device in question on the Integrations page. Then restart HA and re-add/reconfigure the device in the integrations page. I have had this happen to a few ESPHome devices since the 2022.11 release, the latest just a couple days ago. When checking the logs via USB they showed repeated api connection issues.

Thanks, but I had no luck. Deleted the integration, restartet Home Assistant, added the ESPHome node - sensors still “unknown”.

Is this a bug in ESPHome?

I was going to suggest the same thing as that’s a common issue. Do you have any other typws of sensors or switches on that device that do show up? If all of your sensors are modbus, try creating a test switch or binary sensor. This won’t fix the problem but it will help narrow down if it’s specific to the modbus sensors or there’s some other issue blocking the communication. If a test gpio switch or whatever works then we know it’s communicating properly.

I have a lots of sensors on the same modbus that show up normally. It’s either caused by binary sensors, or by device_class: problem.
I tried without device class, still does not work.

are the modbus values you are expecting supposed to be ON/OFF? or are you trying to get some other value? binary sensor is ON or OFF only, your not going to get any integers or floating point data from a binary sensor.

Yes, it is a binary sensor which can only be ON or OFF.

It is binary on/off from a bitmask, basically just like in the howto here:

follow, having the exact same issue