From 9e5fdb7cb137743d3dd61bbb56b9635e547d4096 Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 30 Mar 2022 13:15:25 +0200 Subject: [PATCH 1/3] use boolean rendering to fix Web errors with enums --- src/emsdevice.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index ea0db7ba0..7236f74ae 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -725,8 +725,9 @@ void EMSdevice::generate_values_web(JsonObject & output) { } } else if (dv.type == DeviceValueType::BOOL) { JsonArray l = obj.createNestedArray("l"); - l.add("off"); - l.add("on"); + char result[10]; + l.add(Helpers::render_boolean(result, false)); + l.add(Helpers::render_boolean(result, true)); } // add command help template else if (dv.type == DeviceValueType::STRING || dv.type == DeviceValueType::CMD) { @@ -861,10 +862,6 @@ void EMSdevice::mask_entity(const std::string & entity_id) { for (auto & dv : devicevalues_) { std::string entity = dv.tag < DeviceValueTAG::TAG_HC1 ? read_flash_string(dv.short_name) : tag_to_string(dv.tag) + "/" + read_flash_string(dv.short_name); if (entity == entity_id.substr(2)) { -#if defined(EMSESP_USE_SERIAL) - Serial.print("mask_entity() Removing Visible for device value: "); - Serial.println(read_flash_string(dv.full_name).c_str()); -#endif dv.state = (dv.state & 0x0F) | (flag << 4); // set state high bits to flag, turn off active and ha flags return; } @@ -1217,7 +1214,7 @@ bool EMSdevice::generate_values(JsonObject & output, const uint8_t tag_filter, c return has_values; } -// remove the Home Assistant configs for each device value/entity if its not visible or active +// remove the Home Assistant configs for each device value/entity if its not visible or active or marked as read-only // this is called when an MQTT publish is done via an EMS Device in emsesp.cpp::publish_device_values() void EMSdevice::mqtt_ha_entity_config_remove() { for (auto & dv : devicevalues_) { From cb9ddb299ab12073d6415a32504d2b4bcf4d6a13 Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 30 Mar 2022 13:15:38 +0200 Subject: [PATCH 2/3] show commands differently --- interface/src/project/DashboardData.tsx | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/interface/src/project/DashboardData.tsx b/interface/src/project/DashboardData.tsx index a67b05c9c..21cf4072c 100644 --- a/interface/src/project/DashboardData.tsx +++ b/interface/src/project/DashboardData.tsx @@ -158,6 +158,8 @@ const DashboardData: FC = () => { } }; + const isCmdOnly = (dv: DeviceValue) => dv.v === undefined && dv.c; + function formatValue(value: any, uom: number) { if (value === undefined) { return ''; @@ -218,7 +220,7 @@ const DashboardData: FC = () => { if (deviceValue) { return ( setDeviceValue(undefined)}> - Change Value + {isCmdOnly(deviceValue) ? 'Run Command' : 'Change Value'} {deviceValue.l && ( { {hasMask(dv.n, DeviceEntityMask.DV_API_MQTT_EXCLUDE) && ( )} - {dv.v === undefined && dv.c && } ); @@ -519,21 +520,13 @@ const DashboardData: FC = () => { - ENTITY NAME/COMMAND + ENTITY NAME VALUE {deviceData.data.map((dv, i) => ( - sendCommand(dv)} - // sx={ - // hasMask(dv.n, DeviceEntityMask.DV_FAVORITE) - // ? { backgroundColor: '#334900' } - // : { backgroundColor: 'black' } - // } - > + sendCommand(dv)}> {dv.c && me.admin && !hasMask(dv.n, DeviceEntityMask.DV_READONLY) && ( @@ -544,8 +537,10 @@ const DashboardData: FC = () => { {renderNameCell(dv)} - {formatValue(dv.v, dv.u)} - + + {isCmdOnly(dv) ? : formatValue(dv.v, dv.u)} + + ))} From 84e21ab9924d233a95a191ed8571041a209c984e Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 30 Mar 2022 13:15:48 +0200 Subject: [PATCH 3/3] layout changes to help text --- .../src/project/SettingsCustomization.tsx | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/interface/src/project/SettingsCustomization.tsx b/interface/src/project/SettingsCustomization.tsx index 94913af6f..14a0ceb43 100644 --- a/interface/src/project/SettingsCustomization.tsx +++ b/interface/src/project/SettingsCustomization.tsx @@ -116,14 +116,27 @@ const SettingsCustomization: FC = () => { return ( <> - - - You can mark an entity as a favorite to be listed first in the Dashboard ( - ) ,or remove it entirely from the Dashboard ( - ) ,or disable it's write operation ( - ) or have it excluded from the MQTT and API outputs ( + + Select a device and customize each entity using the options: + +   + +  mark it as favorite to be listed at the top of the Dashboard + + +   + +  hide from the Dashboard + + +   + +  make it read-only (if it has write operation available) + + +   - ). +  excluded it from MQTT and API outputs