Taffu is correct. With the original code in the first post, if the player logs in with out a pet or the mod loads too early, petName will be nil. It is because it only sets petName when the script is read the first time.
The best solution is to register for event UNIT_PET because it fires when something happens to your pet. It should always occur during loading if the pet is out when logging in.
Code:
function HEmote_OnLoad (self)
this:RegisterEvent("PET_ATTACK_START");
self:RegisterEvent("UNIT_PET");
...
function HEmote_OnEvent(self, event, ...)
if (event == "UNIT_PET") then
petName = UnitName("pet");
elseif (petName and HEon == "1") then
...