Config: exclude for recorder, history etc

This commit is contained in:
Martin Bauer 2019-10-28 20:15:32 +01:00
parent 6b742948a8
commit 7e60684c69
3 changed files with 71 additions and 9 deletions

View File

@ -1,8 +1,8 @@
# ---------------------------------- Lights ------------------------------------
light:
- name: Schlafzimmer Deckenlampe
dimmer: True
fhem_ids:
@ -41,11 +41,9 @@ light:
fhem_ids:
- Steckdose_Dimmer
# ---------------------------------- Covers ------------------------------------
cover:
- name: Arbeitszimmer Martin Rollo
fhem_ids:
- ArbeitszimmerMartin_Rollo
@ -74,7 +72,8 @@ cover:
- office_rebecca
# ---------------------------------- Switches ------------------------------------
switch:
- name: Bad Lüfter
@ -86,7 +85,7 @@ switch:
- SteckdosenSchalter
# ------------------------------ Motion Sensors ------------------------------------
binary_sensor:
- name: Arbeitszimmer Martin Bewegungsmelder Batterie

View File

@ -1,6 +1,6 @@
import os
import argparse
from util import DeviceInfo, add_to_group
from util import DeviceInfo, add_to_group, name_to_id
from ruamel.yaml import YAML
import knx_conf as knx
@ -9,6 +9,18 @@ yaml = YAML()
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):
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')))
@ -160,6 +172,55 @@ def add_light_groups(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):
groups_yaml_path = os.path.join(script_path, 'groups.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]
yaml.dump(manual_config_dict, 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)
with open(os.path.join(target_directory, 'groups.yaml'), 'w') as output:

View File

@ -55,7 +55,6 @@ homekit:
- scene
recorder:
history:
ios:
shopping_list: