Merge pull request #195 from proddy/dev

Fix console UOM, set temperature to show 1 decimal place in web
This commit is contained in:
Proddy
2021-11-14 18:04:39 +01:00
committed by GitHub
5 changed files with 130 additions and 346 deletions

View File

@@ -122,7 +122,7 @@ export const formatDuration = (duration_min: number) => {
return formatted;
};
function formatValue(value: any, uom: number, digit: number) {
function formatValue(value: any, uom: number) {
switch (uom) {
case DeviceValueUOM.HOURS:
return value ? formatDuration(value * 60) : '0 hours';
@@ -134,9 +134,10 @@ function formatValue(value: any, uom: number, digit: number) {
}
return value;
case DeviceValueUOM.DEGREES:
// always show with one decimal place
return (
new Intl.NumberFormat(undefined, {
minimumFractionDigits: digit
minimumFractionDigits: 1
}).format(value) +
' ' +
DeviceValueUOM_s[uom]
@@ -410,7 +411,7 @@ class EMSESPDataForm extends Component<
</TableCell>
<TableCell align="left">{sensorData.i}</TableCell>
<TableCell align="right">
{formatValue(sensorData.t, DeviceValueUOM.DEGREES, 1)}
{formatValue(sensorData.t, DeviceValueUOM.DEGREES)}
</TableCell>
</TableRow>
))}
@@ -446,7 +447,7 @@ class EMSESPDataForm extends Component<
Analog Input
</TableCell>
<TableCell align="right">
{formatValue(data.analog, DeviceValueUOM.MV, 0)}
{formatValue(data.analog, DeviceValueUOM.MV)}
</TableCell>
</TableRow>
</TableBody>
@@ -601,7 +602,7 @@ class EMSESPDataForm extends Component<
{item.n}
</TableCell>
<TableCell padding="none" align="right">
{formatValue(item.v, item.u, 0)}
{formatValue(item.v, item.u)}
</TableCell>
</TableRow>
))}

View File

@@ -379,19 +379,19 @@ const emsesp_devicedata_1 = {
{
v: 18,
u: 1,
n: '(hc1) selected room temperature',
n: 'hc1 selected room temperature',
c: 'hc1/seltemp',
},
{
v: 22.6,
u: 1,
n: '(hc1) current room temperature',
n: 'hc1 current room temperature',
c: '',
},
{
v: 'auto',
u: 0,
n: '(hc1) mode',
n: 'hc1 mode',
c: 'hc1/mode',
},
],
@@ -400,360 +400,125 @@ const emsesp_devicedata_1 = {
const emsesp_devicedata_2 = {
name: 'Boiler: Nefit GBx72/Trendline/Cerapur/Greenstar Si/27i',
data: [
{ v: 'off', u: 0, n: 'heating active' },
{ v: 'off', u: 0, n: 'warm water active' },
{ v: 5, u: 1, n: 'selected flow temperature', c: 'selflowtemp' },
{ v: 0, u: 2, n: 'burner selected max power', c: 'selburnpow' },
{ v: 0, u: 2, n: 'heating pump modulation' },
{ v: 42.9, u: 1, n: 'current flow temperature' },
{ v: 41.8, u: 1, n: 'return temperature' },
{ v: 1.6, u: 9, n: 'system pressure' },
{ v: 45, u: 1, n: 'actual boiler temperature' },
{ v: 'off', u: 0, n: 'gas' },
{ v: 0, u: 8, n: 'flame current' },
{ v: 'off', u: 0, n: 'heating pump' },
{ v: 'off', u: 0, n: 'fan' },
{ v: 'off', u: 0, n: 'ignition' },
{
v: false,
u: 16,
n: 'heating active',
c: '',
},
{
v: false,
u: 16,
n: 'warm water active',
c: '',
},
{
v: 5,
u: 1,
n: 'selected flow temperature',
c: 'selflowtemp',
},
{
v: 0,
u: 2,
n: 'burner selected max power',
c: 'selburnpow',
},
{
v: 0,
u: 2,
n: 'heating pump modulation',
c: '',
},
{
v: 51,
u: 1,
n: 'current flow temperature',
c: '',
},
{
v: 49.8,
u: 1,
n: 'return temperature',
c: '',
},
{
v: 1.1,
u: 9,
n: 'system pressure',
c: '',
},
{
v: 52.7,
u: 1,
n: 'boiler temperature',
c: '',
},
{
v: false,
u: 16,
n: 'gas',
c: '',
},
{
v: 0,
u: 8,
n: 'flame current',
c: '',
},
{
v: false,
u: 16,
n: 'heating pump',
c: '',
},
{
v: false,
u: 16,
n: 'fan',
c: '',
},
{
v: false,
u: 16,
n: 'ignition',
c: '',
},
{
v: true,
u: 16,
v: 'on',
u: 0,
n: 'heating activated',
c: 'heatingactivated',
l: ['off', 'on'],
},
{
v: 75,
u: 1,
n: 'heating temperature',
c: 'heatingtemp',
},
{
v: 90,
u: 2,
n: 'burner pump max power',
c: 'pumpmodmax',
},
{
v: 55,
u: 2,
n: 'burner pump min power',
c: 'pumpmodmin',
},
{
v: 1,
u: 7,
n: 'pump delay',
c: 'pumpdelay',
},
{
v: 10,
u: 7,
n: 'burner min period',
c: 'burnminperiod',
},
{
v: 0,
u: 2,
n: 'burner min power',
c: 'burnminpower',
},
{
v: 75,
u: 2,
n: 'burner max power',
c: 'burnmaxpower',
},
{
v: -6,
u: 1,
n: 'hysteresis on temperature',
c: 'boilhyston',
},
{
v: 6,
u: 1,
n: 'hysteresis off temperature',
c: 'boilhystoff',
},
{
v: 0,
u: 2,
n: 'burner current power',
c: '',
},
{
v: 303226,
u: 15,
n: '# burner starts',
c: '',
},
{
v: 510634,
u: 7,
n: 'total burner operating time',
c: '',
},
{
v: 415235,
u: 7,
n: 'total heat operating time',
c: '',
},
{
v: 4338730,
u: 7,
n: 'total UBA operating time',
c: '',
},
{
v: '1C(210) 06.06.2020 12:07',
u: 0,
n: 'last error code',
c: '',
},
{
v: '0H',
u: 0,
n: 'service code',
c: '',
},
{
v: 203,
u: 0,
n: 'service code number',
c: '',
},
{
v: '01.01.2012',
u: 0,
n: 'maintenance set date',
c: '',
},
{ v: 75, u: 1, n: 'heating temperature', c: 'heatingtemp' },
{ v: 90, u: 2, n: 'burner pump max power', c: 'pumpmodmax' },
{ v: 55, u: 2, n: 'burner pump min power', c: 'pumpmodmin' },
{ v: 1, u: 7, n: 'pump delay', c: 'pumpdelay' },
{ v: 10, u: 7, n: 'burner min period', c: 'burnminperiod' },
{ v: 0, u: 2, n: 'burner min power', c: 'burnminpower' },
{ v: 77, u: 2, n: 'burner max power', c: 'burnmaxpower' },
{ v: -6, u: 1, n: 'hysteresis on temperature', c: 'boilhyston' },
{ v: 6, u: 1, n: 'hysteresis off temperature', c: 'boilhystoff' },
{ v: 0, u: 2, n: 'burner current power' },
{ v: 317694, u: 16, n: 'burner starts' },
{ v: 524115, u: 7, n: 'total burner operating time' },
{ v: 424286, u: 7, n: 'total heat operating time' },
{ v: 4571225, u: 7, n: 'total UBA operating time' },
{ v: '1C(210) 06.06.2020 12:07', u: 0, n: 'last error code' },
{ v: '0H', u: 0, n: 'service code' },
{ v: 203, u: 0, n: 'service code number' },
{ v: ' ', u: 0, n: 'maintenance message' },
{
v: 'off',
u: 0,
n: 'maintenance scheduled',
c: 'maintenance',
l: ['off', 'time', 'date'],
},
{ v: 6000, u: 6, n: 'maintenance set time', c: 'maintenancetime' },
{ v: '01.01.2012', u: 0, n: 'maintenance set date', c: 'maintenancedate' },
{ v: 60, u: 1, n: 'ww selected temperature', c: 'wwseltemp' },
{ v: 62, u: 1, n: 'ww set temperature' },
{ v: 'flow', u: 0, n: 'ww type' },
{
v: 6000,
u: 6,
n: 'maintenance set time',
c: '',
},
{
v: 60,
u: 1,
n: '(ww) selected temperature',
c: '',
},
{
v: 62,
u: 1,
n: '(ww) set temperature',
c: 'wwsettemp',
},
{
v: 'flow',
v: 'eco',
u: 0,
n: '(ww) type',
c: '',
},
{
v: 'hot',
u: 0,
n: '(ww) comfort',
n: 'ww comfort',
c: 'wwcomfort',
l: ['hot', 'eco', 'intelligent'],
},
{ v: 40, u: 0, n: 'ww flow temperature offset', c: 'wwflowtempoffset' },
{ v: 100, u: 2, n: 'ww max power', c: 'wwmaxpower' },
{
v: 40,
v: 'off',
u: 0,
n: '(ww) flow temperature offset',
c: 'wwflowtempoffset',
},
{
v: 100,
u: 2,
n: '(ww) max power',
c: 'wwmaxpower',
},
{
v: false,
u: 16,
n: '(ww) circulation pump available',
n: 'ww circulation pump available',
c: 'wwcircpump',
l: ['off', 'on'],
},
{ v: '3-way valve', u: 0, n: 'ww charging type' },
{ v: -5, u: 1, n: 'ww hysteresis on temperature', c: 'wwhyston' },
{ v: 0, u: 1, n: 'ww hysteresis off temperature', c: 'wwhystoff' },
{ v: 70, u: 1, n: 'ww disinfection temperature', c: 'wwdisinfectiontemp' },
{
v: 'charge pump',
v: 'off',
u: 0,
n: '(ww) charging type',
c: '',
},
{
v: 70,
u: 1,
n: '(ww) disinfection temperature',
c: 'wwdisinfectiontemp',
n: 'ww circulation pump frequency',
c: 'wwcircmode',
l: [
'off',
'1x3min',
'2x3min',
'3x3min',
'4x3min',
'5x3min',
'6x3min',
'continuous',
],
},
{
v: 'off',
u: 0,
n: '(ww) circulation pump frequency',
c: 'wwcircmode',
},
{
v: false,
u: 16,
n: '(ww) circulation active',
n: 'ww circulation active',
c: 'wwcirc',
l: ['off', 'on'],
},
{ v: 37.1, u: 1, n: 'ww current intern temperature' },
{ v: 0, u: 3, n: 'ww current tap water flow' },
{ v: 37.2, u: 1, n: 'ww storage intern temperature' },
{ v: 'on', u: 0, n: 'ww activated', c: 'wwactivated', l: ['off', 'on'] },
{
v: 44.4,
u: 1,
n: '(ww) current intern temperature',
c: '',
},
{
v: 0,
u: 3,
n: '(ww) current tap water flow',
c: '',
},
{
v: 44.4,
u: 1,
n: '(ww) storage intern temperature',
c: '',
},
{
v: true,
u: 16,
n: '(ww) activated',
c: 'wwactivated',
},
{
v: false,
u: 16,
n: '(ww) one time charging',
v: 'off',
u: 0,
n: 'ww one time charging',
c: 'wwonetime',
l: ['off', 'on'],
},
{
v: false,
u: 16,
n: '(ww) disinfecting',
c: '',
},
{
v: false,
u: 16,
n: '(ww) charging',
c: '',
},
{
v: false,
u: 16,
n: '(ww) recharging',
c: '',
},
{
v: true,
u: 16,
n: '(ww) temperature ok',
c: '',
},
{
v: false,
u: 16,
n: '(ww) active',
c: '',
},
{
v: true,
u: 16,
n: '(ww) heating',
c: '',
},
{
v: 268671,
u: 15,
n: '(ww) # starts',
c: '',
},
{
v: 95399,
u: 7,
n: '(ww) active time',
c: '',
v: 'off',
u: 0,
n: 'ww disinfection',
c: 'wwdisinfect',
l: ['off', 'on'],
},
{ v: 'off', u: 0, n: 'ww charging' },
{ v: 'off', u: 0, n: 'ww recharging' },
{ v: 'on', u: 0, n: 'ww temperature ok' },
{ v: 'off', u: 0, n: 'ww active' },
{ v: 'on', u: 0, n: 'ww heating' },
{ v: 282323, u: 16, n: 'ww starts' },
{ v: 99829, u: 7, n: 'ww active time' },
],
}

View File

@@ -572,22 +572,29 @@ void EMSdevice::register_device_value(uint8_t tag,
register_device_value(tag, value_p, type, options, name, uom, nullptr, 0, 0);
}
// looks up the uom (suffix) for a given key from the device value table
// looks up the UOM for a given key from the device value table
const std::string EMSdevice::get_value_uom(const char * key) {
// the key may have a suffix at the start which is between brackets. remove it.
// the key may have a TAG string prefixed at the beginning. If so, remove it
char new_key[80];
strlcpy(new_key, key, sizeof(new_key));
char * p = new_key;
if (key[0] == '(') {
while ((*p++ != ')') && (*p != '\0'))
;
p++;
char * key_p = new_key;
size_t sz = sizeof(DeviceValueTAG_s) / sizeof(__FlashStringHelper *);
for (uint8_t i = 0; i < sz; i++) {
auto tag = uuid::read_flash_string(DeviceValueTAG_s[i]);
if (!tag.empty()) {
std::string key2 = key; // copy char to a std::string
if ((key2.find(tag) != std::string::npos) && (key[tag.length()] == ' ')) {
key_p += tag.length() + 1; // remove the tag
break;
}
}
}
// find the key (p) in the name
// look up key in our device value list
for (const auto & dv : devicevalues_) {
if (dv_is_visible(dv)) {
if (uuid::read_flash_string(dv.full_name) == p) {
if (uuid::read_flash_string(dv.full_name) == key_p) {
// ignore TIME since "minutes" is already added to the string value
if ((dv.uom == DeviceValueUOM::NONE) || (dv.uom == DeviceValueUOM::MINUTES)) {
break;
@@ -715,6 +722,10 @@ void EMSdevice::generate_values_json_web(JsonObject & output) {
}
}
}
#if defined(EMSESP_DEBUG)
// serializeJson(data, Serial); // debug only
#endif
}
// builds json with specific single device value information
@@ -1006,37 +1017,40 @@ bool EMSdevice::generate_values_json(JsonObject & output, const uint8_t tag_filt
}
}
// always convert temperatures to floats
bool make_float = (divider || (dv.uom == DeviceValueUOM::DEGREES));
// INT
if ((dv.type == DeviceValueType::INT) && Helpers::hasValue(*(int8_t *)(dv.value_p))) {
if (divider) {
if (make_float) {
json[name] = Helpers::round2(*(int8_t *)(dv.value_p), divider);
} else {
json[name] = *(int8_t *)(dv.value_p) * factor;
}
has_value = true;
} else if ((dv.type == DeviceValueType::UINT) && Helpers::hasValue(*(uint8_t *)(dv.value_p))) {
if (divider) {
if (make_float) {
json[name] = Helpers::round2(*(uint8_t *)(dv.value_p), divider);
} else {
json[name] = *(uint8_t *)(dv.value_p) * factor;
}
has_value = true;
} else if ((dv.type == DeviceValueType::SHORT) && Helpers::hasValue(*(int16_t *)(dv.value_p))) {
if (divider) {
if (make_float) {
json[name] = Helpers::round2(*(int16_t *)(dv.value_p), divider);
} else {
json[name] = *(int16_t *)(dv.value_p) * factor;
}
has_value = true;
} else if ((dv.type == DeviceValueType::USHORT) && Helpers::hasValue(*(uint16_t *)(dv.value_p))) {
if (divider) {
if (make_float) {
json[name] = Helpers::round2(*(uint16_t *)(dv.value_p), divider);
} else {
json[name] = *(uint16_t *)(dv.value_p) * factor;
}
has_value = true;
} else if ((dv.type == DeviceValueType::ULONG) && Helpers::hasValue(*(uint32_t *)(dv.value_p))) {
if (divider) {
if (make_float) {
json[name] = Helpers::round2(*(uint32_t *)(dv.value_p), divider);
} else {
json[name] = *(uint32_t *)(dv.value_p) * factor;

View File

@@ -139,6 +139,7 @@ char * Helpers::render_boolean(char * result, bool value) {
}
// render for native char strings
// format is not used
char * Helpers::render_value(char * result, const char * value, uint8_t format __attribute__((unused))) {
strcpy(result, value);
return result;
@@ -251,6 +252,7 @@ char * Helpers::render_value(char * result, const int16_t value, const uint8_t f
}
// uint16: convert unsigned short (two bytes) to text string and prints it
// format: 0=no division, other divide by the value given and render with a decimal point
char * Helpers::render_value(char * result, const uint16_t value, const uint8_t format) {
if (!hasValue(value)) {
return nullptr;
@@ -260,6 +262,7 @@ char * Helpers::render_value(char * result, const uint16_t value, const uint8_t
}
// int8: convert signed byte to text string and prints it
// format: 0=no division, other divide by the value given and render with a decimal point
char * Helpers::render_value(char * result, const int8_t value, const uint8_t format) {
if (!hasValue(value)) {
return nullptr;
@@ -269,6 +272,7 @@ char * Helpers::render_value(char * result, const int8_t value, const uint8_t fo
}
// uint32: render long (4 byte) unsigned values
// format: 0=no division, other divide by the value given and render with a decimal point
char * Helpers::render_value(char * result, const uint32_t value, const uint8_t format) {
if (!hasValue(value)) {
return nullptr;

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.3.0b5"
#define EMSESP_APP_VERSION "3.3.0b6"