Merge pull request #941 from proddy/dev

minor cleanup
This commit is contained in:
Proddy
2023-02-04 14:09:20 +01:00
committed by GitHub
8 changed files with 50 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
{
"adapter": "react",
"baseLocale": "pl",
"$schema": "https://unpkg.com/typesafe-i18n@5.21.0/schema/typesafe-i18n.json"
}
"adapter": "react",
"baseLocale": "pl",
"$schema": "https://unpkg.com/typesafe-i18n@5.22.0/schema/typesafe-i18n.json"
}

View File

@@ -12,15 +12,15 @@
"@emotion/styled": "^11.10.5",
"@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.6",
"@table-library/react-table-library": "4.0.23",
"@mui/material": "^5.11.7",
"@table-library/react-table-library": "4.0.24",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.18",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/react-router-dom": "^5.3.3",
"async-validator": "^4.2.5",
"axios": "^1.2.6",
"axios": "^1.3.2",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"notistack": "^2.0.8",
@@ -32,7 +32,7 @@
"react-router-dom": "^6.8.0",
"react-scripts": "5.0.1",
"sockette": "^2.0.6",
"typesafe-i18n": "^5.21.0",
"typesafe-i18n": "^5.22.0",
"typescript": "^4.9.5"
},
"devDependencies": {
@@ -3775,9 +3775,9 @@
}
},
"node_modules/@table-library/react-table-library": {
"version": "4.0.23",
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.23.tgz",
"integrity": "sha512-o2L/fqhwQNxsNbbm3LIiyZzEwaTslhG1tY9ArkYdS0xJyRhJxcOLfbJ3+dcnOOn+aIJpmPmQH+gr7RYJC0P8uw==",
"version": "4.0.24",
"resolved": "https://registry.npmjs.org/@table-library/react-table-library/-/react-table-library-4.0.24.tgz",
"integrity": "sha512-tOeKermNhSDKGVvzBlF8gtLVWl+lWbCHk0XH/7s1ybZ9XI8TXpogzXavyRfObGFAIyeazr7Qy5bWGWnE4uueUg==",
"dependencies": {
"clsx": "1.1.1",
"react-virtualized-auto-sizer": "1.0.6",
@@ -5077,9 +5077,9 @@
}
},
"node_modules/axios": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.2.6.tgz",
"integrity": "sha512-rC/7F08XxZwjMV4iuWv+JpD3E0Ksqg9nac4IIg6RwNuF0JTeWoCo/mBNG54+tNhhI11G3/VDRbdDQTs9hGp4pQ==",
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.3.2.tgz",
"integrity": "sha512-1M3O703bYqYuPhbHeya5bnhpYVsDDRyQSabNja04mZtboLNSuZ4YrltestrLXfHgmzua4TpUqRiVKbiQuo2epw==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
@@ -16790,9 +16790,9 @@
}
},
"node_modules/typesafe-i18n": {
"version": "5.21.0",
"resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.21.0.tgz",
"integrity": "sha512-hfJQ7j0jvz21s2Iiv92Nx7rGyEQZJnVaQ64ek6Bn3IDaADiGFoUbSc7ZPYqeI9iTO8mOe35ACJ9MTn2cEp1ECA==",
"version": "5.22.0",
"resolved": "https://registry.npmjs.org/typesafe-i18n/-/typesafe-i18n-5.22.0.tgz",
"integrity": "sha512-I6dH/lmBEOOMdLmHbxOZK4x7wQrf7ZrgT2ynTzcJZAIJIfj0QdU8ncKOfrMOuTf3ddpe/MLSH1NKLxfPS7l2dQ==",
"bin": {
"typesafe-i18n": "cli/typesafe-i18n.mjs"
},

View File

@@ -8,15 +8,15 @@
"@emotion/styled": "^11.10.5",
"@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.6",
"@table-library/react-table-library": "4.0.23",
"@mui/material": "^5.11.7",
"@table-library/react-table-library": "4.0.24",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.18",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/react-router-dom": "^5.3.3",
"async-validator": "^4.2.5",
"axios": "^1.2.6",
"axios": "^1.3.2",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"notistack": "^2.0.8",
@@ -28,7 +28,7 @@
"react-router-dom": "^6.8.0",
"react-scripts": "5.0.1",
"sockette": "^2.0.6",
"typesafe-i18n": "^5.21.0",
"typesafe-i18n": "^5.22.0",
"typescript": "^4.9.5"
},
"scripts": {

View File

@@ -499,7 +499,7 @@ const SettingsCustomization: FC = () => {
value={getMaskString(de.m)}
onChange={(event, mask) => {
de.m = getMaskNumber(mask);
if (de.n === '' && (de.m & DeviceEntityMask.DV_READONLY)) {
if (de.n === '' && de.m & DeviceEntityMask.DV_READONLY) {
de.m = de.m | DeviceEntityMask.DV_WEB_EXCLUDE;
}
if (de.m & DeviceEntityMask.DV_WEB_EXCLUDE) {
@@ -534,7 +534,7 @@ const SettingsCustomization: FC = () => {
isSet={(de.m & DeviceEntityMask.DV_WEB_EXCLUDE) === DeviceEntityMask.DV_WEB_EXCLUDE}
/>
</ToggleButton>
<ToggleButton value="128" >
<ToggleButton value="128">
<OptionIcon
type="deleted"
isSet={(de.m & DeviceEntityMask.DV_DELETED) === DeviceEntityMask.DV_DELETED}
@@ -543,10 +543,10 @@ const SettingsCustomization: FC = () => {
</ToggleButtonGroup>
)}
</Cell>
<Cell>{!deviceEntity && (formatName(de))}</Cell>
<Cell>{!deviceEntity && formatName(de)}</Cell>
<Cell>{!deviceEntity && !(de.m & DeviceEntityMask.DV_READONLY) && formatValue(de.mi)}</Cell>
<Cell>{!deviceEntity && !(de.m & DeviceEntityMask.DV_READONLY) && formatValue(de.ma)}</Cell>
<Cell>{!deviceEntity && (formatValue(de.v))}</Cell>
<Cell>{!deviceEntity && formatValue(de.v)}</Cell>
</Row>
))}
</Body>

View File

@@ -127,6 +127,12 @@ network_settings = {
enableMDNS: true,
enableCORS: false,
CORSOrigin: '*',
enableIPv6: false,
local_ip: '',
gateway_ip: '',
subnet_mask: '',
dns_ip_1: '',
dns_ip_2: '',
}
const network_status = {
status: 3,
@@ -348,6 +354,7 @@ settings = {
bool_format: 1,
bool_dashboard: 1,
enum_format: 1,
fahrenheit: false,
}
const emsesp_devices = {
@@ -411,6 +418,7 @@ const emsesp_coredata = {
e: 3,
},
],
s_n: 'Sensors',
active_sensors: 8,
analog_enabled: true,
}
@@ -589,7 +597,7 @@ const emsesp_devicedata_4 = {
],
}
// CUSTOMIZATION
// CUSTOMIZATIONS
const emsesp_deviceentities_1 = [
{
@@ -934,7 +942,10 @@ rest_server.post(EMSESP_DEVICEENTITIES_ENDPOINT, (req, res) => {
function updateMask(entity, de, dd) {
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 new_custom_name = shortname_with_customname.split('|')[1]
@@ -961,6 +972,7 @@ function updateMask(entity, de, dd) {
// see if the custom name has changed
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) {
changed = true
new_fullname = new_custom_name
@@ -976,6 +988,7 @@ function updateMask(entity, de, dd) {
de[de_objIndex].m = current_mask
de[de_objIndex].cn = 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:')

View File

@@ -181,11 +181,11 @@ class DeviceValue {
bool hasValue() const;
bool get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max);
void set_custom_minmax();
bool get_custom_min(int16_t & val);
bool get_custom_max(uint16_t & val);
std::string get_custom_fullname() const;
std::string get_fullname() const;
void set_custom_minmax();
bool get_custom_min(int16_t & val);
bool get_custom_max(uint16_t & val);
std::string get_custom_fullname() const;
std::string get_fullname() const;
static std::string get_name(std::string & entity);
// dv state flags

View File

@@ -1078,7 +1078,7 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, const
name = "Modem";
device_type = DeviceType::CONNECT;
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CONVERTER) {
name = "Converter"; // generic
name = "Converter"; // generic
} else if (device_id == EMSdevice::EMS_DEVICE_ID_CLOCK) {
name = "Clock"; // generic
device_type = DeviceType::CONTROLLER;

View File

@@ -629,10 +629,10 @@ void Mqtt::ha_status() {
dev["sw"] = "v" + std::string(EMSESP_APP_VERSION);
dev["mf"] = "proddy";
dev["mdl"] = "EMS-ESP";
if (EMSESP::system_.ethernet_connected())
dev["cu"] = "http://" + ETH.localIP().toString();
else
dev["cu"] = "http://" + WiFi.localIP().toString();
#ifndef EMSESP_STANDALONE
dev["cu"] = "http://" + (EMSESP::system_.ethernet_connected() ? ETH.localIP().toString() : WiFi.localIP().toString());
#endif
JsonArray ids = dev.createNestedArray("ids");
ids.add("ems-esp");