Config: exclude for recorder, history etc
This commit is contained in:
parent
6b742948a8
commit
7e60684c69
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
# ---------------------------------- Lights ------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
light:
|
light:
|
||||||
|
|
||||||
- name: Schlafzimmer Deckenlampe
|
- name: Schlafzimmer Deckenlampe
|
||||||
dimmer: True
|
dimmer: True
|
||||||
fhem_ids:
|
fhem_ids:
|
||||||
|
@ -41,11 +41,9 @@ light:
|
||||||
fhem_ids:
|
fhem_ids:
|
||||||
- Steckdose_Dimmer
|
- Steckdose_Dimmer
|
||||||
|
|
||||||
# ---------------------------------- Covers ------------------------------------
|
|
||||||
|
|
||||||
cover:
|
cover:
|
||||||
|
|
||||||
|
|
||||||
- name: Arbeitszimmer Martin Rollo
|
- name: Arbeitszimmer Martin Rollo
|
||||||
fhem_ids:
|
fhem_ids:
|
||||||
- ArbeitszimmerMartin_Rollo
|
- ArbeitszimmerMartin_Rollo
|
||||||
|
@ -74,7 +72,8 @@ cover:
|
||||||
- office_rebecca
|
- office_rebecca
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------- Switches ------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- name: Bad Lüfter
|
- name: Bad Lüfter
|
||||||
|
@ -86,7 +85,7 @@ switch:
|
||||||
- SteckdosenSchalter
|
- SteckdosenSchalter
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------ Motion Sensors ------------------------------------
|
|
||||||
|
|
||||||
binary_sensor:
|
binary_sensor:
|
||||||
- name: Arbeitszimmer Martin Bewegungsmelder Batterie
|
- name: Arbeitszimmer Martin Bewegungsmelder Batterie
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
from util import DeviceInfo, add_to_group
|
from util import DeviceInfo, add_to_group, name_to_id
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
import knx_conf as knx
|
import knx_conf as knx
|
||||||
|
|
||||||
|
@ -9,6 +9,18 @@ yaml = YAML()
|
||||||
yaml.preserve_quotes = True
|
yaml.preserve_quotes = True
|
||||||
|
|
||||||
|
|
||||||
|
fritz_box_counter_sensors = [
|
||||||
|
'sensor.fritz_box_7490_bytes_received',
|
||||||
|
'sensor.fritz_box_7490_bytes_sent',
|
||||||
|
#'sensor.fritz_box_7490_kbyte_sec_received',
|
||||||
|
#'sensor.fritz_box_7490_kbyte_sec_sent',
|
||||||
|
'sensor.fritz_box_7490_packets_received',
|
||||||
|
'sensor.fritz_box_7490_packets_sec_received',
|
||||||
|
'sensor.fritz_box_7490_packets_sec_sent',
|
||||||
|
'sensor.fritz_box_7490_packets_sent',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def add_knx_devices(devices, groups):
|
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 = 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')))
|
imported_csv.update(knx.import_ets5_csv_file(os.path.join(script_path, 'knx_data/export_project2.csv')))
|
||||||
|
@ -160,6 +172,55 @@ def add_light_groups(groups):
|
||||||
groups.update(light_groups)
|
groups.update(light_groups)
|
||||||
|
|
||||||
|
|
||||||
|
def make_sensor_exclude_list(all_devices, name_fragments):
|
||||||
|
exclude_list = []
|
||||||
|
|
||||||
|
def handle_sensor(s):
|
||||||
|
name = s['name'] if 'name' in s else s['friendly_name']
|
||||||
|
if any(t in name for t in name_fragments):
|
||||||
|
exclude_list.append(name_to_id(name, 'sensor'))
|
||||||
|
|
||||||
|
for sensor_device in all_devices['sensor']:
|
||||||
|
if 'platform' in sensor_device and sensor_device['platform'] == 'template':
|
||||||
|
for nested_sensor_dev in sensor_device['sensors'].values():
|
||||||
|
handle_sensor(nested_sensor_dev)
|
||||||
|
elif 'name' in sensor_device:
|
||||||
|
handle_sensor(sensor_device)
|
||||||
|
else:
|
||||||
|
raise NotImplementedError()
|
||||||
|
return exclude_list
|
||||||
|
|
||||||
|
|
||||||
|
def logbook_config(all_devices):
|
||||||
|
sensor_excludes = ['Helligkeit', 'Betriebsstunden', 'Verbrauch', 'Bewegungsmelder']
|
||||||
|
|
||||||
|
exclude_list = []
|
||||||
|
exclude_list.extend(fritz_box_counter_sensors)
|
||||||
|
exclude_list.extend(make_sensor_exclude_list(all_devices, sensor_excludes))
|
||||||
|
return {
|
||||||
|
'logbook': {
|
||||||
|
'exclude': {
|
||||||
|
'entities': exclude_list,
|
||||||
|
'domains': ['group']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def recorder_config(all_devices):
|
||||||
|
recorder_excludes = ['Betriebsstunden', 'Verbrauch mA']
|
||||||
|
exclude_list = ['sun.sun']
|
||||||
|
exclude_list.extend(fritz_box_counter_sensors)
|
||||||
|
exclude_list.extend(make_sensor_exclude_list(all_devices, recorder_excludes))
|
||||||
|
return {
|
||||||
|
'recorder': {
|
||||||
|
'exclude': {
|
||||||
|
'entities': exclude_list,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def create_config(target_directory, development=False):
|
def create_config(target_directory, development=False):
|
||||||
groups_yaml_path = os.path.join(script_path, 'groups.yaml')
|
groups_yaml_path = os.path.join(script_path, 'groups.yaml')
|
||||||
manual_config_path = os.path.join(script_path, 'manual_config.yaml')
|
manual_config_path = os.path.join(script_path, 'manual_config.yaml')
|
||||||
|
@ -178,6 +239,9 @@ def create_config(target_directory, development=False):
|
||||||
del manual_config_dict[key]
|
del manual_config_dict[key]
|
||||||
yaml.dump(manual_config_dict, output)
|
yaml.dump(manual_config_dict, output)
|
||||||
yaml.dump(all_devices, output)
|
yaml.dump(all_devices, output)
|
||||||
|
yaml.dump(logbook_config(all_devices), output)
|
||||||
|
yaml.dump(recorder_config(all_devices), output)
|
||||||
|
|
||||||
add_light_groups(group_dict)
|
add_light_groups(group_dict)
|
||||||
|
|
||||||
with open(os.path.join(target_directory, 'groups.yaml'), 'w') as output:
|
with open(os.path.join(target_directory, 'groups.yaml'), 'w') as output:
|
||||||
|
|
|
@ -55,7 +55,6 @@ homekit:
|
||||||
- scene
|
- scene
|
||||||
|
|
||||||
|
|
||||||
recorder:
|
|
||||||
history:
|
history:
|
||||||
ios:
|
ios:
|
||||||
shopping_list:
|
shopping_list:
|
||||||
|
|
Loading…
Reference in New Issue