intermediate: allow for config array definitions, prepare multiple sensors
This commit is contained in:
parent
f3c682422f
commit
16b7652f1d
|
@ -108,6 +108,44 @@ def mergeConfig(base,other):
|
||||||
base=base+merge
|
base=base+merge
|
||||||
return base
|
return base
|
||||||
|
|
||||||
|
def replaceTexts(data,replacements):
|
||||||
|
if replacements is None:
|
||||||
|
return data
|
||||||
|
if isinstance(data,str):
|
||||||
|
for k,v in replacements.items():
|
||||||
|
data=data.replace("$"+k,str(v))
|
||||||
|
return data
|
||||||
|
if isinstance(data,list):
|
||||||
|
rt=[]
|
||||||
|
for e in data:
|
||||||
|
rt.append(replaceTexts(e,replacements))
|
||||||
|
return rt
|
||||||
|
if isinstance(data,dict):
|
||||||
|
rt={}
|
||||||
|
for k,v in data.items():
|
||||||
|
rt[replaceTexts(k,replacements)]=replaceTexts(v,replacements)
|
||||||
|
return rt
|
||||||
|
return data
|
||||||
|
def expandConfig(config):
|
||||||
|
rt=[]
|
||||||
|
for item in config:
|
||||||
|
type=item.get('type')
|
||||||
|
if type != 'array':
|
||||||
|
rt.append(item)
|
||||||
|
continue
|
||||||
|
replacements=item.get('replace')
|
||||||
|
children=item.get('children')
|
||||||
|
name=item.get('name')
|
||||||
|
if name is None:
|
||||||
|
name="#unknown#"
|
||||||
|
if not isinstance(replacements,list):
|
||||||
|
raise Exception("missing replacements at array %s"%name)
|
||||||
|
for replace in replacements:
|
||||||
|
if children is not None:
|
||||||
|
for c in children:
|
||||||
|
rt.append(replaceTexts(c,replace))
|
||||||
|
return rt
|
||||||
|
|
||||||
def generateMergedConfig(inFile,outFile,addDirs=[]):
|
def generateMergedConfig(inFile,outFile,addDirs=[]):
|
||||||
if not os.path.exists(inFile):
|
if not os.path.exists(inFile):
|
||||||
raise Exception("unable to read cfg file %s"%inFile)
|
raise Exception("unable to read cfg file %s"%inFile)
|
||||||
|
@ -115,6 +153,7 @@ def generateMergedConfig(inFile,outFile,addDirs=[]):
|
||||||
with open(inFile,'rb') as ch:
|
with open(inFile,'rb') as ch:
|
||||||
config=json.load(ch)
|
config=json.load(ch)
|
||||||
config=mergeConfig(config,addDirs)
|
config=mergeConfig(config,addDirs)
|
||||||
|
config=expandConfig(config)
|
||||||
data=json.dumps(config,indent=2)
|
data=json.dumps(config,indent=2)
|
||||||
writeFileIfChanged(outFile,data)
|
writeFileIfChanged(outFile,data)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,12 @@
|
||||||
#ifdef _GWIIC
|
#ifdef _GWIIC
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef GWSHT3X
|
#if defined(GWSHT3X) || defined(GWSHT3X1) || defined(GWSHT3X2) || defined(GWSHT3X2) || defined(GWSHT3X4)
|
||||||
|
#define _GWSHT3X
|
||||||
|
#else
|
||||||
|
#undef _GWSHT3X
|
||||||
|
#endif
|
||||||
|
#ifdef _GWSHT3X
|
||||||
#include "SHT3X.h"
|
#include "SHT3X.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef GWQMP6988
|
#ifdef GWQMP6988
|
||||||
|
@ -16,7 +21,6 @@
|
||||||
#ifdef GWBME280
|
#ifdef GWBME280
|
||||||
#include <Adafruit_BME280.h>
|
#include <Adafruit_BME280.h>
|
||||||
#endif
|
#endif
|
||||||
//#define GWSHT3X -1
|
|
||||||
|
|
||||||
#ifndef GWIIC_SDA
|
#ifndef GWIIC_SDA
|
||||||
#define GWIIC_SDA -1
|
#define GWIIC_SDA -1
|
||||||
|
@ -29,14 +33,14 @@
|
||||||
cfg->getValue(name, GwConfigDefinitions::prefix ## name)
|
cfg->getValue(name, GwConfigDefinitions::prefix ## name)
|
||||||
|
|
||||||
#define CSHT3X(name) \
|
#define CSHT3X(name) \
|
||||||
CFG_GET(config,name,SHT3X)
|
CFG_GET(config,name,SHT3X1)
|
||||||
#define CQMP6988(name) \
|
#define CQMP6988(name) \
|
||||||
CFG_GET(config,name,QMP6988)
|
CFG_GET(config,name,QMP69881)
|
||||||
#define CBME280(name) \
|
#define CBME280(name) \
|
||||||
CFG_GET(config,name,BME280)
|
CFG_GET(config,name,BME2801)
|
||||||
class SHT3XConfig{
|
class SHT3XConfig{
|
||||||
public:
|
public:
|
||||||
const String prefix="SHT3X";
|
const String prefix="SHT3X1";
|
||||||
String tmNam;
|
String tmNam;
|
||||||
String huNam;
|
String huNam;
|
||||||
int iid;
|
int iid;
|
||||||
|
@ -60,7 +64,7 @@ class SHT3XConfig{
|
||||||
|
|
||||||
class QMP6988Config{
|
class QMP6988Config{
|
||||||
public:
|
public:
|
||||||
const String prefix="QMP6988";
|
const String prefix="QMP69881";
|
||||||
String prNam="Pressure";
|
String prNam="Pressure";
|
||||||
int iid=99;
|
int iid=99;
|
||||||
bool prAct=true;
|
bool prAct=true;
|
||||||
|
@ -79,7 +83,7 @@ class QMP6988Config{
|
||||||
|
|
||||||
class BME280Config{
|
class BME280Config{
|
||||||
public:
|
public:
|
||||||
const String prefix="BME280";
|
const String prefix="BME2801";
|
||||||
bool prAct=true;
|
bool prAct=true;
|
||||||
bool tmAct=true;
|
bool tmAct=true;
|
||||||
bool huAct=true;
|
bool huAct=true;
|
||||||
|
|
|
@ -1,433 +1,508 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "SHT3XtmAct",
|
"type": "array",
|
||||||
"label": "SHT3X Temp",
|
"name": "SHT3X",
|
||||||
"type": "boolean",
|
"replace": [
|
||||||
"default": "true",
|
{
|
||||||
"description": "Enable the I2C SHT3x temp sensor",
|
"b": "1",
|
||||||
"category": "sensors",
|
"i": "1",
|
||||||
"capabilities": {
|
"n": "99"
|
||||||
"SHT3X":"true"
|
},
|
||||||
}
|
{
|
||||||
|
"b": "1",
|
||||||
|
"i": "2",
|
||||||
|
"n": "98"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"b": "2",
|
||||||
|
"i": "1",
|
||||||
|
"n": "109"
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "SHT3X$itmAct",
|
||||||
|
"label": "SHT3X$i Temp",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "true",
|
||||||
|
"description": "Enable the $i. I2C SHT3x temp sensor (bus $b)",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHT3X$itmSrc",
|
||||||
|
"label": "SHT3X$i Temp Type",
|
||||||
|
"type": "list",
|
||||||
|
"default": "2",
|
||||||
|
"description": "the NMEA2000 source type for the temperature",
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"l": "SeaTemperature",
|
||||||
|
"v": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "OutsideTemperature",
|
||||||
|
"v": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "InsideTemperature",
|
||||||
|
"v": "2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "EngineRoomTemperature",
|
||||||
|
"v": "3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "MainCabinTemperature",
|
||||||
|
"v": "4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "LiveWellTemperature",
|
||||||
|
"v": "5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "BaitWellTemperature",
|
||||||
|
"v": "6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "RefridgerationTemperature",
|
||||||
|
"v": "7"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "HeatingSystemTemperature",
|
||||||
|
"v": "8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "DewPointTemperature",
|
||||||
|
"v": "9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "ApparentWindChillTemperature",
|
||||||
|
"v": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "TheoreticalWindChillTemperature",
|
||||||
|
"v": "11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "HeatIndexTemperature",
|
||||||
|
"v": "12"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "FreezerTemperature",
|
||||||
|
"v": "13"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "ExhaustGasTemperature",
|
||||||
|
"v": "14"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "ShaftSealTemperature",
|
||||||
|
"v": "15"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHT3X$ihuAct",
|
||||||
|
"label": "SHT3X$i Humidity",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "true",
|
||||||
|
"description": "Enable the $i. I2C SHT3x humidity sensor (bus $b)",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHT3X$ihuSrc",
|
||||||
|
"label": "SHT3X$i Humid Type",
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"l": "OutsideHumidity",
|
||||||
|
"v": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "Undef",
|
||||||
|
"v": "0xff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHT3X$iiid",
|
||||||
|
"label": "SHT3X$i N2K iid",
|
||||||
|
"type": "number",
|
||||||
|
"default": "$n",
|
||||||
|
"description": "the N2K instance id for the $i. SHT3X Temperature and Humidity ",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"min": 0,
|
||||||
|
"max": 253,
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHT3X$iintv",
|
||||||
|
"label": "SHT3X$i Interval",
|
||||||
|
"type": "number",
|
||||||
|
"default": 2,
|
||||||
|
"description": "Interval(s) to query SHT3X Temperature and Humidity (1...300)",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"min": 1,
|
||||||
|
"max": 300,
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHT3X$itmNam",
|
||||||
|
"label": "SHT3X$i Temp XDR",
|
||||||
|
"type": "String",
|
||||||
|
"default": "Temp$i",
|
||||||
|
"description": "set the XDR transducer name for the $i. SHT3X Temperature, leave empty to disable NMEA0183 XDR ",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SHT3X$ihuNam",
|
||||||
|
"label": "SHT3X$i Humid XDR",
|
||||||
|
"type": "String",
|
||||||
|
"default": "Humidity$i",
|
||||||
|
"description": "set the XDR transducer name for the $i. SHT3X Humidity, leave empty to disable NMEA0183 XDR",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"SHT3X$i": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SHT3XtmSrc",
|
"type": "array",
|
||||||
"label": "SHT3X Temp Type",
|
"name": "QMP6988",
|
||||||
"type": "list",
|
"replace": [
|
||||||
"default": "2",
|
|
||||||
"description": "the NMEA2000 source type for the temperature",
|
|
||||||
"list": [
|
|
||||||
{
|
{
|
||||||
"l": "SeaTemperature",
|
"b": "1",
|
||||||
"v": "0"
|
"i": "1",
|
||||||
|
"n": "97"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"l": "OutsideTemperature",
|
"b": "1",
|
||||||
"v": "1"
|
"i": "2",
|
||||||
},
|
"n": "96"
|
||||||
{
|
|
||||||
"l": "InsideTemperature",
|
|
||||||
"v": "2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "EngineRoomTemperature",
|
|
||||||
"v": "3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "MainCabinTemperature",
|
|
||||||
"v": "4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "LiveWellTemperature",
|
|
||||||
"v": "5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "BaitWellTemperature",
|
|
||||||
"v": "6"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "RefridgerationTemperature",
|
|
||||||
"v": "7"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "HeatingSystemTemperature",
|
|
||||||
"v": "8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "DewPointTemperature",
|
|
||||||
"v": "9"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "ApparentWindChillTemperature",
|
|
||||||
"v": "10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "TheoreticalWindChillTemperature",
|
|
||||||
"v": "11"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "HeatIndexTemperature",
|
|
||||||
"v": "12"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "FreezerTemperature",
|
|
||||||
"v": "13"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "ExhaustGasTemperature",
|
|
||||||
"v": "14"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "ShaftSealTemperature",
|
|
||||||
"v": "15"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"category": "sensors",
|
"children": [
|
||||||
"capabilities": {
|
{
|
||||||
"SHT3X":"true"
|
"name": "QMP6988$iprAct",
|
||||||
}
|
"label": "QMP6988-$i pressure",
|
||||||
|
"description": "activate the $i. QMP6988 pressure measurement (bus $b)",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "true",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"QMP6988$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "QMP6988$iiid",
|
||||||
|
"label": "QMP6988-$i N2K iid",
|
||||||
|
"type": "number",
|
||||||
|
"default": "$n",
|
||||||
|
"description": "the N2K instance id for the $i. QMP6988 pressure",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"min": 0,
|
||||||
|
"max": 253,
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"capabilities": {
|
||||||
|
"QMP6988$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "QMP6988$iintv",
|
||||||
|
"label": "QMP6988-$i Interval",
|
||||||
|
"type": "number",
|
||||||
|
"default": 2,
|
||||||
|
"description": "Interval(s) to query the $i. QMP6988 Pressure (1...300)",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"min": 1,
|
||||||
|
"max": 300,
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"capabilities": {
|
||||||
|
"QMP6988$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "QMP6988$iprNam",
|
||||||
|
"label": "QMP6988-$i Pressure XDR",
|
||||||
|
"type": "String",
|
||||||
|
"default": "Pressure$i",
|
||||||
|
"description": "set the XDR transducer name for the $i. QMP6988 Pressure, leave empty to disable NMEA0183 XDR",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"QMP6988$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "QMP6988$iprOff",
|
||||||
|
"label": "QMP6988-$i Pressure Offset",
|
||||||
|
"type": "number",
|
||||||
|
"description": "offset (in pa) to be added to the $i. QMP6988 pressure measurements",
|
||||||
|
"default": "0",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"QMP6988$i": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "SHT3XhuAct",
|
"type": "array",
|
||||||
"label": "SHT3X Humidity",
|
"name": "BME280",
|
||||||
"type": "boolean",
|
"replace": [
|
||||||
"default": "true",
|
|
||||||
"description": "Enable the I2C SHT3x humidity sensor",
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"SHT3X":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SHT3XhuSrc",
|
|
||||||
"label": "SHT3X Humid Type",
|
|
||||||
"list":[
|
|
||||||
{"l":"OutsideHumidity","v":"1"},
|
|
||||||
{"l":"Undef","v":"0xff"}
|
|
||||||
],
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"SHT3X":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SHT3Xiid",
|
|
||||||
"label": "SHT3X N2K iid",
|
|
||||||
"type": "number",
|
|
||||||
"default": 99,
|
|
||||||
"description": "the N2K instance id for the SHT3X Temperature and Humidity ",
|
|
||||||
"category": "sensors",
|
|
||||||
"min": 0,
|
|
||||||
"max": 253,
|
|
||||||
"check": "checkMinMax",
|
|
||||||
"capabilities": {
|
|
||||||
"SHT3X":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SHT3Xintv",
|
|
||||||
"label": "SHT3X Interval",
|
|
||||||
"type": "number",
|
|
||||||
"default": 2,
|
|
||||||
"description": "Interval(s) to query SHT3X Temperature and Humidity (1...300)",
|
|
||||||
"category": "sensors",
|
|
||||||
"min": 1,
|
|
||||||
"max": 300,
|
|
||||||
"check": "checkMinMax",
|
|
||||||
"capabilities": {
|
|
||||||
"SHT3X":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SHT3XtmNam",
|
|
||||||
"label": "SHT3X Temp XDR",
|
|
||||||
"type": "String",
|
|
||||||
"default": "Temp",
|
|
||||||
"description": "set the XDR transducer name for the SHT3X Temperature, leave empty to disable NMEA0183 XDR ",
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"SHT3X":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "SHT3XhuNam",
|
|
||||||
"label": "SHT3X Humid XDR",
|
|
||||||
"type": "String",
|
|
||||||
"default": "Humidity",
|
|
||||||
"description": "set the XDR transducer name for the SHT3X Humidity, leave empty to disable NMEA0183 XDR",
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"SHT3X":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "QMP6988prAct",
|
|
||||||
"label": "QMP6988 pressure",
|
|
||||||
"description": "activate the QMP6988 pressure measurement",
|
|
||||||
"type":"boolean",
|
|
||||||
"default":"true",
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"QMP6988":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "QMP6988iid",
|
|
||||||
"label": "QMP6988 N2K iid",
|
|
||||||
"type": "number",
|
|
||||||
"default": 99,
|
|
||||||
"description": "the N2K instance id for the QMP6988 pressure",
|
|
||||||
"category": "sensors",
|
|
||||||
"min": 0,
|
|
||||||
"max": 253,
|
|
||||||
"check": "checkMinMax",
|
|
||||||
"capabilities": {
|
|
||||||
"QMP6988":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "QMP6988intv",
|
|
||||||
"label": "QMP6988 Interval",
|
|
||||||
"type": "number",
|
|
||||||
"default": 2,
|
|
||||||
"description": "Interval(s) to query QMP6988 Pressure (1...300)",
|
|
||||||
"category": "sensors",
|
|
||||||
"min": 1,
|
|
||||||
"max": 300,
|
|
||||||
"check": "checkMinMax",
|
|
||||||
"capabilities": {
|
|
||||||
"QMP6988":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "QMP6988prNam",
|
|
||||||
"label": "QMP6988 Pressure XDR",
|
|
||||||
"type": "String",
|
|
||||||
"default": "Pressure",
|
|
||||||
"description": "set the XDR transducer name for the QMP6988 Pressure, leave empty to disable NMEA0183 XDR",
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"QMP6988":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name":"QMP6988prOff",
|
|
||||||
"label":"QMP6988 Pressure Offset",
|
|
||||||
"type": "number",
|
|
||||||
"description": "offset (in pa) to be added to the QMP6988 pressure measurements",
|
|
||||||
"default":"0",
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"QMP6988":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "BME280tmAct",
|
|
||||||
"label": "BME280 Temp",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": "true",
|
|
||||||
"description": "Enable the I2C BME280 temp sensor",
|
|
||||||
"category": "sensors",
|
|
||||||
"capabilities": {
|
|
||||||
"BME280":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "BME280tmSrc",
|
|
||||||
"label": "BME280 Temp Type",
|
|
||||||
"type": "list",
|
|
||||||
"default": "2",
|
|
||||||
"description": "the NMEA2000 source type for the temperature",
|
|
||||||
"list": [
|
|
||||||
{
|
{
|
||||||
"l": "SeaTemperature",
|
"b": "1",
|
||||||
"v": "0"
|
"i": "1",
|
||||||
|
"n": "95"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"l": "OutsideTemperature",
|
"b": "1",
|
||||||
"v": "1"
|
"i": "2",
|
||||||
},
|
"n": "94"
|
||||||
{
|
|
||||||
"l": "InsideTemperature",
|
|
||||||
"v": "2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "EngineRoomTemperature",
|
|
||||||
"v": "3"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "MainCabinTemperature",
|
|
||||||
"v": "4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "LiveWellTemperature",
|
|
||||||
"v": "5"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "BaitWellTemperature",
|
|
||||||
"v": "6"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "RefridgerationTemperature",
|
|
||||||
"v": "7"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "HeatingSystemTemperature",
|
|
||||||
"v": "8"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "DewPointTemperature",
|
|
||||||
"v": "9"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "ApparentWindChillTemperature",
|
|
||||||
"v": "10"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "TheoreticalWindChillTemperature",
|
|
||||||
"v": "11"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "HeatIndexTemperature",
|
|
||||||
"v": "12"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "FreezerTemperature",
|
|
||||||
"v": "13"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "ExhaustGasTemperature",
|
|
||||||
"v": "14"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"l": "ShaftSealTemperature",
|
|
||||||
"v": "15"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"category": "sensors",
|
"children": [
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"name": "BME280$itmAct",
|
||||||
}
|
"label": "BME280-$i Temp",
|
||||||
},
|
"type": "boolean",
|
||||||
{
|
"default": "true",
|
||||||
"name":"BME280tmOff",
|
"description": "Enable the $i. I2C BME280 temp sensor (bus $b)",
|
||||||
"label":"BME280 Temperature Offset",
|
"category": "iicsensors$b",
|
||||||
"type": "number",
|
"capabilities": {
|
||||||
"description": "offset (in °) to be added to the BME280 temperature measurements",
|
"BME280$i": "true"
|
||||||
"default":"0",
|
}
|
||||||
"category": "sensors",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"name": "BME280$itmSrc",
|
||||||
}
|
"label": "BME280-$i Temp Type",
|
||||||
},
|
"type": "list",
|
||||||
{
|
"default": "2",
|
||||||
"name": "BME280huAct",
|
"description": "the NMEA2000 source type for the temperature",
|
||||||
"label": "BME280 Humidity",
|
"list": [
|
||||||
"type": "boolean",
|
{
|
||||||
"default": "true",
|
"l": "SeaTemperature",
|
||||||
"description": "Enable the I2C BME280 humidity sensor",
|
"v": "0"
|
||||||
"category": "sensors",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"l": "OutsideTemperature",
|
||||||
}
|
"v": "1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "BME280huSrc",
|
"l": "InsideTemperature",
|
||||||
"label": "BME280 Humid Type",
|
"v": "2"
|
||||||
"type": "list",
|
},
|
||||||
"description": "the NMEA2000 source type for the humidity",
|
{
|
||||||
"default": "0",
|
"l": "EngineRoomTemperature",
|
||||||
"list":[
|
"v": "3"
|
||||||
{"l":"InsideHumidity","v":"0"},
|
},
|
||||||
{"l":"OutsideHumidity","v":"1"},
|
{
|
||||||
{"l":"Undef","v":"0xff"}
|
"l": "MainCabinTemperature",
|
||||||
],
|
"v": "4"
|
||||||
"category": "sensors",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"l": "LiveWellTemperature",
|
||||||
}
|
"v": "5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "BME280prAct",
|
"l": "BaitWellTemperature",
|
||||||
"label": "BME280 Pressure",
|
"v": "6"
|
||||||
"type": "boolean",
|
},
|
||||||
"default": "true",
|
{
|
||||||
"description": "Enable the I2C BME280 pressure sensor",
|
"l": "RefridgerationTemperature",
|
||||||
"category": "sensors",
|
"v": "7"
|
||||||
"capabilities": {
|
},
|
||||||
"BME280":"true"
|
{
|
||||||
}
|
"l": "HeatingSystemTemperature",
|
||||||
},
|
"v": "8"
|
||||||
{
|
},
|
||||||
"name":"BME280prOff",
|
{
|
||||||
"label":"BME280 Pressure Offset",
|
"l": "DewPointTemperature",
|
||||||
"type": "number",
|
"v": "9"
|
||||||
"description": "offset (in pa) to be added to the BME280 pressure measurements",
|
},
|
||||||
"default":"0",
|
{
|
||||||
"category": "sensors",
|
"l": "ApparentWindChillTemperature",
|
||||||
"capabilities": {
|
"v": "10"
|
||||||
"BME280":"true"
|
},
|
||||||
}
|
{
|
||||||
},
|
"l": "TheoreticalWindChillTemperature",
|
||||||
{
|
"v": "11"
|
||||||
"name": "BME280iid",
|
},
|
||||||
"label": "BME280 N2K iid",
|
{
|
||||||
"type": "number",
|
"l": "HeatIndexTemperature",
|
||||||
"default": 99,
|
"v": "12"
|
||||||
"description": "the N2K instance id for the BME280 Temperature and Humidity ",
|
},
|
||||||
"category": "sensors",
|
{
|
||||||
"min": 0,
|
"l": "FreezerTemperature",
|
||||||
"max": 253,
|
"v": "13"
|
||||||
"check": "checkMinMax",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"l": "ExhaustGasTemperature",
|
||||||
}
|
"v": "14"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "BME280intv",
|
"l": "ShaftSealTemperature",
|
||||||
"label": "BME280 Interval",
|
"v": "15"
|
||||||
"type": "number",
|
}
|
||||||
"default": 2,
|
],
|
||||||
"description": "Interval(s) to query BME280 Temperature and Humidity (1...300)",
|
"category": "iicsensors$b",
|
||||||
"category": "sensors",
|
"capabilities": {
|
||||||
"min": 1,
|
"BME280$i": "true"
|
||||||
"max": 300,
|
}
|
||||||
"check": "checkMinMax",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"name": "BME280$itmOff",
|
||||||
}
|
"label": "BME280-$i Temperature Offset",
|
||||||
},
|
"type": "number",
|
||||||
{
|
"description": "offset (in °) to be added to the BME280 temperature measurements",
|
||||||
"name": "BME280tmNam",
|
"default": "0",
|
||||||
"label": "BME280 Temp XDR",
|
"category": "iicsensors$b",
|
||||||
"type": "String",
|
"capabilities": {
|
||||||
"default": "Temp",
|
"BME280$i": "true"
|
||||||
"description": "set the XDR transducer name for the BME280 Temperature, leave empty to disable NMEA0183 XDR ",
|
}
|
||||||
"category": "sensors",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"name": "BME280$ihuAct",
|
||||||
}
|
"label": "BME280-$i Humidity",
|
||||||
},
|
"type": "boolean",
|
||||||
{
|
"default": "true",
|
||||||
"name": "BME280huNam",
|
"description": "Enable the $i. I2C BME280 humidity sensor",
|
||||||
"label": "BME280 Humid XDR",
|
"category": "iicsensors$b",
|
||||||
"type": "String",
|
"capabilities": {
|
||||||
"default": "Humidity",
|
"BME280$i": "true"
|
||||||
"description": "set the XDR transducer name for the BME280 Humidity, leave empty to disable NMEA0183 XDR",
|
}
|
||||||
"category": "sensors",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"name": "BME280$ihuSrc",
|
||||||
}
|
"label": "BME280-$i Humid Type",
|
||||||
},
|
"type": "list",
|
||||||
{
|
"description": "the NMEA2000 source type for the humidity",
|
||||||
"name": "BME280prNam",
|
"default": "0",
|
||||||
"label": "BME280 Pressure XDR",
|
"list": [
|
||||||
"type": "String",
|
{
|
||||||
"default": "Pressure",
|
"l": "InsideHumidity",
|
||||||
"description": "set the XDR transducer name for the BME280 Pressure, leave empty to disable NMEA0183 XDR",
|
"v": "0"
|
||||||
"category": "sensors",
|
},
|
||||||
"capabilities": {
|
{
|
||||||
"BME280":"true"
|
"l": "OutsideHumidity",
|
||||||
}
|
"v": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"l": "Undef",
|
||||||
|
"v": "0xff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BME280$iprAct",
|
||||||
|
"label": "BME280-$i Pressure",
|
||||||
|
"type": "boolean",
|
||||||
|
"default": "true",
|
||||||
|
"description": "Enable the $i. I2C BME280 pressure sensor (bus $b)",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BME280$iprOff",
|
||||||
|
"label": "BME280 Pressure Offset",
|
||||||
|
"type": "number",
|
||||||
|
"description": "offset (in pa) to be added to the BME280 pressure measurements",
|
||||||
|
"default": "0",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BME280$iiid",
|
||||||
|
"label": "BME280-$i N2K iid",
|
||||||
|
"type": "number",
|
||||||
|
"default": "$n",
|
||||||
|
"description": "the N2K instance id for the BME280 Temperature and Humidity ",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"min": 0,
|
||||||
|
"max": 253,
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BME280$iintv",
|
||||||
|
"label": "BME280-$i Interval",
|
||||||
|
"type": "number",
|
||||||
|
"default": 2,
|
||||||
|
"description": "Interval(s) to query BME280 Temperature and Humidity (1...300)",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"min": 1,
|
||||||
|
"max": 300,
|
||||||
|
"check": "checkMinMax",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BME280$itmNam",
|
||||||
|
"label": "BME280-$i Temp XDR",
|
||||||
|
"type": "String",
|
||||||
|
"default": "BTemp$i",
|
||||||
|
"description": "set the XDR transducer name for the BME280 Temperature, leave empty to disable NMEA0183 XDR ",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BME280$ihuNam",
|
||||||
|
"label": "BME280-$i Humid XDR",
|
||||||
|
"type": "String",
|
||||||
|
"default": "BHumidity$i",
|
||||||
|
"description": "set the XDR transducer name for the BME280 Humidity, leave empty to disable NMEA0183 XDR",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BME280$iprNam",
|
||||||
|
"label": "BME280-$i Pressure XDR",
|
||||||
|
"type": "String",
|
||||||
|
"default": "BPressure$i",
|
||||||
|
"description": "set the XDR transducer name for the BME280 Pressure, leave empty to disable NMEA0183 XDR",
|
||||||
|
"category": "iicsensors$b",
|
||||||
|
"capabilities": {
|
||||||
|
"BME280$i": "true"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
45
web/index.js
45
web/index.js
|
@ -1020,9 +1020,7 @@ function toggleClass(el,id,classList){
|
||||||
}
|
}
|
||||||
|
|
||||||
function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
||||||
let category;
|
let categories={};
|
||||||
let categoryEl;
|
|
||||||
let categoryFrame;
|
|
||||||
let frame = parent.querySelector('.configFormRows');
|
let frame = parent.querySelector('.configFormRows');
|
||||||
if (!frame) throw Error("no config form");
|
if (!frame) throw Error("no config form");
|
||||||
frame.innerHTML = '';
|
frame.innerHTML = '';
|
||||||
|
@ -1035,23 +1033,25 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(includeXdr) return;
|
if(includeXdr) return;
|
||||||
}
|
}
|
||||||
if (item.category != category || !categoryEl) {
|
let catEntry;
|
||||||
if (categoryFrame && ! currentCategoryPopulated){
|
if (categories[item.category] === undefined){
|
||||||
categoryFrame.remove();
|
catEntry={
|
||||||
|
populated:false,
|
||||||
|
frame: undefined,
|
||||||
|
element: undefined
|
||||||
}
|
}
|
||||||
currentCategoryPopulated=false;
|
categories[item.category]=catEntry
|
||||||
categoryFrame = addEl('div', 'category', frame);
|
catEntry.frame = addEl('div', 'category', frame);
|
||||||
categoryFrame.setAttribute('data-category',item.category)
|
catEntry.frame.setAttribute('data-category',item.category)
|
||||||
let categoryTitle = addEl('div', 'title', categoryFrame);
|
let categoryTitle = addEl('div', 'title', catEntry.frame);
|
||||||
let categoryButton = addEl('span', 'icon icon-more', categoryTitle);
|
let categoryButton = addEl('span', 'icon icon-more', categoryTitle);
|
||||||
addEl('span', 'label', categoryTitle, item.category);
|
addEl('span', 'label', categoryTitle, item.category);
|
||||||
addEl('span','categoryAdd',categoryTitle);
|
addEl('span','categoryAdd',categoryTitle);
|
||||||
categoryEl = addEl('div', 'content', categoryFrame);
|
catEntry.element = addEl('div', 'content', catEntry.frame);
|
||||||
categoryEl.classList.add('hidden');
|
catEntry.element.classList.add('hidden');
|
||||||
let currentEl = categoryEl;
|
|
||||||
categoryTitle.addEventListener('click', function (ev) {
|
categoryTitle.addEventListener('click', function (ev) {
|
||||||
let rs = currentEl.classList.toggle('hidden');
|
let rs = catEntry.element.classList.toggle('hidden');
|
||||||
if (rs) {
|
if (rs) {
|
||||||
toggleClass(categoryButton,0,moreicons);
|
toggleClass(categoryButton,0,moreicons);
|
||||||
}
|
}
|
||||||
|
@ -1059,7 +1059,9 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
||||||
toggleClass(categoryButton,1,moreicons);
|
toggleClass(categoryButton,1,moreicons);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
category = item.category;
|
}
|
||||||
|
else{
|
||||||
|
catEntry=categories[item.category];
|
||||||
}
|
}
|
||||||
let showItem=true;
|
let showItem=true;
|
||||||
let itemCapabilities=item.capabilities||{};
|
let itemCapabilities=item.capabilities||{};
|
||||||
|
@ -1089,8 +1091,8 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
||||||
}
|
}
|
||||||
if (showItem) {
|
if (showItem) {
|
||||||
item.readOnly=readOnly;
|
item.readOnly=readOnly;
|
||||||
currentCategoryPopulated=true;
|
catEntry.populated=true;
|
||||||
let row = addEl('div', 'row', categoryEl);
|
let row = addEl('div', 'row', catEntry.element);
|
||||||
let label = item.label || item.name;
|
let label = item.label || item.name;
|
||||||
addEl('span', 'label', row, label);
|
addEl('span', 'label', row, label);
|
||||||
let valueFrame = addEl('div', 'value', row);
|
let valueFrame = addEl('div', 'value', row);
|
||||||
|
@ -1136,8 +1138,11 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (categoryFrame && ! currentCategoryPopulated){
|
for (let cat in categories){
|
||||||
categoryFrame.remove();
|
let catEntry=categories[cat];
|
||||||
|
if (! catEntry.populated){
|
||||||
|
catEntry.frame.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function loadConfigDefinitions() {
|
function loadConfigDefinitions() {
|
||||||
|
|
Loading…
Reference in New Issue