The error message says that it can't find the "hero" entity.
The reason is that you never asked the engine to give it to you in the first place.
Since you intend to make some generic behavior for the hero -hero_meta-, you should use the hero's metatable (using sol.main.get_metatable), and then define what you need here. it works the same as using the hero directly, but more like a model, so multiples heroes will get the same behavior.
If you know the concept of object-oriented programming, then think of modifying the class instead of the instances.