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
|
||||
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=[]):
|
||||
if not os.path.exists(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:
|
||||
config=json.load(ch)
|
||||
config=mergeConfig(config,addDirs)
|
||||
config=expandConfig(config)
|
||||
data=json.dumps(config,indent=2)
|
||||
writeFileIfChanged(outFile,data)
|
||||
|
||||
|
|
|
@ -3,7 +3,12 @@
|
|||
#ifdef _GWIIC
|
||||
#include <Wire.h>
|
||||
#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"
|
||||
#endif
|
||||
#ifdef GWQMP6988
|
||||
|
@ -16,7 +21,6 @@
|
|||
#ifdef GWBME280
|
||||
#include <Adafruit_BME280.h>
|
||||
#endif
|
||||
//#define GWSHT3X -1
|
||||
|
||||
#ifndef GWIIC_SDA
|
||||
#define GWIIC_SDA -1
|
||||
|
@ -29,14 +33,14 @@
|
|||
cfg->getValue(name, GwConfigDefinitions::prefix ## name)
|
||||
|
||||
#define CSHT3X(name) \
|
||||
CFG_GET(config,name,SHT3X)
|
||||
CFG_GET(config,name,SHT3X1)
|
||||
#define CQMP6988(name) \
|
||||
CFG_GET(config,name,QMP6988)
|
||||
CFG_GET(config,name,QMP69881)
|
||||
#define CBME280(name) \
|
||||
CFG_GET(config,name,BME280)
|
||||
CFG_GET(config,name,BME2801)
|
||||
class SHT3XConfig{
|
||||
public:
|
||||
const String prefix="SHT3X";
|
||||
const String prefix="SHT3X1";
|
||||
String tmNam;
|
||||
String huNam;
|
||||
int iid;
|
||||
|
@ -60,7 +64,7 @@ class SHT3XConfig{
|
|||
|
||||
class QMP6988Config{
|
||||
public:
|
||||
const String prefix="QMP6988";
|
||||
const String prefix="QMP69881";
|
||||
String prNam="Pressure";
|
||||
int iid=99;
|
||||
bool prAct=true;
|
||||
|
@ -79,7 +83,7 @@ class QMP6988Config{
|
|||
|
||||
class BME280Config{
|
||||
public:
|
||||
const String prefix="BME280";
|
||||
const String prefix="BME2801";
|
||||
bool prAct=true;
|
||||
bool tmAct=true;
|
||||
bool huAct=true;
|
||||
|
|
|
@ -1,433 +1,508 @@
|
|||
[
|
||||
{
|
||||
"name": "SHT3XtmAct",
|
||||
"label": "SHT3X Temp",
|
||||
"type": "boolean",
|
||||
"default": "true",
|
||||
"description": "Enable the I2C SHT3x temp sensor",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"SHT3X":"true"
|
||||
}
|
||||
"type": "array",
|
||||
"name": "SHT3X",
|
||||
"replace": [
|
||||
{
|
||||
"b": "1",
|
||||
"i": "1",
|
||||
"n": "99"
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"label": "SHT3X Temp Type",
|
||||
"type": "list",
|
||||
"default": "2",
|
||||
"description": "the NMEA2000 source type for the temperature",
|
||||
"list": [
|
||||
"type": "array",
|
||||
"name": "QMP6988",
|
||||
"replace": [
|
||||
{
|
||||
"l": "SeaTemperature",
|
||||
"v": "0"
|
||||
"b": "1",
|
||||
"i": "1",
|
||||
"n": "97"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
"b": "1",
|
||||
"i": "2",
|
||||
"n": "96"
|
||||
}
|
||||
],
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"SHT3X":"true"
|
||||
}
|
||||
"children": [
|
||||
{
|
||||
"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",
|
||||
"label": "SHT3X Humidity",
|
||||
"type": "boolean",
|
||||
"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": [
|
||||
"type": "array",
|
||||
"name": "BME280",
|
||||
"replace": [
|
||||
{
|
||||
"l": "SeaTemperature",
|
||||
"v": "0"
|
||||
"b": "1",
|
||||
"i": "1",
|
||||
"n": "95"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
"b": "1",
|
||||
"i": "2",
|
||||
"n": "94"
|
||||
}
|
||||
],
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name":"BME280tmOff",
|
||||
"label":"BME280 Temperature Offset",
|
||||
"type": "number",
|
||||
"description": "offset (in °) to be added to the BME280 temperature measurements",
|
||||
"default":"0",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280huAct",
|
||||
"label": "BME280 Humidity",
|
||||
"type": "boolean",
|
||||
"default": "true",
|
||||
"description": "Enable the I2C BME280 humidity sensor",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280huSrc",
|
||||
"label": "BME280 Humid Type",
|
||||
"type": "list",
|
||||
"description": "the NMEA2000 source type for the humidity",
|
||||
"default": "0",
|
||||
"list":[
|
||||
{"l":"InsideHumidity","v":"0"},
|
||||
{"l":"OutsideHumidity","v":"1"},
|
||||
{"l":"Undef","v":"0xff"}
|
||||
],
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280prAct",
|
||||
"label": "BME280 Pressure",
|
||||
"type": "boolean",
|
||||
"default": "true",
|
||||
"description": "Enable the I2C BME280 pressure sensor",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name":"BME280prOff",
|
||||
"label":"BME280 Pressure Offset",
|
||||
"type": "number",
|
||||
"description": "offset (in pa) to be added to the BME280 pressure measurements",
|
||||
"default":"0",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280iid",
|
||||
"label": "BME280 N2K iid",
|
||||
"type": "number",
|
||||
"default": 99,
|
||||
"description": "the N2K instance id for the BME280 Temperature and Humidity ",
|
||||
"category": "sensors",
|
||||
"min": 0,
|
||||
"max": 253,
|
||||
"check": "checkMinMax",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280intv",
|
||||
"label": "BME280 Interval",
|
||||
"type": "number",
|
||||
"default": 2,
|
||||
"description": "Interval(s) to query BME280 Temperature and Humidity (1...300)",
|
||||
"category": "sensors",
|
||||
"min": 1,
|
||||
"max": 300,
|
||||
"check": "checkMinMax",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280tmNam",
|
||||
"label": "BME280 Temp XDR",
|
||||
"type": "String",
|
||||
"default": "Temp",
|
||||
"description": "set the XDR transducer name for the BME280 Temperature, leave empty to disable NMEA0183 XDR ",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280huNam",
|
||||
"label": "BME280 Humid XDR",
|
||||
"type": "String",
|
||||
"default": "Humidity",
|
||||
"description": "set the XDR transducer name for the BME280 Humidity, leave empty to disable NMEA0183 XDR",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280prNam",
|
||||
"label": "BME280 Pressure XDR",
|
||||
"type": "String",
|
||||
"default": "Pressure",
|
||||
"description": "set the XDR transducer name for the BME280 Pressure, leave empty to disable NMEA0183 XDR",
|
||||
"category": "sensors",
|
||||
"capabilities": {
|
||||
"BME280":"true"
|
||||
}
|
||||
"children": [
|
||||
{
|
||||
"name": "BME280$itmAct",
|
||||
"label": "BME280-$i Temp",
|
||||
"type": "boolean",
|
||||
"default": "true",
|
||||
"description": "Enable the $i. I2C BME280 temp sensor (bus $b)",
|
||||
"category": "iicsensors$b",
|
||||
"capabilities": {
|
||||
"BME280$i": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280$itmSrc",
|
||||
"label": "BME280-$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": {
|
||||
"BME280$i": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280$itmOff",
|
||||
"label": "BME280-$i Temperature Offset",
|
||||
"type": "number",
|
||||
"description": "offset (in °) to be added to the BME280 temperature measurements",
|
||||
"default": "0",
|
||||
"category": "iicsensors$b",
|
||||
"capabilities": {
|
||||
"BME280$i": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280$ihuAct",
|
||||
"label": "BME280-$i Humidity",
|
||||
"type": "boolean",
|
||||
"default": "true",
|
||||
"description": "Enable the $i. I2C BME280 humidity sensor",
|
||||
"category": "iicsensors$b",
|
||||
"capabilities": {
|
||||
"BME280$i": "true"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "BME280$ihuSrc",
|
||||
"label": "BME280-$i Humid Type",
|
||||
"type": "list",
|
||||
"description": "the NMEA2000 source type for the humidity",
|
||||
"default": "0",
|
||||
"list": [
|
||||
{
|
||||
"l": "InsideHumidity",
|
||||
"v": "0"
|
||||
},
|
||||
{
|
||||
"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) {
|
||||
let category;
|
||||
let categoryEl;
|
||||
let categoryFrame;
|
||||
let categories={};
|
||||
let frame = parent.querySelector('.configFormRows');
|
||||
if (!frame) throw Error("no config form");
|
||||
frame.innerHTML = '';
|
||||
|
@ -1035,23 +1033,25 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
|||
}
|
||||
else{
|
||||
if(includeXdr) return;
|
||||
}
|
||||
if (item.category != category || !categoryEl) {
|
||||
if (categoryFrame && ! currentCategoryPopulated){
|
||||
categoryFrame.remove();
|
||||
}
|
||||
let catEntry;
|
||||
if (categories[item.category] === undefined){
|
||||
catEntry={
|
||||
populated:false,
|
||||
frame: undefined,
|
||||
element: undefined
|
||||
}
|
||||
currentCategoryPopulated=false;
|
||||
categoryFrame = addEl('div', 'category', frame);
|
||||
categoryFrame.setAttribute('data-category',item.category)
|
||||
let categoryTitle = addEl('div', 'title', categoryFrame);
|
||||
categories[item.category]=catEntry
|
||||
catEntry.frame = addEl('div', 'category', frame);
|
||||
catEntry.frame.setAttribute('data-category',item.category)
|
||||
let categoryTitle = addEl('div', 'title', catEntry.frame);
|
||||
let categoryButton = addEl('span', 'icon icon-more', categoryTitle);
|
||||
addEl('span', 'label', categoryTitle, item.category);
|
||||
addEl('span','categoryAdd',categoryTitle);
|
||||
categoryEl = addEl('div', 'content', categoryFrame);
|
||||
categoryEl.classList.add('hidden');
|
||||
let currentEl = categoryEl;
|
||||
catEntry.element = addEl('div', 'content', catEntry.frame);
|
||||
catEntry.element.classList.add('hidden');
|
||||
categoryTitle.addEventListener('click', function (ev) {
|
||||
let rs = currentEl.classList.toggle('hidden');
|
||||
let rs = catEntry.element.classList.toggle('hidden');
|
||||
if (rs) {
|
||||
toggleClass(categoryButton,0,moreicons);
|
||||
}
|
||||
|
@ -1059,7 +1059,9 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
|||
toggleClass(categoryButton,1,moreicons);
|
||||
}
|
||||
})
|
||||
category = item.category;
|
||||
}
|
||||
else{
|
||||
catEntry=categories[item.category];
|
||||
}
|
||||
let showItem=true;
|
||||
let itemCapabilities=item.capabilities||{};
|
||||
|
@ -1089,8 +1091,8 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
|||
}
|
||||
if (showItem) {
|
||||
item.readOnly=readOnly;
|
||||
currentCategoryPopulated=true;
|
||||
let row = addEl('div', 'row', categoryEl);
|
||||
catEntry.populated=true;
|
||||
let row = addEl('div', 'row', catEntry.element);
|
||||
let label = item.label || item.name;
|
||||
addEl('span', 'label', row, label);
|
||||
let valueFrame = addEl('div', 'value', row);
|
||||
|
@ -1136,8 +1138,11 @@ function createConfigDefinitions(parent, capabilities, defs,includeXdr) {
|
|||
});
|
||||
}
|
||||
});
|
||||
if (categoryFrame && ! currentCategoryPopulated){
|
||||
categoryFrame.remove();
|
||||
for (let cat in categories){
|
||||
let catEntry=categories[cat];
|
||||
if (! catEntry.populated){
|
||||
catEntry.frame.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
function loadConfigDefinitions() {
|
||||
|
|
Loading…
Reference in New Issue