Most players do not like ballistas killing them and their pets. However, the devs don't want automated death machines that trivialize boss encounters (instead you need to cheese the old fashioned way, in a treehouse). Also, IFF systems seem a bit TOO magical for some.
So for some middle ground… how about if ballistas had a storage slot for a trophy, and they only target whatever trophy they have installed? It protects players, makes ballistas non-omnipotent, and prevents wasting ammo on Graylings, and makes more sense than magically knowing if an entity is hostile. It might even make them more useful in difficult raids. And it prevents use against bosses and other new threats that the player is not strong enough to kill. Best of all, it finally gives trophies a use.
Base or upgraded ballistas could have multiple storage slots if that helps balance resource and space considerations, but either way, this seems to solve most if not all of the potential issues with ballistas. Possibly a ballista without a trophy could revert to attacking anything that moves, but I think having it do nothing would be good too. It really gives you an incentive to go out there and take heads.
Source: https://www.reddit.com/r/valheim/comments/zpn67w/trophyconfigured_ballista_targeting/