mirror of
				https://gitlab.alpinelinux.org/alpine/aports.git
				synced 2025-10-31 16:31:40 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			65 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			65 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| Patch-Source: https://github.com/Koenkk/zigbee2mqtt/pull/15005
 | |
| --
 | |
| From d16acf602d7b8e4134df64d07f8fe046381e452f Mon Sep 17 00:00:00 2001
 | |
| From: Jakub Jirutka <jakub@jirutka.cz>
 | |
| Date: Tue, 15 Nov 2022 20:04:52 +0100
 | |
| Subject: [PATCH] Allow to read advanced.pan_id from a different file
 | |
| 
 | |
| The goal is to allow moving all GENERATEable settings to a separate file.
 | |
| ---
 | |
|  lib/util/settings.ts  | 5 +++++
 | |
|  test/settings.test.js | 3 +++
 | |
|  2 files changed, 8 insertions(+)
 | |
| 
 | |
| diff --git a/lib/util/settings.ts b/lib/util/settings.ts
 | |
| index aabbf5af1..c7933bd66 100644
 | |
| --- a/lib/util/settings.ts
 | |
| +++ b/lib/util/settings.ts
 | |
| @@ -214,6 +214,7 @@ function write(): void {
 | |
|          ['mqtt', 'user'],
 | |
|          ['mqtt', 'password'],
 | |
|          ['advanced', 'network_key'],
 | |
| +        ['advanced', 'pan_id'],
 | |
|          ['frontend', 'auth_token'],
 | |
|      ]) {
 | |
|          if (actual[path[0]] && actual[path[0]][path[1]]) {
 | |
| @@ -352,6 +353,10 @@ function read(): Settings {
 | |
|          s.advanced.network_key = interpetValue(s.advanced.network_key);
 | |
|      }
 | |
|  
 | |
| +    if (s.advanced?.pan_id) {
 | |
| +        s.advanced.pan_id = interpetValue(s.advanced.pan_id);
 | |
| +    }
 | |
| +
 | |
|      if (s.frontend?.auth_token) {
 | |
|          s.frontend.auth_token = interpetValue(s.frontend.auth_token);
 | |
|      }
 | |
| diff --git a/test/settings.test.js b/test/settings.test.js
 | |
| index 68a05e1f0..6d558b191 100644
 | |
| --- a/test/settings.test.js
 | |
| +++ b/test/settings.test.js
 | |
| @@ -203,6 +203,7 @@ describe('Settings', () => {
 | |
|              },
 | |
|              advanced: {
 | |
|                  network_key: '!secret network_key',
 | |
| +                pan_id: '!secret.yaml pan_id',
 | |
|              }
 | |
|          };
 | |
|  
 | |
| @@ -211,6 +212,7 @@ describe('Settings', () => {
 | |
|              username: 'mysecretusername',
 | |
|              password: 'mysecretpassword',
 | |
|              network_key: [1,2,3],
 | |
| +            pan_id: 0x1a66,
 | |
|          };
 | |
|  
 | |
|          write(secretFile, contentSecret, false);
 | |
| @@ -227,6 +229,7 @@ describe('Settings', () => {
 | |
|  
 | |
|          expect(settings.get().mqtt).toStrictEqual(expected);
 | |
|          expect(settings.get().advanced.network_key).toStrictEqual([1,2,3]);
 | |
| +        expect(settings.get().advanced.pan_id).toStrictEqual(0x1a66);
 | |
|  
 | |
|          settings.testing.write();
 | |
|          expect(read(configurationFile)).toStrictEqual(contentConfiguration);
 |