Skip to content

Commit

Permalink
show entity count in device list, remove type
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Oct 17, 2023
1 parent f9a176e commit a1bb493
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
18 changes: 10 additions & 8 deletions interface/src/project/DashboardDevices.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import CancelIcon from '@mui/icons-material/Cancel';
import CommentsDisabledOutlinedIcon from '@mui/icons-material/CommentsDisabledOutlined';
import EditIcon from '@mui/icons-material/Edit';
import EditOffOutlinedIcon from '@mui/icons-material/EditOffOutlined';
import DownloadIcon from '@mui/icons-material/GetApp';
import HighlightOffIcon from '@mui/icons-material/HighlightOff';
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
import KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';
import KeyboardArrowUpOutlinedIcon from '@mui/icons-material/KeyboardArrowUpOutlined';
Expand All @@ -26,6 +26,7 @@ import {
Grid,
Typography
} from '@mui/material';

import { useRowSelect } from '@table-library/react-table-library/select';
import { useSort, SortToggleType } from '@table-library/react-table-library/sort';
import { Table, Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
Expand Down Expand Up @@ -135,7 +136,7 @@ const DashboardDevices: FC = () => {
common_theme,
{
Table: `
--data-table-library_grid-template-columns: 40px repeat(1, minmax(0, 1fr)) 130px;
--data-table-library_grid-template-columns: 40px repeat(1, minmax(0, 1fr));
`,
BaseRow: `
.td {
Expand Down Expand Up @@ -417,7 +418,6 @@ const DashboardDevices: FC = () => {
<HeaderRow>
<HeaderCell stiff />
<HeaderCell resize>{LL.DESCRIPTION()}</HeaderCell>
<HeaderCell stiff>{LL.TYPE(0)}</HeaderCell>
</HeaderRow>
</Header>
<Body>
Expand All @@ -426,8 +426,10 @@ const DashboardDevices: FC = () => {
<Cell stiff>
<DeviceIcon type_id={device.t} />
</Cell>
<Cell>{device.n}</Cell>
<Cell stiff>{device.tn}</Cell>
<Cell>
{device.n}
<span style={{ color: 'lightblue' }}>&nbsp;&nbsp;({device.e})</span>
</Cell>
</Row>
))}
</Body>
Expand Down Expand Up @@ -485,8 +487,8 @@ const DashboardDevices: FC = () => {
}}
>
<Box sx={{ border: '1px solid #177ac9' }}>
<Typography noWrap variant="subtitle1" color="warning.main" sx={{ mx: 1 }}>
{coreData.devices[deviceIndex].n}
<Typography noWrap variant="subtitle1" color="warning.main" sx={{ ml: 1 }}>
{coreData.devices[deviceIndex].tn}&nbsp;&#124;&nbsp;{coreData.devices[deviceIndex].n}
</Typography>

<Grid container justifyContent="space-between">
Expand All @@ -511,7 +513,7 @@ const DashboardDevices: FC = () => {
</Typography>
<Grid item zeroMinWidth justifyContent="flex-end">
<IconButton onClick={resetDeviceSelect}>
<CancelIcon color="info" sx={{ fontSize: 18, verticalAlign: 'middle' }} />
<HighlightOffIcon color="primary" sx={{ fontSize: 18, verticalAlign: 'middle' }} />
</IconButton>
</Grid>
</Grid>
Expand Down
1 change: 1 addition & 0 deletions interface/src/project/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export interface Device {
d: number; // deviceid
p: number; // productid
v: string; // version
e: number; // entities
}

export interface TemperatureSensor {
Expand Down
24 changes: 16 additions & 8 deletions mock-api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ const emsesp_coredata = {
// n: 'Enviline/Compress 6000AW/Hybrid 3000-7000iAW/SupraEco/Geo 5xx/WLW196i/WSW196i',
d: 8,
p: 123,
v: '06.01'
v: '06.01',
e: 69
},
{
id: 3,
Expand All @@ -437,7 +438,8 @@ const emsesp_coredata = {
n: 'GB125/GB135/MC10',
d: 8,
p: 123,
v: '06.01'
v: '06.01',
e: 73
},
{
id: 1,
Expand All @@ -447,7 +449,8 @@ const emsesp_coredata = {
n: 'RC35',
d: 24,
p: 86,
v: '04.01'
v: '04.01',
e: 57
},
{
id: 2,
Expand All @@ -457,7 +460,8 @@ const emsesp_coredata = {
n: 'RC20/Moduline 300',
d: 23,
p: 77,
v: '03.03'
v: '03.03',
e: 6
},
{
id: 4,
Expand All @@ -467,7 +471,8 @@ const emsesp_coredata = {
n: 'RC100/Moduline 1000/1010',
d: 16,
p: 165,
v: '04.01'
v: '04.01',
e: 3
},
{
id: 5,
Expand All @@ -477,7 +482,8 @@ const emsesp_coredata = {
n: 'MM10',
d: 32,
p: 69,
v: '01.01'
v: '01.01',
e: 6
},
{
id: 6,
Expand All @@ -487,7 +493,8 @@ const emsesp_coredata = {
n: 'SM10',
d: 48,
p: 73,
v: '01.02'
v: '01.02',
e: 22
},
{
id: 99,
Expand All @@ -497,7 +504,8 @@ const emsesp_coredata = {
n: 'User defined entities',
d: 1,
p: 1,
v: ''
v: '',
e: 1
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion src/emsdevicevalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ bool DeviceValue::hasValue() const {
has_value = Helpers::hasValue(*(uint32_t *)(value_p));
break;
case DeviceValueType::CMD:
has_value = false; // commands don't have values!
has_value = true; // we count command as an actual entity
break;
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.6.3-dev.3"
#define EMSESP_APP_VERSION "3.6.3-dev.4"
2 changes: 2 additions & 0 deletions src/web/WebDataService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) {
obj["d"] = emsdevice->device_id(); // deviceid
obj["p"] = emsdevice->product_id(); // productid
obj["v"] = emsdevice->version(); // version
obj["e"] = emsdevice->count_entities(); // number of entities
}
}

Expand All @@ -102,6 +103,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) {
obj["d"] = 0; // deviceid
obj["p"] = 0; // productid
obj["v"] = 0; // version
obj["e"] = EMSESP::webCustomEntityService.count_entities(); // number of custom entities
}

root["connected"] = EMSESP::bus_status() != 2;
Expand Down

0 comments on commit a1bb493

Please sign in to comment.