What causes the door to appear in The Hobbit? Should the dwarves have predicted this event? Why didn't they?
In The Hobbit, there are moon-letters on the map Thorin received from Gandalf, and those moon-letters are translated by Elrond when the company arrives in Rivendell: "Stand by the grey stone when the thrush knocks and the setting sun with the last light of Durin's Day will shine upon the key-hole." Just as Elrond's translation said, the door opened when a thrush (a type of bird) was knocking on the wall with a snail's shell and the last ray of light on Durin's Day shone on the wall; when the light hit the stone, a small piece cracked off, revealing the key-hole.
So, yes, the dwarves should have known exactly when the door would open because Elrond told them the map's instructions, but they were so excited about finally reaching Erebor and getting into the mountain that they forgot about what Elrond told them.