mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
fix bug with custom name
This commit is contained in:
@@ -127,6 +127,12 @@ network_settings = {
|
|||||||
enableMDNS: true,
|
enableMDNS: true,
|
||||||
enableCORS: false,
|
enableCORS: false,
|
||||||
CORSOrigin: '*',
|
CORSOrigin: '*',
|
||||||
|
enableIPv6: false,
|
||||||
|
local_ip: '',
|
||||||
|
gateway_ip: '',
|
||||||
|
subnet_mask: '',
|
||||||
|
dns_ip_1: '',
|
||||||
|
dns_ip_2: '',
|
||||||
}
|
}
|
||||||
const network_status = {
|
const network_status = {
|
||||||
status: 3,
|
status: 3,
|
||||||
@@ -348,6 +354,7 @@ settings = {
|
|||||||
bool_format: 1,
|
bool_format: 1,
|
||||||
bool_dashboard: 1,
|
bool_dashboard: 1,
|
||||||
enum_format: 1,
|
enum_format: 1,
|
||||||
|
fahrenheit: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const emsesp_devices = {
|
const emsesp_devices = {
|
||||||
@@ -411,6 +418,7 @@ const emsesp_coredata = {
|
|||||||
e: 3,
|
e: 3,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
s_n: 'Sensors',
|
||||||
active_sensors: 8,
|
active_sensors: 8,
|
||||||
analog_enabled: true,
|
analog_enabled: true,
|
||||||
}
|
}
|
||||||
@@ -589,7 +597,7 @@ const emsesp_devicedata_4 = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
// CUSTOMIZATION
|
// CUSTOMIZATIONS
|
||||||
|
|
||||||
const emsesp_deviceentities_1 = [
|
const emsesp_deviceentities_1 = [
|
||||||
{
|
{
|
||||||
@@ -934,7 +942,10 @@ rest_server.post(EMSESP_DEVICEENTITIES_ENDPOINT, (req, res) => {
|
|||||||
|
|
||||||
function updateMask(entity, de, dd) {
|
function updateMask(entity, de, dd) {
|
||||||
const current_mask = parseInt(entity.slice(0, 2), 16)
|
const current_mask = parseInt(entity.slice(0, 2), 16)
|
||||||
const shortname_with_customname = entity.slice(2)
|
|
||||||
|
// strip of any min/max ranges
|
||||||
|
const shortname_with_customname = entity.slice(2).split('>')[0]
|
||||||
|
|
||||||
const shortname = shortname_with_customname.split('|')[0]
|
const shortname = shortname_with_customname.split('|')[0]
|
||||||
const new_custom_name = shortname_with_customname.split('|')[1]
|
const new_custom_name = shortname_with_customname.split('|')[1]
|
||||||
|
|
||||||
@@ -961,6 +972,7 @@ function updateMask(entity, de, dd) {
|
|||||||
|
|
||||||
// see if the custom name has changed
|
// see if the custom name has changed
|
||||||
const old_custom_name = dd.data[dd_objIndex].cn
|
const old_custom_name = dd.data[dd_objIndex].cn
|
||||||
|
console.log('comparing old ' + old_custom_name + ' with new ' + new_custom_name)
|
||||||
if (old_custom_name !== new_custom_name) {
|
if (old_custom_name !== new_custom_name) {
|
||||||
changed = true
|
changed = true
|
||||||
new_fullname = new_custom_name
|
new_fullname = new_custom_name
|
||||||
@@ -976,6 +988,7 @@ function updateMask(entity, de, dd) {
|
|||||||
de[de_objIndex].m = current_mask
|
de[de_objIndex].m = current_mask
|
||||||
de[de_objIndex].cn = new_fullname
|
de[de_objIndex].cn = new_fullname
|
||||||
dd.data[dd_objIndex].id = current_mask.toString(16).padStart(2, '0') + new_fullname
|
dd.data[dd_objIndex].id = current_mask.toString(16).padStart(2, '0') + new_fullname
|
||||||
|
dd.data[dd_objIndex].cn = new_fullname
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('new dd:')
|
console.log('new dd:')
|
||||||
|
|||||||
Reference in New Issue
Block a user