Skip to content
Snippets Groups Projects

WIP: Resolve "YAML Generation"

Open Julian requested to merge 1-yaml-generation into master
2 files
+ 41
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -188,3 +188,29 @@ def export(out_path: str) -> None:
@@ -188,3 +188,29 @@ def export(out_path: str) -> None:
print(f"Writing to {filepath}...")
print(f"Writing to {filepath}...")
with open(filepath, "w") as file:
with open(filepath, "w") as file:
file.write(text)
file.write(text)
 
 
 
def export_yaml(out_file_path: str) -> None:
 
"""
 
Exports the current device configuration to a Home Assistant YAML file.
 
:param out_file_path: Path to write the YAML file to
 
"""
 
 
x = {
 
'alias': 'Rule 1 Light on in the evening',
 
'trigger': [
 
{'platform': 'sun', 'event': 'sunset', 'offset': '-01:00:00'},
 
{'platform': 'state', 'entity_id': 'all', 'to': 'home'}
 
],
 
'condition': [
 
{'condition': 'state', 'entity_id': 'all', 'state': 'home'},
 
{'condition': 'time', 'after': '16:00:00', 'before': '23:00:00'}
 
],
 
'action': {'service': 'homeassistant.turn_on', 'entity_id': 'group.living_room'}
 
},
 
 
# for filename, text in exports.items():
 
# filepath = os.file_path.join(out_file_path, filename)
 
# print(f"Writing to {filepath}...")
 
# with open(filepath, "w") as file:
 
# file.write(text)
Loading