So… If you post a question about your config or an error caused from your config. Do you think you might want to also post your config with the question?
When you assigned D4 to pin, did you make a typo and use a period ( . ) after pin? Thats what it looks like and it needs to be
pin: D4
Not
pin. D4
Its hard to say really. My crystal ball is at the shop getting some wicked flames painted on it so, your gonna need to post your yaml.