"Heart" here is a metonym for a person's inner consciousness, thoughts, motivation, or feelings. Alternate translation: "thought to himself" (See: [[rc://en/ta/man/translate/figs-metonymy]])
Here "house" is a metonym representing family or descendants. Alternate translation: "the kings descended from David" (See: [[rc://en/ta/man/translate/figs-metonymy]])