Config extensions

- KNX consumption in W by template filter
- pool pump: runtime in h
This commit is contained in:
Martin Bauer
2019-07-07 17:31:38 +02:00
parent e6f5504181
commit 87e199e260
9 changed files with 371 additions and 29 deletions

View File

@@ -9,6 +9,9 @@ yaml = YAML()
def add_knx_devices(devices, groups):
imported_csv = knx.import_ets5_csv_file(os.path.join(script_path, 'knx_data/export_project1.csv'))
imported_csv.update(knx.import_ets5_csv_file(os.path.join(script_path, 'knx_data/export_project2.csv')))
lights = [
# Dimmers
DeviceInfo('Wohnzimmerlampe', 'Wohnzimmer Deckenlampe', 'living_area'),
@@ -56,15 +59,15 @@ def add_knx_devices(devices, groups):
power_plugs = [
# Vorratsraum
DeviceInfo("VorratsraumSteckdose1", "Vorratsraum Steckdose", 'other'),
DeviceInfo("VorratsraumSteckdose2", "Vorratsraum Steckdose", 'other'),
DeviceInfo("VorratsraumSteckdose1", "Vorratsraum Steckdose 1", 'other'),
DeviceInfo("VorratsraumSteckdose2", "Vorratsraum Steckdose 2", 'other'),
DeviceInfo("VorratsraumSteckdose3", "Gefrierschrank", 'other'),
# Waschraum
DeviceInfo("Trockner", "Trockner", 'other'),
DeviceInfo("Waschmaschine", "Waschmaschine", 'other'),
# Küche
DeviceInfo("KücheSteckdose1", "Küche Steckdose 1"),
DeviceInfo("KücheSteckdose2", "Küche Steckdose 2"),
DeviceInfo("KücheSteckdose1", "Küche Steckdosen rechts"),
DeviceInfo("KücheSteckdose2", "Dunstabzug"),
DeviceInfo("Spülmaschine", "Spülmaschine", 'living_area'),
DeviceInfo("Backofen", "Backofen", 'living_area'),
DeviceInfo("HerdP1", "Herd Phase 1", 'living_area'),
@@ -76,9 +79,51 @@ def add_knx_devices(devices, groups):
DeviceInfo("WohnzimmerSteckdose2", "Wohnzimmer Steckdose 2", 'living_area'),
]
imported_csv = knx.import_ets5_csv_file(os.path.join(script_path, 'knx_data/export_project1.csv'))
imported_csv.update(knx.import_ets5_csv_file(os.path.join(script_path, 'knx_data/export_project2.csv')))
motion_sensors = {
'sensor': [
# Brightness
{'name': 'Gang Bewegungsmelder West Helligkeit',
'address': imported_csv['BewegungsmelderWest Helligkeit'],
'type': 'illuminance'},
{'name': 'Gang Bewegungsmelder Mitte Helligkeit',
'address': imported_csv['BewegungsmelderMitte Helligkeit'],
'type': 'illuminance'},
{'name': 'Gang Bewegungsmelder Ost Helligkeit',
'address': imported_csv['BewegungsmelderOst Helligkeit'],
'type': 'illuminance'},
# Temperature
{'name': 'Esszimmer Temperatur',
'address': imported_csv['TemperaturEsszimmer'],
'type': 'temperature'},
{'name': 'Treppenhaus Oben Temperatur',
'address': imported_csv['TreppenhausObenTemperatur'],
'type': 'temperature'},
{'name': 'Eingangsbereich Temperatur',
'address': imported_csv['TemperaturGang'],
'type': 'temperature'},
{'name': 'Wohnzimmer Gang Temperatur',
'address': imported_csv['TemperaturWohnzimmerGangTuer'],
'type': 'temperature'},
{'name': 'Wohnzimmer Terassentür Temperatur',
'address': imported_csv['TemperaturWohnzimmerAussenTuer'],
'type': 'temperature'},
],
'binary_sensor': [
{'name': 'Gang Bewegungsmelder Schlafzimmer',
'address': imported_csv['BewegungsmelderWest Motion Links'],
'device_class': 'motion'},
{'name': 'Gang Bewegungsmelder Wohnzimmer',
'address': imported_csv['BewegungsmelderWest Motion Rechts'],
'device_class': 'motion'},
{'name': 'Gang Bewegungsmelder Mitte',
'address': imported_csv['BewegungsmelderMitte Motion'],
'device_class': 'motion'},
{'name': 'Gang Bewegungsmelder Ost',
'address': imported_csv['BewegungsmelderOst Motion'],
'device_class': 'motion'},
]
}
knx.extent(devices, motion_sensors)
knx.extent(devices, knx.create_lights(lights, imported_csv))
knx.extent(devices, knx.create_shutters(shutters, imported_csv))
knx.extent(devices, knx.create_switches(switches, imported_csv))
@@ -118,6 +163,7 @@ def create_config(target_directory, development=False):
groups_yaml_path = os.path.join(script_path, 'groups.yaml')
manual_config_path = os.path.join(script_path, 'manual_config.yaml')
group_dict = yaml.load(open(groups_yaml_path))
manual_config_dict = yaml.load(open(manual_config_path))
all_devices = {}
add_knx_devices(all_devices, group_dict)
@@ -125,7 +171,11 @@ def create_config(target_directory, development=False):
with open(os.path.join(target_directory, 'configuration.yaml'), 'w') as output:
output.write("# Dont' edit manually! this is generated!\n\n")
output.write(open(manual_config_path, 'r').read())
for key in ['sensor', 'switch', 'light', 'cover']:
if key in manual_config_dict:
all_devices[key].extend(manual_config_dict[key])
del manual_config_dict[key]
yaml.dump(manual_config_dict, output)
yaml.dump(all_devices, output)
add_light_groups(group_dict)