forked from jgyates/genmon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genserv.py
2102 lines (1850 loc) · 107 KB
/
genserv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#-------------------------------------------------------------------------------
# FILE: genserv.py
# PURPOSE: Flask app for generator monitor web app
#
# AUTHOR: Jason G Yates
# DATE: 20-Dec-2016
#
# MODIFICATIONS:
#-------------------------------------------------------------------------------
from __future__ import print_function
import sys, signal, os, socket, atexit, time, subprocess, json, threading, signal, errno, collections, getopt
try:
from flask import Flask, render_template, request, jsonify, session, send_file, redirect, url_for
except Exception as e1:
print("\n\nThis program requires the Flask library. Please see the project documentation at https://github.com/jgyates/genmon.\n")
print("Error: " + str(e1))
sys.exit(2)
try:
import pyotp
except Exception as e1:
print("\n\nThis program requires the pyotp library. Please see the project documentation at https://github.com/jgyates/genmon.\n")
print("Error: " + str(e1))
sys.exit(2)
try:
from genmonlib.myclient import ClientInterface
from genmonlib.mylog import SetupLogger
from genmonlib.myconfig import MyConfig
from genmonlib.mymail import MyMail
from genmonlib.mysupport import MySupport
from genmonlib.program_defaults import ProgramDefaults
except Exception as e1:
print("\n\nThis program requires the modules located in the genmonlib directory in the original github repository.\n")
print("Please see the project documentation at https://github.com/jgyates/genmon.\n")
print("Error: " + str(e1))
sys.exit(2)
try:
from urllib.parse import urlparse
from urllib.parse import parse_qs
from urllib.parse import parse_qsl
except ImportError:
from urlparse import urlparse
from urlparse import parse_qs
from urlparse import parse_qsl
import re, datetime
#-------------------------------------------------------------------------------
app = Flask(__name__,static_url_path='')
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 300
HTTPAuthUser = None
HTTPAuthPass = None
HTTPAuthUser_RO = None
HTTPAuthPass_RO = None
LdapServer = None
LdapBase = None
DomainNetbios = None
LdapAdminGroup = None
LdapReadOnlyGroup = None
mail = None
bUseMFA = False
SecretMFAKey = None
MFA_URL = None
bUseSecureHTTP = False
bUseSelfSignedCert = True
SSLContext = None
HTTPPort = 8000
loglocation = ProgramDefaults.LogPath
clientport = ProgramDefaults.ServerPort
log = None
console = None
AppPath = ""
favicon = "favicon.ico"
ConfigFilePath = ProgramDefaults.ConfPath
MAIL_SECTION = "MyMail"
GENMON_SECTION = "GenMon"
Closing = False
Restarting = False
ControllerType = "generac_evo_nexus"
CriticalLock = threading.Lock()
CachedToolTips = {}
CachedRegisterDescriptions = {}
#-------------------------------------------------------------------------------
@app.route('/logout')
def logout():
try:
# remove the session data
if LoginActive():
session['logged_in'] = False
session['write_access'] = False
session['mfa_ok'] = False
return redirect(url_for('root'))
except Exception as e1:
LogError("Error on logout: " + str(e1))
#-------------------------------------------------------------------------------
@app.after_request
def add_header(r):
"""
Force cache header
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, public, max-age=0"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
return r
#-------------------------------------------------------------------------------
@app.route('/', methods=['GET'])
def root():
return ServePage('index.html')
#-------------------------------------------------------------------------------
@app.route('/verbose', methods=['GET'])
def verbose():
return ServePage('index_verbose.html')
#-------------------------------------------------------------------------------
@app.route('/low', methods=['GET'])
def lowbandwidth():
return ServePage('index_lowbandwith.html')
#-------------------------------------------------------------------------------
@app.route('/internal', methods=['GET'])
def display_internal():
return ServePage('internal.html')
#-------------------------------------------------------------------------------
def ServePage(page_file):
if LoginActive():
if not session.get('logged_in'):
return render_template('login.html')
else:
return app.send_static_file(page_file)
else:
return app.send_static_file(page_file)
#-------------------------------------------------------------------------------
@app.route('/mfa', methods=['POST'])
def mfa_auth():
try:
if bUseMFA:
if ValidateOTP(request.form['code']):
session['mfa_ok'] = True
return redirect(url_for('root'))
else:
session['mfa_ok'] = False
return redirect(url_for('logout'))
else:
return redirect(url_for('root'))
except Exception as e1:
LogErrorLine("Error in mfa_auth: " + str(e1))
return render_template('login.html')
#-------------------------------------------------------------------------------
def admin_login_helper():
if bUseMFA:
#GetOTP()
return render_template('mfa.html')
else:
return redirect(url_for('root'))
#-------------------------------------------------------------------------------
@app.route('/', methods=['POST'])
def do_admin_login():
if request.form['password'] == HTTPAuthPass and request.form['username'] == HTTPAuthUser:
session['logged_in'] = True
session['write_access'] = True
LogError("Admin Login")
return admin_login_helper()
elif request.form['password'] == HTTPAuthPass_RO and request.form['username'] == HTTPAuthUser_RO:
session['logged_in'] = True
session['write_access'] = False
LogError("Limited Rights Login")
return admin_login_helper()
elif doLdapLogin(request.form['username'], request.form['password']):
return admin_login_helper()
elif request.form['username'] != "":
LogError("Invalid login: " + request.form['username'])
return render_template('login.html')
else:
return render_template('login.html')
#-------------------------------------------------------------------------------
def doLdapLogin(username, password):
if LdapServer == None or LdapServer == "":
return False
try:
from ldap3 import Server, Connection, ALL, NTLM
except ImportError as importException:
LogError("LDAP3 import not found, run 'sudo pip install ldap3 && sudo pip3 install ldap3'")
LogError(importException)
return False
HasAdmin = False
HasReadOnly = False
try:
SplitName = username.split('\\')
DomainName = SplitName[0]
DomainName = DomainName.strip()
AccountName = SplitName[1]
AccountName = AccountName.strip()
except IndexError:
LogError("Using domain name in config file")
DomainName = DomainNetbios
AccountName = username.strip()
try:
server = Server(LdapServer, get_info=ALL)
conn = Connection(server, user='{}\\{}'.format(DomainName, AccountName), password=password, authentication=NTLM, auto_bind=True)
conn.search(LdapBase, '(&(objectclass=user)(sAMAccountName='+AccountName+'))', attributes=['memberOf'])
for user in sorted(conn.entries):
for group in user.memberOf:
if group.upper().find("CN="+LdapAdminGroup.upper()) >= 0:
HasAdmin = True
elif group.upper().find("CN="+LdapReadOnlyGroup.upper()) >= 0:
HasReadOnly = True
except Exception:
LogError("Error in LDAP login. Check credentials and config parameters")
session['logged_in'] = HasAdmin or HasReadOnly
session['write_access'] = HasAdmin
if HasAdmin:
LogError("Admin Login via LDAP")
elif HasReadOnly:
LogError("Limited Rights Login via LDAP")
else:
LogError("No rights for login via LDAP")
return HasAdmin or HasReadOnly
#-------------------------------------------------------------------------------
@app.route("/cmd/<command>")
def command(command):
if Closing or Restarting:
return jsonify("Closing")
if HTTPAuthUser == None or HTTPAuthPass == None:
return ProcessCommand(command)
if not session.get('logged_in'):
return render_template('login.html')
else:
return ProcessCommand(command)
#-------------------------------------------------------------------------------
def ProcessCommand(command):
try:
#LogError(request.url)
if command in ["status", "status_json", "outage", "outage_json", "maint", "maint_json",
"logs", "logs_json", "monitor", "monitor_json", "registers_json", "allregs_json",
"start_info_json", "gui_status_json", "power_log_json", "power_log_clear",
"getbase", "getsitename","setexercise", "setquiet", "setremote",
"settime", "sendregisters", "sendlogfiles", "getdebug", "status_num_json",
"get_maint_log_json", "add_maint_log", "clear_maint_log", "delete_row_maint_log",
"edit_row_maint_log", "support_data_json", 'fuel_log_clear' ]:
finalcommand = "generator: " + command
try:
if command in ["setexercise", "setquiet", "setremote", "add_maint_log", "delete_row_maint_log", "edit_row_maint_log"] and not session.get('write_access', True):
return jsonify("Read Only Mode")
if command == "setexercise":
settimestr = request.args.get('setexercise', 0, type=str)
if settimestr:
finalcommand += "=" + settimestr
elif command == "setquiet":
# /cmd/setquiet?setquiet=off
setquietstr = request.args.get('setquiet', 0, type=str)
if setquietstr:
finalcommand += "=" + setquietstr
elif command == "setremote":
setremotestr = request.args.get('setremote', 0, type=str)
if setremotestr:
finalcommand += "=" + setremotestr
if command == "power_log_json":
# example: /cmd/power_log_json?power_log_json=1440
setlogstr = request.args.get('power_log_json', 0, type=str)
if setlogstr:
finalcommand += "=" + setlogstr
if command == "add_maint_log":
# use direct method instead of request.args.get due to unicoode
# input for add_maint_log for international users
input = request.args['add_maint_log']
finalcommand += "=" + input
if command == "delete_row_maint_log":
# use direct method instead of request.args.get due to unicoode
# input for add_maint_log for international users
input = request.args['delete_row_maint_log']
finalcommand += "=" + input
if command == "edit_row_maint_log":
# use direct method instead of request.args.get due to unicoode
# input for add_maint_log for international users
input = request.args['edit_row_maint_log']
finalcommand += "=" + input
data = MyClientInterface.ProcessMonitorCommand(finalcommand)
except Exception as e1:
data = "Retry"
LogError("Error on command function: " + str(e1))
if command in ["status_json", "outage_json", "maint_json", "monitor_json", "logs_json",
"registers_json", "allregs_json", "start_info_json", "gui_status_json", "power_log_json",
"status_num_json", "get_maint_log_json", "support_data_json"]:
if command in ["start_info_json"]:
try:
StartInfo = json.loads(data)
StartInfo["write_access"] = session.get('write_access', True)
if not StartInfo["write_access"]:
StartInfo["pages"]["settings"] = False
StartInfo["pages"]["notifications"] = False
StartInfo["LoginActive"] = LoginActive()
data = json.dumps(StartInfo, sort_keys=False)
except Exception as e1:
LogErrorLine("Error in JSON parse / decode: " + str(e1))
return data
return jsonify(data)
elif command in ["updatesoftware"]:
if session.get('write_access', True):
Update()
return "OK"
else:
return "Access denied"
elif command in ["getfavicon"]:
return jsonify(favicon)
elif command in ["settings"]:
if session.get('write_access', True):
data = ReadSettingsFromFile()
return json.dumps(data, sort_keys = False)
else:
return "Access denied"
elif command in ["notifications"]:
data = ReadNotificationsFromFile()
return jsonify(data)
elif command in ["setnotifications"]:
if session.get('write_access', True):
SaveNotifications(request.args.get('setnotifications', 0, type=str))
return "OK"
# Add on items
elif command in ["get_add_on_settings", "set_add_on_settings"]:
if session.get('write_access', True):
if command == "get_add_on_settings":
data = GetAddOnSettings()
return json.dumps(data, sort_keys = False)
elif command == "set_add_on_settings":
SaveAddOnSettings(request.args.get('set_add_on_settings', default = None, type=str))
else:
return "OK"
return "OK"
elif command in ["get_advanced_settings", "set_advanced_settings"]:
if session.get('write_access', True):
if command == "get_advanced_settings":
data = ReadAdvancedSettingsFromFile()
return json.dumps(data, sort_keys = False)
elif command == "set_advanced_settings":
SaveAdvancedSettings(request.args.get('set_advanced_settings', default = None, type=str))
else:
return "OK"
return "OK"
elif command in ["setsettings"]:
if session.get('write_access', True):
SaveSettings(request.args.get('setsettings', 0, type=str))
return "OK"
elif command in ["getreglabels"]:
return jsonify(CachedRegisterDescriptions)
elif command in ["restart"]:
if session.get('write_access', True):
Restart()
elif command in ["stop"]:
if session.get('write_access', True):
Close()
sys.exit(0)
elif command in ["shutdown"]:
if session.get('write_access', True):
Shutdown()
sys.exit(0)
elif command in ["backup"]:
if session.get('write_access', True):
Backup() # Create backup file
# Now send the file
pathtofile = os.path.dirname(os.path.realpath(__file__))
return send_file(os.path.join(pathtofile, "genmon_backup.tar.gz"), as_attachment=True)
elif command in ["get_logs"]:
if session.get('write_access', True):
GetLogs() # Create log archive file
# Now send the file
pathtofile = os.path.dirname(os.path.realpath(__file__))
return send_file(os.path.join(pathtofile, "genmon_logs.tar.gz"), as_attachment=True)
elif command in ["test_email"]:
return SendTestEmail(request.args.get('test_email', default = None, type=str))
else:
return render_template('command_template.html', command = command)
except Exception as e1:
LogErrorLine("Error in Process Command: " + command + ": " + str(e1))
return render_template('command_template.html', command = command)
#-------------------------------------------------------------------------------
def LoginActive():
if HTTPAuthUser != None and HTTPAuthPass != None or LdapServer != None:
return True
return False
#-------------------------------------------------------------------------------
def SendTestEmail(query_string):
try:
if query_string == None or not len(query_string):
return "No parameters given for email test."
parameters = json.loads(query_string)
if not len(parameters):
return "No parameters" # nothing to change
except:
LogErrorLine("Error getting parameters in SendTestEmail: " + str(e1))
return "Error getting parameters in email test: " + str(e1)
try:
smtp_server = str(parameters['smtp_server'])
smtp_server = smtp_server.strip()
smtp_port = int(parameters['smtp_port'])
email_account = str(parameters['email_account'])
email_account = email_account.strip()
sender_account = str(parameters['sender_account'])
sender_account = sender_account.strip()
if not len(sender_account):
sender_account == None
sender_name = str(parameters['sender_name'])
sender_name = sender_name.strip()
if not len(sender_name):
sender_name == None
recipient = str(parameters['recipient'])
recipient = recipient.strip()
password = str(parameters['password'])
if parameters['use_ssl'].lower() == 'true':
use_ssl = True
else:
use_ssl = False
if parameters['tls_disable'].lower() == 'true':
tls_disable = True
else:
tls_disable = False
if parameters['smtpauth_disable'].lower() == 'true':
smtpauth_disable = True
else:
smtpauth_disable = False
except Exception as e1:
LogErrorLine("Error parsing parameters in SendTestEmail: " + str(e1))
LogError(str(parameters))
return "Error parsing parameters in email test: " + str(e1)
try:
ReturnMessage = MyMail.TestSendSettings(
smtp_server = smtp_server,
smtp_port = smtp_port,
email_account = email_account,
sender_account = sender_account,
sender_name = sender_name,
recipient = recipient,
password = password,
use_ssl = use_ssl,
tls_disable = tls_disable,
smtpauth_disable = smtpauth_disable
)
return ReturnMessage
except Exception as e1:
LogErrorLine("Error sending test email : " + str(e1))
return "Error sending test email : " + str(e1)
#-------------------------------------------------------------------------------
def GetAddOns():
AddOnCfg = collections.OrderedDict()
# Default icon name should be "Genmon" to get a generic icon
try:
# GENGPIO
Temp = collections.OrderedDict()
AddOnCfg['gengpio'] = collections.OrderedDict()
AddOnCfg['gengpio']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gengpio", default = False)
AddOnCfg['gengpio']['title'] = "Genmon GPIO Outputs"
AddOnCfg['gengpio']['description'] = "Genmon will set Raspberry Pi GPIO outputs (see documentation for details)"
AddOnCfg['gengpio']['icon'] = "rpi"
AddOnCfg['gengpio']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gengpiopy-optional"
AddOnCfg['gengpio']['parameters'] = None
# GENGPIOIN
AddOnCfg['gengpioin'] = collections.OrderedDict()
AddOnCfg['gengpioin']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gengpioin", default = False)
AddOnCfg['gengpioin']['title'] = "Genmon GPIO Inputs"
AddOnCfg['gengpioin']['description'] = "Genmon will set Raspberry Pi GPIO inputs (see documentation for details)"
AddOnCfg['gengpioin']['icon'] = "rpi"
AddOnCfg['gengpioin']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gengpioinpy-optional"
AddOnCfg['gengpioin']['parameters'] = collections.OrderedDict()
AddOnCfg['gengpioin']['parameters']['trigger'] = CreateAddOnParam(
ConfigFiles[GENGPIOIN_CONFIG].ReadValue("trigger", return_type = str, default = "falling"),
'list',
"Set GPIO input to trigger on rising or falling edge.",
bounds = 'falling,rising,both',
display_name = "GPIO Edge Trigger")
AddOnCfg['gengpioin']['parameters']['resistorpull'] = CreateAddOnParam(
ConfigFiles[GENGPIOIN_CONFIG].ReadValue("resistorpull", return_type = str, default = "up"),
'list',
"Set GPIO input internal pull up or pull down resistor.",
bounds = 'up,down,off',
display_name = "Internal resistor pull")
AddOnCfg['gengpioin']['parameters']['bounce'] = CreateAddOnParam(
ConfigFiles[GENGPIOIN_CONFIG].ReadValue("bounce", return_type = int, default = 0),
'int',
"Minimum interval in milliseconds between valid input channges. Zero to disable, or positive whole number.",
bounds = 'number',
display_name = "Software Debounce")
#GENGPIOLEDBLINK
AddOnCfg['gengpioledblink'] = collections.OrderedDict()
AddOnCfg['gengpioledblink']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gengpioledblink", default = False)
AddOnCfg['gengpioledblink']['title'] = "Genmon GPIO Output to blink LED"
AddOnCfg['gengpioledblink']['description'] = "Genmon will blink LED connected to GPIO pin to indicate genmon status"
AddOnCfg['gengpioledblink']['icon'] = "rpi"
AddOnCfg['gengpioledblink']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gengpioledblinkpy-optional"
AddOnCfg['gengpioledblink']['parameters'] = collections.OrderedDict()
AddOnCfg['gengpioledblink']['parameters']['ledpin'] = CreateAddOnParam(
ConfigFiles[GENGPIOLEDBLINK_CONFIG].ReadValue("ledpin", return_type = int, default = 12),
'int',
"GPIO pin number that an LED is connected (valid numbers are 0 - 27)",
bounds = "required digits range:0:27",
display_name = "GPIO LED pin")
#GENLOG
AddOnCfg['genlog'] = collections.OrderedDict()
AddOnCfg['genlog']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "genlog", default = False)
AddOnCfg['genlog']['title'] = "Notifications to CSV Log"
AddOnCfg['genlog']['description'] = "Log Genmon and utility state changes to a file. Log file is in text CSV format."
AddOnCfg['genlog']['icon'] = "csv"
AddOnCfg['genlog']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#genlogpy-optional"
AddOnCfg['genlog']['parameters'] = collections.OrderedDict()
Args = ConfigFiles[GENLOADER_CONFIG].ReadValue("args", return_type = str, section = "genlog", default = '-f /home/pi/genmon/LogFile.csv')
ArgList = Args.split()
if len(ArgList) == 2:
Value = ArgList[1]
else:
Value = ""
AddOnCfg['genlog']['parameters']['Log File Name'] = CreateAddOnParam(
Value,
'string',
'Filename for log. Full path of the file must be included (i.e. /home/pi/genmon/LogFile.csv)',
bounds = "required UnixFile",
display_name = "Log File Name" )
#GENSMS
AddOnCfg['gensms'] = collections.OrderedDict()
AddOnCfg['gensms']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gensms", default = False)
AddOnCfg['gensms']['title'] = "Notifications via SMS - Twilio"
AddOnCfg['gensms']['description'] = "Send Genmon and utility state changes via Twilio SMS"
AddOnCfg['gensms']['icon'] = "twilio"
AddOnCfg['gensms']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gensmspy-optional"
AddOnCfg['gensms']['parameters'] = collections.OrderedDict()
AddOnCfg['gensms']['parameters']['accountsid'] = CreateAddOnParam(
ConfigFiles[GENSMS_CONFIG].ReadValue("accountsid", return_type = str, default = ""),
'string',
"Twilio account SID. This can be obtained from a valid Twilio account",
bounds = 'required minmax:10:50',
display_name = "Twilio Account SID")
AddOnCfg['gensms']['parameters']['authtoken'] = CreateAddOnParam(
ConfigFiles[GENSMS_CONFIG].ReadValue("authtoken", return_type = str, default = ""),
'string',
"Twilio authentication token. This can be obtained from a valid Twilio account",
bounds = 'required minmax:10:50',
display_name = "Twilio Authentication Token")
AddOnCfg['gensms']['parameters']['to_number'] = CreateAddOnParam(
ConfigFiles[GENSMS_CONFIG].ReadValue("to_number", return_type = str, default = ""),
'string',
"Mobile number to send SMS message to. This can be any mobile number.",
bounds = 'required InternationalPhone',
display_name = "Recipient Phone Number")
AddOnCfg['gensms']['parameters']['from_number'] = CreateAddOnParam(
ConfigFiles[GENSMS_CONFIG].ReadValue("from_number", return_type = str, default = ""),
'string',
"Number to send SMS message from. This should be a twilio phone number.",
bounds = 'required InternationalPhone',
display_name = "Twilio Phone Number")
#GENSMS_MODEM
AddOnCfg['gensms_modem'] = collections.OrderedDict()
AddOnCfg['gensms_modem']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gensms_modem", default = False)
AddOnCfg['gensms_modem']['title'] = "Notifications via SMS - LTE Hat"
AddOnCfg['gensms_modem']['description'] = "Send Genmon and utility state changes via cellular SMS (additional hardware required)"
AddOnCfg['gensms_modem']['icon'] = "sms"
AddOnCfg['gensms_modem']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gensms_modempy-optional"
AddOnCfg['gensms_modem']['parameters'] = collections.OrderedDict()
AddOnCfg['gensms_modem']['parameters']['recipient'] = CreateAddOnParam(
ConfigFiles[MYMODEM_CONFIG].ReadValue("recipient", return_type = str, default = ""),
'string',
"Mobile number to send SMS message. This can be any mobile number. No dashes or spaces.",
bounds = 'required InternationalPhone',
display_name = "Recipient Phone Number")
AddOnCfg['gensms_modem']['parameters']['port'] = CreateAddOnParam(
ConfigFiles[MYMODEM_CONFIG].ReadValue("port", return_type = str, default = ""),
'string',
"This is the serial device to send AT modem commands. This *must* be different from the serial port used by the generator monitor software.",
bounds = 'required UnixDevice',
display_name = "Modem Serial Port")
AddOnCfg['gensms_modem']['parameters']['rate'] = CreateAddOnParam(
ConfigFiles[MYMODEM_CONFIG].ReadValue("rate", return_type = int, default = 115200),
'int',
"The baud rate for the port. Use 115200 for the LTEPiHat.",
bounds = 'required digits',
display_name = "Modem Serial Rate")
AddOnCfg['gensms_modem']['parameters']['log_at_commands'] = CreateAddOnParam(
ConfigFiles[MYMODEM_CONFIG].ReadValue("log_at_commands", return_type = bool, default = False),
'boolean',
"Enable to log at commands to the log file.",
display_name = "Log AT Commands")
# modem type - select the type of modem used. For future use. Presently "LTEPiHat" is the only option
#modem_type = LTEPiHat
#GENPUSHOVER
AddOnCfg['genpushover'] = collections.OrderedDict()
AddOnCfg['genpushover']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "genpushover", default = False)
AddOnCfg['genpushover']['title'] = "Notifications via Pushover"
AddOnCfg['genpushover']['description'] = "Send Genmon and utility state changes via Pushover service"
AddOnCfg['genpushover']['icon'] = "pushover"
AddOnCfg['genpushover']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#genpushoverpy-optional"
AddOnCfg['genpushover']['parameters'] = collections.OrderedDict()
AddOnCfg['genpushover']['parameters']['appid'] = CreateAddOnParam(
ConfigFiles[GENPUSHOVER_CONFIG].ReadValue("appid", return_type = str, default = ""),
'string',
"Pushover app ID.",
bounds = 'required minmax:5:50',
display_name = "Application ID")
AddOnCfg['genpushover']['parameters']['userid'] = CreateAddOnParam(
ConfigFiles[GENPUSHOVER_CONFIG].ReadValue("userid", return_type = str, default = ""),
'string',
"Pushover user ID.",
bounds = 'required minmax:5:50',
display_name = "User ID")
AddOnCfg['genpushover']['parameters']['pushsound'] = CreateAddOnParam(
ConfigFiles[GENPUSHOVER_CONFIG].ReadValue("pushsound", return_type = str, default = "updown"),
'string',
"Notification sound identifier. See https://pushover.net/api#sounds for a full list of sound IDs",
bounds = 'minmax:3:20',
display_name = "Push Sound")
# GENSYSLOG
AddOnCfg['gensyslog'] = collections.OrderedDict()
AddOnCfg['gensyslog']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gensyslog", default = False)
AddOnCfg['gensyslog']['title'] = "Linux System Logging"
AddOnCfg['gensyslog']['description'] = "Write generator and utility state changes to system log (/var/log/system)"
AddOnCfg['gensyslog']['icon'] = "linux"
AddOnCfg['gensyslog']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gensyslogpy-optional"
AddOnCfg['gensyslog']['parameters'] = None
#GENMQTT
AddOnCfg['genmqtt'] = collections.OrderedDict()
AddOnCfg['genmqtt']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "genmqtt", default = False)
AddOnCfg['genmqtt']['title'] = "MQTT integration"
AddOnCfg['genmqtt']['description'] = "Export Genmon data and status to MQTT server for automation integration"
AddOnCfg['genmqtt']['icon'] = "mqtt"
AddOnCfg['genmqtt']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#genmqttpy-optional"
AddOnCfg['genmqtt']['parameters'] = collections.OrderedDict()
AddOnCfg['genmqtt']['parameters']['mqtt_address'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("mqtt_address", return_type = str, default = ""),
'string',
"Address of your MQTT server.",
bounds = 'required IPAddress',
display_name = "MQTT Server Address")
AddOnCfg['genmqtt']['parameters']['mqtt_port'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("mqtt_port", return_type = int, default = 1833),
'int',
"The port of the MQTT server in a decimal number.",
bounds = 'required digits',
display_name = "MQTT Server Port Number")
AddOnCfg['genmqtt']['parameters']['username'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("username", return_type = str, default = ""),
'string',
"This value is used for the username if your MQTT server requires authentication. Leave blank for no authentication.",
bounds = 'minmax:4:50',
display_name = "MQTT Authentication Username")
AddOnCfg['genmqtt']['parameters']['password'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("password", return_type = str, default = ""),
'password',
"This value is used for the password if your MQTT server requires authentication. Leave blank for no authentication or no password.",
bounds = 'minmax:4:50',
display_name = "MQTT Authentication Password")
AddOnCfg['genmqtt']['parameters']['poll_interval'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("poll_interval", return_type = float, default = 2.0),
'float',
"The time in seconds between requesting status from genmon. The default value is 2 seconds.",
bounds = 'number',
display_name = "Poll Interval")
AddOnCfg['genmqtt']['parameters']['root_topic'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("root_topic", return_type = str, default = ""),
'string',
"(Optional) Prepend this value to the MQTT data path i.e. 'Home' would result in 'Home/generator/...''",
bounds = 'minmax:1:50',
display_name = "Root Topic")
AddOnCfg['genmqtt']['parameters']['blacklist'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("blacklist", return_type = str, default = ""),
'string',
"(Optional) Names of data not exported to the MQTT server, separated by commas.",
bounds = '',
display_name = "Blacklist Filter")
AddOnCfg['genmqtt']['parameters']['flush_interval'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("flush_interval", return_type = float, default = 0),
'float',
"(Optional) Time in seconds where even unchanged values will be published to their MQTT topic. Set to zero to disable flushing.",
bounds = 'number',
display_name = "Flush Interval")
AddOnCfg['genmqtt']['parameters']['numeric_json'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("numeric_json", return_type = bool, default = False),
'boolean',
"If enabled will return numeric values in the Status, Maintenance (Evo/Nexus only) and Outage topics as an object with unit, type and value members.",
bounds = '',
display_name = "JSON for Numerics")
AddOnCfg['genmqtt']['parameters']['remove_spaces'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("remove_spaces", return_type = bool, default = False),
'boolean',
"If enabled any spaces in the topic path will be converted to underscores",
bounds = '',
display_name = "Remove Spaces in Topic Path")
AddOnCfg['genmqtt']['parameters']['cert_authority_path'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("cert_authority_path", return_type = str, default = ""),
'string',
"(Optional) Full path to Certificate Authority file. Leave empty to not use SSL/TLS. If used port will be forced to 8883.",
bounds = '',
display_name = "SSL/TLS CA certificate file")
AddOnCfg['genmqtt']['parameters']['tls_version'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("tls_version", return_type = str, default = "1.0"),
'list',
"(Optional) TLS version used (integer). Default is 1.0. Must be 1.0, 1.1, or 1.2. This is ignored if a CA cert file is not used. ",
bounds = '1.0,1.1,1.2',
display_name = "TLS Version")
AddOnCfg['genmqtt']['parameters']['cert_reqs'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("cert_reqs", return_type = str, default = "Required"),
'list',
"(Optional) Defines the certificate requirements that the client imposes on the broker. Used if Certificate Authority file is used.",
bounds = 'None,Optional,Required',
display_name = "Certificate Requirements")
AddOnCfg['genmqtt']['parameters']['client_id'] = CreateAddOnParam(
ConfigFiles[GENMQTT_CONFIG].ReadValue("client_id", return_type = str, default = "genmon"),
'string',
"Unique identifer. Must be unique for each instance of genmon running on a given system. ",
bounds = '',
display_name = "Client ID")
#GENSLACK
AddOnCfg['genslack'] = collections.OrderedDict()
AddOnCfg['genslack']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "genslack", default = False)
AddOnCfg['genslack']['title'] = "Notifications via Slack"
AddOnCfg['genslack']['description'] = "Send Genmon and utility state changes via Slack service"
AddOnCfg['genslack']['icon'] = "slack"
AddOnCfg['genslack']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#genslackpy-optional"
AddOnCfg['genslack']['parameters'] = collections.OrderedDict()
AddOnCfg['genslack']['parameters']['webhook_url'] = CreateAddOnParam(
ConfigFiles[GENSLACK_CONFIG].ReadValue("webhook_url", return_type = str, default = ""),
'string',
"Full Slack Webhook URL. Retrieve from Slack custom integration configuration.",
bounds = 'required HTTPAddress',
display_name = "Web Hook URL")
AddOnCfg['genslack']['parameters']['channel'] = CreateAddOnParam(
ConfigFiles[GENSLACK_CONFIG].ReadValue("channel", return_type = str, default = ""),
'string',
"Slack channel to which the message will be sent.",
display_name = "Channel")
AddOnCfg['genslack']['parameters']['username'] = CreateAddOnParam(
ConfigFiles[GENSLACK_CONFIG].ReadValue("username", return_type = str, default = ""),
'string',
"Slack username.",
bounds = 'required username',
display_name = "Username")
AddOnCfg['genslack']['parameters']['icon_emoji'] = CreateAddOnParam(
ConfigFiles[GENSLACK_CONFIG].ReadValue("icon_emoji", return_type = str, default = ":red_circle:"),
'string',
"Emoji that appears as the icon of the user who sent the message i.e. :red_circle:n",
bounds = '',
display_name = "Icon Emoji")
AddOnCfg['genslack']['parameters']['title_link'] = CreateAddOnParam(
ConfigFiles[GENSLACK_CONFIG].ReadValue("title_link", return_type = str, default = request.url_root),
'string',
"Use this to make the title of the message a link i.e. link to the genmon web interface.",
bounds = 'HTTPAddress',
display_name = "Title Link")
# GENEXERCISE
ControllerInfo = GetControllerInfo("controller").lower()
if "evolution" in ControllerInfo or "nexus" in ControllerInfo:
AddOnCfg['genexercise'] = collections.OrderedDict()
AddOnCfg['genexercise']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "genexercise", default = False)
AddOnCfg['genexercise']['title'] = "Enhanced Exercise"
AddOnCfg['genexercise']['description'] = "Add additional exercise cycles with new functionality for Evolution/Nexus Controllers"
AddOnCfg['genexercise']['icon'] = "selftest"
AddOnCfg['genexercise']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#genexercisepy-optional"
AddOnCfg['genexercise']['parameters'] = collections.OrderedDict()
AddOnCfg['genexercise']['parameters']['exercise_type'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_type", return_type = str, default = "Normal"),
'list',
"Quiet Exercise (reducded RPM, Hz and Voltage), Normal Exercise or Exercise with Transfer Switch Activated.",
bounds = 'Quiet,Normal,Transfer',
display_name = "Exercise Type")
AddOnCfg['genexercise']['parameters']['exercise_frequency'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_frequency", return_type = str, default = "Monthly"),
'list',
"Exercise Frequency options are Weekly, Biweekly, or Monthly",
bounds = 'Weekly,Biweekly,Monthly',
display_name = "Exercise Frequency")
AddOnCfg['genexercise']['parameters']['use_gen_time'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("use_gen_time", return_type = bool, default = False),
'boolean',
"Enable to use the generator time for the exercise cycle, otherwise it will use the system time.",
display_name = "Use Generator Time")
AddOnCfg['genexercise']['parameters']['exercise_hour'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_hour", return_type = int, default = 12),
'int',
"The hour of the exercise time. Valid input is 0 - 23.",
bounds = "required digits range:0:23",
display_name = "Exercise Time Hour")
AddOnCfg['genexercise']['parameters']['exercise_minute'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_minute", return_type = int, default = 0),
'int',
"The minute of the exercise time. Valid input is 0 - 59",
bounds = "required digits range:0:59",
display_name = "Exercise Time Minute")
AddOnCfg['genexercise']['parameters']['exercise_day_of_month'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_day_of_month", return_type = int, default = 1),
'int',
"The day of month if monthly exercise is selected.",
bounds = "required digits range:1:28",
display_name = "Exercise Day of Month")
AddOnCfg['genexercise']['parameters']['exercise_day_of_week'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_day_of_week", return_type = str, default = "Monday"),
'list',
"Exercise day of the week, if Weekly or Biweekly exercise frequency is selected.",
bounds = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday",
display_name = "Exercise Day of the Week")
AddOnCfg['genexercise']['parameters']['exercise_duration'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_duration", return_type = float, default = 12),
'float',
"The duration of the exercise time. Note: this time does not include warmup time for Transfer type exercise cycles.",
bounds = 'number range:5:60',
display_name = "Exercise Duration")
AddOnCfg['genexercise']['parameters']['exercise_warmup'] = CreateAddOnParam(
ConfigFiles[GENEXERCISE_CONFIG].ReadValue("exercise_warmup", return_type = float, default = 0),
'float',
"The duration of the warmup time. Note: this time only appies to the transfer type of exercise cycle. Zero will disable the warmup period.",
bounds = 'number range:0:30',
display_name = "Warmup Duration")
#GENEMAIL2SMS
AddOnCfg['genemail2sms'] = collections.OrderedDict()
AddOnCfg['genemail2sms']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "genemail2sms", default = False)
AddOnCfg['genemail2sms']['title'] = "Mobile Carrier Email to SMS"
AddOnCfg['genemail2sms']['description'] = "Send Genmon and utility state changes via carrier email to SMS service"
AddOnCfg['genemail2sms']['icon'] = "text"
AddOnCfg['genemail2sms']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#genemail2smspy-optional"
AddOnCfg['genemail2sms']['parameters'] = collections.OrderedDict()
AddOnCfg['genemail2sms']['parameters']['destination'] = CreateAddOnParam(
ConfigFiles[GENEMAIL2SMS_CONFIG].ReadValue("destination", return_type = str, default = ""),
'string',
"Email to SMS email recipient. Must be a valid email address",
bounds = 'required email',
display_name = "Email to SMS address")
#GENTANKUTIL
AddOnCfg['gentankutil'] = collections.OrderedDict()
AddOnCfg['gentankutil']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gentankutil", default = False)
AddOnCfg['gentankutil']['title'] = "External Tank Fuel Monitor"
AddOnCfg['gentankutil']['description'] = "Integrates tankutility.com propane tank sensor data"
AddOnCfg['gentankutil']['icon'] = "tankutility"
AddOnCfg['gentankutil']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gentankutilpy-optional"
AddOnCfg['gentankutil']['parameters'] = collections.OrderedDict()
AddOnCfg['gentankutil']['parameters']['tank_name'] = CreateAddOnParam(
ConfigFiles[GENTANKUTIL_CONFIG].ReadValue("tank_name", return_type = str, default = ""),
'string',
"Tank name as defined in tankutility.com",
bounds = 'minmax:1:50',
display_name = "Tank Name")
AddOnCfg['gentankutil']['parameters']['username'] = CreateAddOnParam(
ConfigFiles[GENTANKUTIL_CONFIG].ReadValue("username", return_type = str, default = ""),
'string',
"Username at tankutility.com",
bounds = 'required email',
display_name = "Username")
AddOnCfg['gentankutil']['parameters']['password'] = CreateAddOnParam(
ConfigFiles[GENTANKUTIL_CONFIG].ReadValue("password", return_type = str, default = ""),
'password',
"Password at tankutility.com",
bounds = 'minmax:4:50',
display_name = "Password")
AddOnCfg['gentankutil']['parameters']['poll_frequency'] = CreateAddOnParam(
ConfigFiles[GENTANKUTIL_CONFIG].ReadValue("poll_frequency", return_type = float, default = 0),
'float',
"The duration in minutes between poll of tank data.",
bounds = 'number',
display_name = "Poll Frequency")
#GENTANKDIY
AddOnCfg['gentankdiy'] = collections.OrderedDict()
AddOnCfg['gentankdiy']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gentankdiy", default = False)
AddOnCfg['gentankdiy']['title'] = "DIY Fuel Tank Gauge Sensor"
AddOnCfg['gentankdiy']['description'] = "Integrates DIY tank gauge sensor for Genmon"
AddOnCfg['gentankdiy']['icon'] = "rpi"
AddOnCfg['gentankdiy']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gentankdiypy-optional"
AddOnCfg['gentankdiy']['parameters'] = collections.OrderedDict()
AddOnCfg['gentankdiy']['parameters']['poll_frequency'] = CreateAddOnParam(
ConfigFiles[GENTANKDIY_CONFIG].ReadValue("poll_frequency", return_type = float, default = 0),
'float',
"The duration in minutes between poll of tank data.",
bounds = 'number',
display_name = "Poll Frequency")
AddOnCfg['gentankdiy']['parameters']['gauge_type'] = CreateAddOnParam(
ConfigFiles[GENTANKDIY_CONFIG].ReadValue("gauge_type", return_type = str, default = '1'),
'list',
"DIY sensor type. Valid optios are Type 1 and Type 2.",
bounds = '1,2',
display_name = "Sensor Type")
#GENALEXA
AddOnCfg['genalexa'] = collections.OrderedDict()
AddOnCfg['genalexa']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "genalexa", default = False)
AddOnCfg['genalexa']['title'] = "Amazon Alexa voice commands"
AddOnCfg['genalexa']['description'] = "Allow Amazon Alexa to start and stop the generator"
AddOnCfg['genalexa']['icon'] = "alexa"
AddOnCfg['genalexa']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#genalexapy-optional"
AddOnCfg['genalexa']['parameters'] = collections.OrderedDict()
AddOnCfg['genalexa']['parameters']['name'] = CreateAddOnParam(
ConfigFiles[GENALEXA_CONFIG].ReadValue("name", return_type = str, default = ""),
'string',
"Name to call the generator device, i.e. 'generator'",
bounds = 'minmax:4:50',
display_name = "Name for generator device")
#GENSNMP
AddOnCfg['gensnmp'] = collections.OrderedDict()
AddOnCfg['gensnmp']['enable'] = ConfigFiles[GENLOADER_CONFIG].ReadValue("enable", return_type = bool, section = "gensnmp", default = False)
AddOnCfg['gensnmp']['title'] = "SNMP Support"
AddOnCfg['gensnmp']['description'] = "Allow Genmon to respond to SNMP requests"
AddOnCfg['gensnmp']['icon'] = "snmp"
AddOnCfg['gensnmp']['url'] = "https://github.com/jgyates/genmon/wiki/1----Software-Overview#gensnmppy-optional"
AddOnCfg['gensnmp']['parameters'] = collections.OrderedDict()
AddOnCfg['gensnmp']['parameters']['poll_frequency'] = CreateAddOnParam(
ConfigFiles[GENSNMP_CONFIG].ReadValue("poll_frequency", return_type = float, default = 2.0),
'float',
"The time in seconds between requesting status from genmon. The default value is 2 seconds.",
bounds = 'number',
display_name = "Poll Interval")
AddOnCfg['gensnmp']['parameters']['enterpriseid'] = CreateAddOnParam(
ConfigFiles[GENSNMP_CONFIG].ReadValue("enterpriseid", return_type = int, default = 9999),
'int',
"The enterprise ID used in the SNMP Object Identifier (OID).",
bounds = 'required digits',
display_name = "Enterprise ID")
AddOnCfg['gensnmp']['parameters']['community'] = CreateAddOnParam(
ConfigFiles[GENSNMP_CONFIG].ReadValue("community", return_type = str, default = "public"),
'string',
"SNMP Community string",
bounds = 'minmax:4:50',
display_name = "SNMP Community")
AddOnCfg['gensnmp']['parameters']['use_numeric'] = CreateAddOnParam(
ConfigFiles[GENSNMP_CONFIG].ReadValue("use_numeric", return_type = bool, default = False),
'boolean',