At home, I would say Hi if I'm coming home after being out or if someone else comes home after being out (at least if I'm in the same room). There are probably also circumstances when no one has left the house where I would also say Hi, but I can't summarize them.
Similarly, if I'm leaving the house, I would say Bye, and if someone else is leaving the house, I would say Bye to them (at least if they were in the same room as me). I wouldn't normally say Bye if someone was going to a different part of the house, and I probably wouldn't say it if they were going out to work in the yard.
If a visitor arrives at the house I would say Hi to them, and if a visitor leaves, I would say Bye to them.
I don't know if I have a definable principle for saying Hi to people I meet outside the house.
_________________
Now convinced that I'm a bit autistic, but still unsure if I'd qualify for a diagnosis, since it causes me few problems. Apparently people who are familiar with the autism spectrum can readily spot that I'm a bit autistic, though.