@@ -22,6 +22,8 @@ export interface MqttConfig {
22
22
distinctFields : Array < string > ;
23
23
prefix : string ;
24
24
url : string ;
25
+ last_reset ?: string ;
26
+ last_reset_solar ?: string ;
25
27
}
26
28
27
29
const defaultMqttConfig : Partial < MqttConfig > = {
@@ -35,13 +37,15 @@ const defaultMqttConfig: Partial<MqttConfig> = {
35
37
export interface SunspecConfig {
36
38
host : string ;
37
39
port : number ;
40
+ interval ?: number ;
38
41
}
39
42
40
43
export interface OutputConfig {
41
44
debug : boolean ;
42
45
influx ?: InfluxOutputOptions ;
43
46
jsonSocket ?: number ;
44
47
mqtt ?: MqttConfig ;
48
+ mqttSocket ?: number ;
45
49
post ?: HttpPostConfig ;
46
50
rawSocket ?: number ;
47
51
webserver ?: number ;
@@ -120,20 +124,28 @@ export class ConfigLoader {
120
124
. describe ( 'mqtt-discovery' , 'Emit auto-discovery message' )
121
125
. boolean ( 'mqtt-discovery' )
122
126
. describe ( 'mqtt-discovery-prefix' , 'Autodiscovery prefix' )
127
+ . describe ( 'mqtt-last-reset' , 'If set, this value is added to mqtt as \'last_reset\'' )
128
+ . string ( 'mqtt-last-reset' )
129
+ . describe ( 'mqtt-last-reset-solar' , 'If set, this value is added to mqtt as \'last_reset\'' )
130
+ . string ( 'mqtt-last-reset-solar' )
123
131
. describe ( 'influx-url' , 'Influxdb server url' )
124
132
. describe ( 'influx-token' , 'Influxdb server token' )
125
133
. describe ( 'influx-bucket' , 'Influx bucket' )
126
134
. describe ( 'influx-org' , 'Influx organization' )
127
135
. describe ( 'tcp-server' , 'Expose JSON TCP socket on this port' )
136
+ . describe ( 'tcp-server-mqtt' , 'Expose JSON TCP socket on this port' )
128
137
. describe ( 'raw-tcp-server' , 'Expose RAW TCP socket on this port' )
129
138
. conflicts ( 'port' , 'socket' )
130
139
. describe ( 'debug' , 'Enable debug output' )
131
140
. boolean ( 'debug' )
132
141
. describe ( 'sunspec-modbus' , 'IP of solar inverter with modbus TCP enabled' )
133
142
. describe ( 'sunspec-modbus-port' , 'modbus TCP port' )
143
+ . describe ( 'sunspec-interval' , 'Interval for solar reading' )
134
144
. number ( 'sunspec-modbus-port' )
145
+ . number ( 'sunspec-modbus-interval' )
135
146
. number ( 'web-server' )
136
147
. number ( 'tcp-server' )
148
+ . number ( 'tcp-server-mqtt' )
137
149
. number ( 'raw-tcp-server' )
138
150
. number ( 'post-interval' )
139
151
. describe ( 'enc-aad' , 'Additional authentication data, if your meter encrypts data (eg. Luxemburg)' )
@@ -167,6 +179,10 @@ export class ConfigLoader {
167
179
config . outputs . jsonSocket = args [ 'tcp-server' ] ;
168
180
}
169
181
182
+ if ( args [ 'tcp-server-mqtt' ] ) {
183
+ config . outputs . mqttSocket = args [ 'tcp-server-mqtt' ] ;
184
+ }
185
+
170
186
if ( typeof args [ 'mqtt-url' ] === 'string' ) {
171
187
config . outputs . mqtt = {
172
188
discovery : args [ 'mqtt-discovery' ] === true ,
@@ -175,6 +191,8 @@ export class ConfigLoader {
175
191
distinctFields : args [ 'mqtt-distinct-fields' ] ?. split ( ',' ) ?? defaultMqttConfig . distinctFields ?? [ ] ,
176
192
prefix : args [ 'mqtt-topic' ] ?? 'smartmeter' ,
177
193
url : args [ 'mqtt-url' ] ,
194
+ last_reset : args [ 'mqtt-last-reset' ] ,
195
+ last_reset_solar : args [ 'mqtt-last-reset-solar' ] ,
178
196
} ;
179
197
}
180
198
@@ -208,6 +226,7 @@ export class ConfigLoader {
208
226
config . solar = {
209
227
host : args [ 'sunspec-modbus' ] ,
210
228
port : args [ 'sunspec-modbus-port' ] ,
229
+ interval : args [ 'sunspec-interval' ] ,
211
230
} as SunspecConfig ;
212
231
}
213
232
0 commit comments