From d789de9ea2b82bef418e1a14241c0532952734f6 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 26 Feb 2017 15:28:12 -0800 Subject: [PATCH] Config fix (#6261) --- homeassistant/components/config/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/config/__init__.py b/homeassistant/components/config/__init__.py index 9fbb030e96e..631650077ce 100644 --- a/homeassistant/components/config/__init__.py +++ b/homeassistant/components/config/__init__.py @@ -129,5 +129,8 @@ def _read(path): def _write(path, data): """Write YAML helper.""" + # Do it before opening file. If dump causes error it will now not + # truncate the file. + data = dump(data) with open(path, 'w', encoding='utf-8') as outfile: - outfile.write(dump(data)) + outfile.write(data)