synthetic_home.tool.create_inventory
Create inventory files from a synthetic home device file.
Given a home yaml file:
---
name: Family Farmhouse
devices:
Family Room:
- name: Family Room Lamp
device_type: light
device_info:
manufacturer: Phillips
model: Hue
- name: Family Room
device_type: hvac
device_info:
manufacturer: Nest
sw_version: 1.0.0
attributes:
unit_of_measurement: °F
current_temperature: 60
- name: Left Window
device_type: window-sensor
- name: Right Window
device_type: window-sensor
The create_inventory
command can convert it to an inventory file which can be
used with the synthetic home custom component.
$ synthetic-home create_inventory famhouse-home.yaml > famhouse-inventory.yaml
1"""Create inventory files from a synthetic home device file. 2 3Given a home yaml file: 4 5``` 6--- 7name: Family Farmhouse 8devices: 9 Family Room: 10 - name: Family Room Lamp 11 device_type: light 12 device_info: 13 manufacturer: Phillips 14 model: Hue 15 - name: Family Room 16 device_type: hvac 17 device_info: 18 manufacturer: Nest 19 sw_version: 1.0.0 20 attributes: 21 unit_of_measurement: °F 22 current_temperature: 60 23 - name: Left Window 24 device_type: window-sensor 25 - name: Right Window 26 device_type: window-sensor 27``` 28 29The `create_inventory` command can convert it to an inventory file which can be 30used with the synthetic home custom component. 31 32```bash 33$ synthetic-home create_inventory famhouse-home.yaml > famhouse-inventory.yaml 34``` 35""" 36 37import argparse 38import pathlib 39 40from synthetic_home import synthetic_home 41 42 43def create_arguments(args: argparse.ArgumentParser) -> None: 44 """Get parsed passed in arguments.""" 45 args.add_argument( 46 "config_file", 47 type=str, 48 help="Specifies the synthetic home config file.", 49 ) 50 51 52async def run(args: argparse.Namespace) -> int: 53 home = synthetic_home.load_synthetic_home(pathlib.Path(args.config_file)) 54 inventory = synthetic_home.build_inventory(home) 55 print(inventory.yaml()) 56 return 0
def
create_arguments(args: argparse.ArgumentParser) -> None:
44def create_arguments(args: argparse.ArgumentParser) -> None: 45 """Get parsed passed in arguments.""" 46 args.add_argument( 47 "config_file", 48 type=str, 49 help="Specifies the synthetic home config file.", 50 )
Get parsed passed in arguments.
async def
run(args: argparse.Namespace) -> int: