mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
add min/max to customization table #686
This commit is contained in:
@@ -66,7 +66,7 @@ const SettingsCustomization: FC = () => {
|
|||||||
|
|
||||||
const entities_theme = useTheme({
|
const entities_theme = useTheme({
|
||||||
Table: `
|
Table: `
|
||||||
--data-table-library_grid-template-columns: 120px repeat(1, minmax(0, 1fr)) 120px;
|
--data-table-library_grid-template-columns: 120px repeat(1, minmax(80px, 1fr)) 40px 40px 120px;
|
||||||
`,
|
`,
|
||||||
BaseRow: `
|
BaseRow: `
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -75,6 +75,12 @@ const SettingsCustomization: FC = () => {
|
|||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
BaseCell: `
|
BaseCell: `
|
||||||
|
&:nth-of-type(3) {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
&:nth-of-type(4) {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
@@ -122,6 +128,12 @@ const SettingsCustomization: FC = () => {
|
|||||||
&:nth-of-type(2) {
|
&:nth-of-type(2) {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
&:nth-of-type(3) {
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
|
&:nth-of-type(4) {
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
&:last-of-type {
|
&:last-of-type {
|
||||||
padding-right: 8px;
|
padding-right: 8px;
|
||||||
}
|
}
|
||||||
@@ -446,6 +458,8 @@ const SettingsCustomization: FC = () => {
|
|||||||
{LL.NAME()}
|
{LL.NAME()}
|
||||||
</Button>
|
</Button>
|
||||||
</HeaderCell>
|
</HeaderCell>
|
||||||
|
<HeaderCell stiff>min</HeaderCell>
|
||||||
|
<HeaderCell stiff>max</HeaderCell>
|
||||||
<HeaderCell resize>{LL.VALUE(0)}</HeaderCell>
|
<HeaderCell resize>{LL.VALUE(0)}</HeaderCell>
|
||||||
</HeaderRow>
|
</HeaderRow>
|
||||||
</Header>
|
</Header>
|
||||||
@@ -497,6 +511,8 @@ const SettingsCustomization: FC = () => {
|
|||||||
</ToggleButtonGroup>
|
</ToggleButtonGroup>
|
||||||
</Cell>
|
</Cell>
|
||||||
<Cell>{formatName(de)}</Cell>
|
<Cell>{formatName(de)}</Cell>
|
||||||
|
<Cell>{!(de.m & DeviceEntityMask.DV_READONLY) && (formatValue(de.mi))}</Cell>
|
||||||
|
<Cell>{!(de.m & DeviceEntityMask.DV_READONLY) && (formatValue(de.ma))}</Cell>
|
||||||
<Cell>{formatValue(de.v)}</Cell>
|
<Cell>{formatValue(de.v)}</Cell>
|
||||||
</Row>
|
</Row>
|
||||||
))}
|
))}
|
||||||
@@ -626,7 +642,7 @@ const SettingsCustomization: FC = () => {
|
|||||||
onChange={updateValue(setDeviceEntity)}
|
onChange={updateValue(setDeviceEntity)}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
{typeof de.v === 'number' && de.w && (
|
{typeof de.v === 'number' && de.w && !(de.m & DeviceEntityMask.DV_READONLY) && (
|
||||||
<>
|
<>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<TextField
|
<TextField
|
||||||
|
|||||||
@@ -947,15 +947,14 @@ void EMSdevice::generate_values_web_customization(JsonArray & output) {
|
|||||||
obj["m"] = dv.state >> 4; // send back the mask state. We're only interested in the high nibble
|
obj["m"] = dv.state >> 4; // send back the mask state. We're only interested in the high nibble
|
||||||
obj["w"] = dv.has_cmd; // if writable
|
obj["w"] = dv.has_cmd; // if writable
|
||||||
|
|
||||||
if (dv.has_cmd) {
|
if (dv.has_cmd && (obj["v"].is<float>() || obj["v"].is<int>())) {
|
||||||
// set the custom min and max values if there are any
|
// set the min and max values if there are any and if entity has a value
|
||||||
int16_t dv_set_min;
|
int16_t dv_set_min;
|
||||||
uint16_t dv_set_max;
|
uint16_t dv_set_max;
|
||||||
if (dv.get_custom_min(dv_set_min)) {
|
if (dv.get_min_max(dv_set_min, dv_set_max)) {
|
||||||
obj["mi"] = fahrenheit ? (int)(dv_set_min * 1.8 + 32 * (fahrenheit - 1)) : dv_set_min;
|
char s[10];
|
||||||
}
|
obj["mi"] = Helpers::render_value(s, dv_set_min, 0, fahrenheit);
|
||||||
if (dv.get_custom_max(dv_set_max)) {
|
obj["ma"] = Helpers::render_value(s, dv_set_max, 0, fahrenheit);
|
||||||
obj["ma"] = fahrenheit ? (int)(dv_set_max * 1.8 + 32 * (fahrenheit - 1)) : dv_set_max;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,13 +287,13 @@ bool DeviceValue::get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max) {
|
|||||||
|
|
||||||
if (type == DeviceValueType::USHORT) {
|
if (type == DeviceValueType::USHORT) {
|
||||||
dv_set_min = Helpers::transformNumFloat(0, numeric_operator, fahrenheit);
|
dv_set_min = Helpers::transformNumFloat(0, numeric_operator, fahrenheit);
|
||||||
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_USHORT_NOTSET, numeric_operator, fahrenheit);
|
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_USHORT_NOTSET - 1, numeric_operator, fahrenheit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DeviceValueType::SHORT) {
|
if (type == DeviceValueType::SHORT) {
|
||||||
dv_set_min = Helpers::transformNumFloat(-EMS_VALUE_SHORT_NOTSET, numeric_operator, fahrenheit);
|
dv_set_min = Helpers::transformNumFloat(-EMS_VALUE_SHORT_NOTSET + 1, numeric_operator, fahrenheit);
|
||||||
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_SHORT_NOTSET, numeric_operator, fahrenheit);
|
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_SHORT_NOTSET - 1, numeric_operator, fahrenheit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ bool DeviceValue::get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max) {
|
|||||||
if (uom == DeviceValueUOM::PERCENT) {
|
if (uom == DeviceValueUOM::PERCENT) {
|
||||||
dv_set_max = 100;
|
dv_set_max = 100;
|
||||||
} else {
|
} else {
|
||||||
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_UINT_NOTSET, numeric_operator, fahrenheit);
|
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_UINT_NOTSET - 1, numeric_operator, fahrenheit);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -311,19 +311,19 @@ bool DeviceValue::get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max) {
|
|||||||
dv_set_min = -100;
|
dv_set_min = -100;
|
||||||
dv_set_max = 100;
|
dv_set_max = 100;
|
||||||
} else {
|
} else {
|
||||||
dv_set_min = Helpers::transformNumFloat(-EMS_VALUE_INT_NOTSET, numeric_operator, fahrenheit);
|
dv_set_min = Helpers::transformNumFloat(-EMS_VALUE_INT_NOTSET + 1, numeric_operator, fahrenheit);
|
||||||
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_INT_NOTSET, numeric_operator, fahrenheit);
|
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_INT_NOTSET - 1, numeric_operator, fahrenheit);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DeviceValueType::ULONG) {
|
if (type == DeviceValueType::ULONG) {
|
||||||
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_ULONG_NOTSET, numeric_operator);
|
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_ULONG_NOTSET - 1, numeric_operator);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DeviceValueType::TIME) {
|
if (type == DeviceValueType::TIME) {
|
||||||
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_ULONG_NOTSET, numeric_operator);
|
dv_set_max = Helpers::transformNumFloat(EMS_VALUE_ULONG_NOTSET - 1, numeric_operator);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user