Used secrets file to distinguish development vs. deployment

This commit is contained in:
Martin Bauer
2019-06-30 22:15:52 +02:00
parent 28e3b77c15
commit 383973c255
10 changed files with 28 additions and 11 deletions

View File

@@ -1,4 +1,5 @@
import os
import argparse
from util import DeviceInfo, add_to_group
from ruamel.yaml import YAML
import knx_conf as knx
@@ -113,7 +114,7 @@ def add_light_groups(groups):
groups.update(light_groups)
def create_config(target_directory):
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))
@@ -132,6 +133,16 @@ def create_config(target_directory):
output.write("# Dont' edit manually! this is generated!\n\n")
yaml.dump(group_dict, output)
with open(os.path.join(target_directory, 'secrets.yaml'), 'w') as output:
output.write("# Dont' edit manually! this is generated!\n\n")
output.write(open(os.path.join(script_path, 'secrets.yaml'), 'r').read())
output.write("\n\n")
additional_file = 'secrets_development.yaml' if development else 'secrets_deploy.yaml'
output.write(open(os.path.join(script_path, additional_file), 'r').read())
if __name__ == '__main__':
create_config(target_directory=os.getcwd())
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--dev", help="create config file for development", action="store_true")
args = parser.parse_args()
create_config(target_directory=os.getcwd(), development=args.dev)

View File

@@ -54,19 +54,20 @@ cover_half:
tts:
- platform: watson_tts
watson_apikey: X_tnnoaZGOwxZlqUn07wkD2G-0vaaAuOw6I6d_6jpCf7
watson_apikey: !secret watson_api_key
watson_url: https://gateway-lon.watsonplatform.net/text-to-speech/api
voice: de-DE_BirgitVoice
output_format: audio/flac
output_audio_rate: 44100
knx:
rate_limit: 20
tunneling:
host: server # knxd to work together with old home automation server
#host: 192.168.178.65 # network bridge
host: !secret knxd_host
port: 3671
local_ip: 192.168.178.76
local_ip: !secret local_ip
fhem:
host: server
@@ -91,7 +92,7 @@ media_player:
vacuum:
- platform: xiaomi_miio
host: rockrobo
token: 515a69497537766d4f7a38756b4b654d
token: !secret local_ip
group: !include groups.yaml

View File

@@ -0,0 +1,3 @@
vacuum_token: 515a69497537766d4f7a38756b4b654d
watson_api_key: X_tnnoaZGOwxZlqUn07wkD2G-0vaaAuOw6I6d_6jpCf7
knxd_host: server #directly the network bridge: 192.168.178.65

View File

@@ -0,0 +1 @@
local_ip: 192.168.178.80

View File

@@ -0,0 +1 @@
local_ip: 192.168.178.76