Merge pull request #429 from proddy/dev

updates to customization screen
This commit is contained in:
Proddy
2022-03-30 13:16:40 +02:00
committed by GitHub
3 changed files with 33 additions and 28 deletions

View File

@@ -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 (
<Dialog open={deviceValue !== undefined} onClose={() => setDeviceValue(undefined)}>
<DialogTitle>Change Value</DialogTitle>
<DialogTitle>{isCmdOnly(deviceValue) ? 'Run Command' : 'Change Value'}</DialogTitle>
<DialogContent dividers>
{deviceValue.l && (
<ValidatedTextField
@@ -506,7 +508,6 @@ const DashboardData: FC = () => {
{hasMask(dv.n, DeviceEntityMask.DV_API_MQTT_EXCLUDE) && (
<CommentsDisabledOutlinedIcon color="primary" sx={{ fontSize: 12 }} />
)}
{dv.v === undefined && dv.c && <PlayArrowIcon color="primary" sx={{ fontSize: 14 }} />}
</>
);
@@ -519,21 +520,13 @@ const DashboardData: FC = () => {
<TableHead>
<TableRow>
<StyledTableCell padding="checkbox" style={{ width: 18 }}></StyledTableCell>
<StyledTableCell align="left">ENTITY NAME/COMMAND</StyledTableCell>
<StyledTableCell align="left">ENTITY NAME</StyledTableCell>
<StyledTableCell align="right">VALUE</StyledTableCell>
</TableRow>
</TableHead>
<TableBody>
{deviceData.data.map((dv, i) => (
<TableRow
key={i}
onClick={() => sendCommand(dv)}
// sx={
// hasMask(dv.n, DeviceEntityMask.DV_FAVORITE)
// ? { backgroundColor: '#334900' }
// : { backgroundColor: 'black' }
// }
>
<StyledTableRow key={i} onClick={() => sendCommand(dv)}>
<StyledTableCell padding="checkbox">
{dv.c && me.admin && !hasMask(dv.n, DeviceEntityMask.DV_READONLY) && (
<IconButton size="small">
@@ -544,8 +537,10 @@ const DashboardData: FC = () => {
<StyledTableCell component="th" scope="row">
{renderNameCell(dv)}
</StyledTableCell>
<StyledTableCell align="right">{formatValue(dv.v, dv.u)}</StyledTableCell>
</TableRow>
<StyledTableCell align="right">
{isCmdOnly(dv) ? <PlayArrowIcon color="primary" sx={{ fontSize: 14 }} /> : formatValue(dv.v, dv.u)}
</StyledTableCell>
</StyledTableRow>
))}
</TableBody>
</Table>

View File

@@ -116,14 +116,27 @@ const SettingsCustomization: FC = () => {
return (
<>
<Box mb={2} color="warning.main">
<Typography variant="body2">
You can mark an entity as a favorite to be listed first in the Dashboard (
<FavoriteBorderOutlinedIcon color="success" fontSize="small" />) ,or remove it entirely from the Dashboard (
<VisibilityOffOutlinedIcon color="action" fontSize="small" />) ,or disable it's write operation (
<EditOffOutlinedIcon color="action" fontSize="small" />) or have it excluded from the MQTT and API outputs (
<Box mb={1} color="warning.main">
Select a device and customize each entity using the options:
<Typography display="block" variant="body2" sx={{ alignItems: 'center', display: 'flex' }}>
&nbsp;
<FavoriteBorderOutlinedIcon color="success" fontSize="small" />
&nbsp;mark it as favorite to be listed at the top of the Dashboard
</Typography>
<Typography display="block" variant="body2" sx={{ alignItems: 'center', display: 'flex' }}>
&nbsp;
<VisibilityOffOutlinedIcon color="action" fontSize="small" />
&nbsp;hide from the Dashboard
</Typography>
<Typography display="block" variant="body2" sx={{ alignItems: 'center', display: 'flex' }}>
&nbsp;
<EditOffOutlinedIcon color="action" fontSize="small" />
&nbsp;make it read-only (if it has write operation available)
</Typography>
<Typography display="block" variant="body2" sx={{ alignItems: 'center', display: 'flex' }}>
&nbsp;
<CommentsDisabledOutlinedIcon color="action" fontSize="small" />
).
&nbsp;excluded it from MQTT and API outputs
</Typography>
</Box>
<ValidatedTextField

View File

@@ -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_) {