@LudovicH
You may reference this: https://esphome.io/components/binary_sensor/