H.P. Lovecraft at all times presented as a rationalist (albeit potentially drawing upon now-discredited science), and described his creations in terms of a universe with principles we could not understand populated with beings that are alien rather than divine. So—barring a deep and sustained deceit—he didn’t believe he was writing about occult truths in the sense of magic or religion: so, was he a skilled deceiver, an author who happened to tap a need to believe, or something else?
He was certainly inspired by works that it is claimed reveal real occult knowledge: for example, we know Lovecraft’s descriptions of hidden cults were at least partially inspired by Murray’s The Witch Cult in Western Europe, a book which a number of the first generation of Twentieth Century pagan revivalists drew upon for evidence of an ongoing tradition of folk magic; however, Murray’s work is entirely discredited in mainstream academia so the book might not have uncovered real occult knowledge.
Lovecraft also borrowed freely from the works of his contemporaries—not all of whom have left as detailed a set of papers as Lovecraft—so it’s possible one of the Lovecraft circle might have been inspired by something that in turn inspired Lovecraft. However, none of Lovecraft’s letters comment on any of his contemporaries claiming to have found real secrets—as opposed to spoofs of the same.
The Simon Necronomicon claims Lovecraft drew from Sumerian mythology; however, there is no archaeological evidence that the “names” Simon claims echo those of Lovecraft’s creations existed in the region at the time. Simon also alleges Lovecraft knew Crowley (which would have given him access to occult tomes); however, Lovecraft created Al-Hazred well before the earliest date he could have crossed paths with Crowley, so that would seem fabulation.
Colin Wilson’s introduction to the Hay Necronomicon mentions Lovecraft’s father having access to a secret tome upon which the Necronomicon was based; however, Wilson has later admitted he invented this “fact” (Crypt of Cthulhu, St John’s Eve 1984) as an homage to Lovecraft’s habit of taking a person and pretending they were part of the Mythos.
Thus, given Lovecraft’s obsessive and copious correspondence, it seems unlikely that he actually encountered any magical or religious books which weren’t freely available to anyone of suitable means and education at the time. So, if those are real occult secrets, then they inspired him but he didn’t believe them.
The theory that he dreamed the true nature of the universe but his waking personality caused him to consider the dreams merely nightmares that he worked into fictions is harder to judge either way: people have found possible links between his works and historical facts (half-similar names, significant dates, &c); however, the human mind is designed to find patterns, so it’s entirely possible Lovecraft’s dreams were produced by his unconscious finding the same half-links between things as others have used to suggest Lovecraft’s work fits together.
Ultimately, if there were a cult that had hidden ancient secrets from pre-history to the 1920’s that had somehow allowed Lovecraft access to their truths, then they’d be so good enough at hiding those truths that (i) another century of academic and conspiracy theorist investigation wouldn’t have suddenly uncovered widely circulated evidence and (ii) Lovecraft’s stories would have served the hiding of the truth not the revealing of it.
So, perhaps Lovecraft was inspired by real occult knowledge but he was inspired to write stories that contained no truths. Perhaps we might best transcend our limits by actively not worshipping his deities.