Config update

This commit is contained in:
Martin Bauer
2019-06-11 19:28:39 +02:00
parent 4f3c9abd0d
commit fab83c86f4
9 changed files with 157 additions and 297 deletions

View File

@@ -46,10 +46,10 @@ def add_knx_devices(devices, groups):
]
scene_button_names = ['ObenLinks', 'ObenRechts', 'MitteLinks', 'MitteRechts', 'UntenLinks', 'UntenRechts']
scene_button_names = [(i, e) for i, e in enumerate(scene_button_names)]
switches += [DeviceInfo(f"SzeneEsszimmer{n}", "Esszimmer Szene {i}") for i, n in scene_button_names]
switches += [DeviceInfo(f"SzeneWohnzimmer{n}", "Wohnzimmer Szene {i}") for i, n in scene_button_names]
switches += [DeviceInfo(f"SzeneEingang{n}", "Eingang Szene {i}") for i, n in scene_button_names[2:]]
switches += [DeviceInfo(f"SzeneTerrassentuer{n}", "Wohnzimmer Terrassentür Szene {i}")
switches += [DeviceInfo(f"SzeneEsszimmer{n}", f"Esszimmer Szene {i}") for i, n in scene_button_names]
switches += [DeviceInfo(f"SzeneWohnzimmer{n}", f"Wohnzimmer Szene {i}") for i, n in scene_button_names]
switches += [DeviceInfo(f"SzeneEingang{n}", f"Eingang Szene {i}") for i, n in scene_button_names[2:]]
switches += [DeviceInfo(f"SzeneTerrassentuer{n}", f"Wohnzimmer Terrassentür Szene {i}")
for i, n in scene_button_names[2: 4]]
power_plugs = [
@@ -82,8 +82,9 @@ def add_knx_devices(devices, groups):
knx.extent(devices, knx.create_switches(switches, imported_csv))
knx.extent(devices, knx.create_power_plug(power_plugs, imported_csv))
for device in lights + shutters + switches + power_plugs:
add_to_group(groups, device.groups, device.display_name)
for device_type, devices in [('light', lights), ('cover', shutters), ('switch', switches)]:
for device in devices:
add_to_group(groups, device.groups, device.display_name, device_type)
def add_fhem_devices(devices, groups):
@@ -94,7 +95,7 @@ def add_fhem_devices(devices, groups):
for device in device_list:
device['platform'] = 'fhem'
if 'groups' in device:
add_to_group(groups, device['groups'], device['name'])
add_to_group(groups, device['groups'], device['name'], device_type)
del device['groups']
devices[device_type].append(device)
@@ -109,7 +110,7 @@ def main():
with open('output/configuration.yaml', 'w') as output:
output.write(open('manual_config.yaml', 'r').read())
yaml.dump(all_devices, output)
yaml.dump(group_dict, open('output/groups.yaml', 'a'))
yaml.dump(group_dict, open('output/groups.yaml', 'w'))
if __name__ == '__main__':

View File

@@ -14,6 +14,11 @@ homeassistant:
latitude: 49.369477
longitude: 10.9831468
customize_glob:
cover.*:
half_position: 25
# Sensors
#sensor:
# Weather prediction

View File

@@ -0,0 +1,103 @@
resources:
- type: js
url: /local/custom_ui/state-card-custom-cover.js
title: Home
views:
- cards:
- entities:
- light.wohnzimmer_deckenlampe
- light.wohnzimmer_kugel
image: /local/living_room.jpg
title: Wohnzimmer
type: picture-glance
- entities:
- entity: light.kuche_deckenlampe
name: Decke Küche
- entity: light.esszimmer_deckenlampe_mitte
name: Decke Esszimmer Mitte
- entity: light.esszimmer_deckenlampe_west
name: Decke Esszimmer
- type: divider
- entity: light.kuche_links
name: Küche LED links
- entity: light.kuche_rechts
name: Küche LED rechts
- entity: light.kuche_vorne
name: Küche LED vorne
- type: divider
- entity: cover.kuche_fenster_rollo
name: Küche
type: 'custom:state-card-custom-cover'
- entity: cover.esszimmer_fenster_rollo
name: Esszimmer
type: 'custom:state-card-custom-cover'
show_header_toggle: true
title: Küche/Esszimmer
type: entities
- entities:
- entity: light.wohnzimmer_deckenlampe
name: Decke
- type: divider
- entity: light.wohnzimmer_kugel
name: Kugel
- entity: light.wohnzimmer_regal_links
name: Regal links
- entity: light.wohnzimmer_regal_rechts
name: Regal rechts
- type: divider
- entity: light.wohnzimmer_stehlampe_oben
name: Stehlampe oben
- entity: light.wohnzimmer_stehlampe
name: Stehlampe unten
- type: divider
- entity: cover.wohnzimmer_fenster_rollo
name: Fenster
type: 'custom:state-card-custom-cover'
- entity: cover.wohnzimmer_terrassentur_rollo
name: Tür
type: 'custom:state-card-custom-cover'
show_header_toggle: true
title: Wohnzimmer
type: entities
- entities:
- entity: light.gang_licht
name: Licht
- entity: light.gang_bogen
name: Bogen
show_header_toggle: true
title: Gang
type: entities
title: Wohnbereich
- badges:
- sensor.fritz_box_7490_kbyte_sec_received
- sensor.fritz_box_7490_kbyte_sec_sent
cards:
- entities:
- entity: sensor.trockner_verbrauch
name: Trockner aktuell
- entity: sensor.trockner_verbrauch_summe
name: Trockner insgesamt
- entity: sensor.trockner_betriebsstunden
name: Trockner Stunden
- type: divider
- entity: sensor.waschmaschine_verbrauch
name: Waschmaschine aktuell
- entity: sensor.waschmaschine_verbrauch_summe
name: Waschmaschine insgesamt
- entity: sensor.waschmaschine_betriebsstunden
name: Waschmaschine Stunden
show_header_toggle: false
title: Verbrauch
type: entities
- entities:
- switch.trockner
- switch.waschmaschine
- switch.spulmaschine
- switch.backofen
- switch.herd_phase_1
- switch.herd_phase_2
- switch.herd_phase_3
show_header_toggle: false
title: Sicherheitsabschaltung
type: entities
title: Admin

View File

@@ -19,14 +19,14 @@ def extent(result_dict, input_dict, platform):
result_dict[k] += v
def name_to_id(name):
return slugify.slugify(name, separator='_')
def name_to_id(name, device_type):
return "{}.{}".format(device_type, slugify.slugify(name, separator='_'))
def add_to_group(groups_dict, device_groups, device_name):
def add_to_group(groups_dict, device_groups, device_name, device_type):
for group in device_groups:
if group not in groups_dict:
raise ValueError(f"FHEM device {device_name} wants to be added to unknown group {group}")
if 'entities' not in groups_dict[group]:
groups_dict[group]['entities'] = []
groups_dict[group]['entities'].append(name_to_id(device_name))
groups_dict[group]['entities'].append(name_to_id(device_name, device_type))