sensor: - platform: template name: "Bathroom Scale" id: bathroom_scale unit_of_measurement: "kg" esp32_ble_tracker: on_ble_service_data_advertise: - mac_address: 70:87:9E:11:22:33 service_uuid: 181D then: - lambda: |- uint8_t flags = x[0]; bool has_weight = (flags & (1 << 7)) == 0; bool is_stable = (flags & (1 << 5)) != 0; bool unit_jin = (flags & (1 << 4)) != 0; bool unit_lb = (flags & (1 << 2)) != 0; bool unit_kg = (flags & (1 << 1)) != 0; ESP_LOGD("scale", "Flags: %u has_weight=%u is_stable=%u unit: jin=%u lb=%u kg=%u", flags, has_weight, is_stable, unit_jin, unit_lb, unit_kg); uint16_t weight = (((uint16_t)x[2]) << 8) + x[1]; double weight_f = (static_cast(weight) / 100.0) / 2.0; // kg ESP_LOGD("scale", "Weight: raw=%x%x u16=%u kg=%f", x[1], x[2], weight, weight_f); if (has_weight && is_stable) { ESP_LOGI("scale", "Publish weight %f", weight_f); id(bathroom_scale).publish_state(weight_f); }