mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
Merge pull request #1558 from proddy/dev
renamed Web custom entity TSX class, remove bogus URI handler from Web customization, added icon to Custom table
This commit is contained in:
@@ -24,8 +24,9 @@
|
|||||||
- changed HA name and grouping to be consistent [#1528](https://github.com/emsesp/EMS-ESP32/issues/1528)
|
- changed HA name and grouping to be consistent [#1528](https://github.com/emsesp/EMS-ESP32/issues/1528)
|
||||||
- MQTT autodiscovery in Domoticz not working [#1360](https://github.com/emsesp/EMS-ESP32/issues/1528)
|
- MQTT autodiscovery in Domoticz not working [#1360](https://github.com/emsesp/EMS-ESP32/issues/1528)
|
||||||
- dhw comfort for new ems+, [#1495](https://github.com/emsesp/EMS-ESP32/issues/1495)
|
- dhw comfort for new ems+, [#1495](https://github.com/emsesp/EMS-ESP32/issues/1495)
|
||||||
|
- added writeable icon to Web's Custom Entity page for each entity shown in the table
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
- HA don't set entity_category to Diagnostic/Configuration for EMS entities [#1459](https://github.com/emsesp/EMS-ESP32/discussions/1459)
|
- HA don't set entity_category to Diagnostic/Configuration for EMS entities [#1459](https://github.com/emsesp/EMS-ESP32/discussions/1459)
|
||||||
- Upgraded ArduinoJson to 7.0.0 #1538
|
- upgraded ArduinoJson to 7.0.0 #1538 and then 7.0.1
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-react": "^7.33.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"preact": "^10.19.3",
|
"preact": "^10.19.3",
|
||||||
"prettier": "^3.2.1",
|
"prettier": "^3.2.2",
|
||||||
"rollup-plugin-visualizer": "^5.12.0",
|
"rollup-plugin-visualizer": "^5.12.0",
|
||||||
"terser": "^5.26.0",
|
"terser": "^5.26.0",
|
||||||
"vite": "^5.0.11",
|
"vite": "^5.0.11",
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { Tab } from '@mui/material';
|
|||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||||
|
|
||||||
import SettingsApplication from './SettingsApplication';
|
import SettingsApplication from './SettingsApplication';
|
||||||
|
import SettingsCustomEntities from './SettingsCustomEntities';
|
||||||
import SettingsCustomization from './SettingsCustomization';
|
import SettingsCustomization from './SettingsCustomization';
|
||||||
import SettingsEntities from './SettingsEntities';
|
|
||||||
import SettingsScheduler from './SettingsScheduler';
|
import SettingsScheduler from './SettingsScheduler';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { RouterTabs, useRouterTab, useLayoutTitle } from 'components';
|
import { RouterTabs, useRouterTab, useLayoutTitle } from 'components';
|
||||||
@@ -27,7 +27,7 @@ const Settings: FC = () => {
|
|||||||
<Route path="application" element={<SettingsApplication />} />
|
<Route path="application" element={<SettingsApplication />} />
|
||||||
<Route path="customization" element={<SettingsCustomization />} />
|
<Route path="customization" element={<SettingsCustomization />} />
|
||||||
<Route path="scheduler" element={<SettingsScheduler />} />
|
<Route path="scheduler" element={<SettingsScheduler />} />
|
||||||
<Route path="customentities" element={<SettingsEntities />} />
|
<Route path="customentities" element={<SettingsCustomEntities />} />
|
||||||
<Route path="*" element={<Navigate replace to="/settings/application" />} />
|
<Route path="*" element={<Navigate replace to="/settings/application" />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import AddIcon from '@mui/icons-material/Add';
|
import AddIcon from '@mui/icons-material/Add';
|
||||||
import CancelIcon from '@mui/icons-material/Cancel';
|
import CancelIcon from '@mui/icons-material/Cancel';
|
||||||
|
import EditOutlinedIcon from '@mui/icons-material/EditOutlined';
|
||||||
import WarningIcon from '@mui/icons-material/Warning';
|
import WarningIcon from '@mui/icons-material/Warning';
|
||||||
import { Button, Typography, Box } from '@mui/material';
|
import { Button, Typography, Box } from '@mui/material';
|
||||||
import { Table, Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
import { Table, Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
||||||
@@ -11,7 +12,7 @@ import { useBlocker } from 'react-router-dom';
|
|||||||
|
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
|
||||||
import SettingsEntitiesDialog from './SettingsEntitiesDialog';
|
import SettingsCustomEntitiesDialog from './SettingsCustomEntitiesDialog';
|
||||||
import * as EMSESP from './api';
|
import * as EMSESP from './api';
|
||||||
import { DeviceValueTypeNames, DeviceValueUOM_s } from './types';
|
import { DeviceValueTypeNames, DeviceValueUOM_s } from './types';
|
||||||
import { entityItemValidation } from './validators';
|
import { entityItemValidation } from './validators';
|
||||||
@@ -21,7 +22,7 @@ import { ButtonRow, FormLoader, SectionContent, BlockNavigation } from 'componen
|
|||||||
|
|
||||||
import { useI18nContext } from 'i18n/i18n-react';
|
import { useI18nContext } from 'i18n/i18n-react';
|
||||||
|
|
||||||
const SettingsEntities: FC = () => {
|
const SettingsCustomEntities: FC = () => {
|
||||||
const { LL } = useI18nContext();
|
const { LL } = useI18nContext();
|
||||||
const [numChanges, setNumChanges] = useState<number>(0);
|
const [numChanges, setNumChanges] = useState<number>(0);
|
||||||
const blocker = useBlocker(numChanges !== 0);
|
const blocker = useBlocker(numChanges !== 0);
|
||||||
@@ -219,7 +220,10 @@ const SettingsEntities: FC = () => {
|
|||||||
<Body>
|
<Body>
|
||||||
{tableList.map((ei: EntityItem) => (
|
{tableList.map((ei: EntityItem) => (
|
||||||
<Row key={ei.name} item={ei} onClick={() => editEntityItem(ei)}>
|
<Row key={ei.name} item={ei} onClick={() => editEntityItem(ei)}>
|
||||||
<Cell>{ei.name}</Cell>
|
<Cell>
|
||||||
|
{ei.name}
|
||||||
|
{ei.writeable && <EditOutlinedIcon color="primary" sx={{ fontSize: 12 }} />}
|
||||||
|
</Cell>
|
||||||
<Cell>{showHex(ei.device_id as number, 2)}</Cell>
|
<Cell>{showHex(ei.device_id as number, 2)}</Cell>
|
||||||
<Cell>{showHex(ei.type_id as number, 3)}</Cell>
|
<Cell>{showHex(ei.type_id as number, 3)}</Cell>
|
||||||
<Cell>{ei.offset}</Cell>
|
<Cell>{ei.offset}</Cell>
|
||||||
@@ -244,7 +248,7 @@ const SettingsEntities: FC = () => {
|
|||||||
{renderEntity()}
|
{renderEntity()}
|
||||||
|
|
||||||
{selectedEntityItem && (
|
{selectedEntityItem && (
|
||||||
<SettingsEntitiesDialog
|
<SettingsCustomEntitiesDialog
|
||||||
open={dialogOpen}
|
open={dialogOpen}
|
||||||
creating={creating}
|
creating={creating}
|
||||||
onClose={onDialogClose}
|
onClose={onDialogClose}
|
||||||
@@ -284,4 +288,4 @@ const SettingsEntities: FC = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SettingsEntities;
|
export default SettingsCustomEntities;
|
||||||
@@ -30,7 +30,7 @@ import { useI18nContext } from 'i18n/i18n-react';
|
|||||||
import { updateValue } from 'utils';
|
import { updateValue } from 'utils';
|
||||||
import { validate } from 'validators';
|
import { validate } from 'validators';
|
||||||
|
|
||||||
type SettingsEntitiesDialogProps = {
|
type SettingsCustomEntitiesDialogProps = {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
creating: boolean;
|
creating: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
@@ -39,14 +39,14 @@ type SettingsEntitiesDialogProps = {
|
|||||||
validator: Schema;
|
validator: Schema;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SettingsEntitiesDialog = ({
|
const SettingsCustomEntitiesDialog = ({
|
||||||
open,
|
open,
|
||||||
creating,
|
creating,
|
||||||
onClose,
|
onClose,
|
||||||
onSave,
|
onSave,
|
||||||
selectedItem,
|
selectedItem,
|
||||||
validator
|
validator
|
||||||
}: SettingsEntitiesDialogProps) => {
|
}: SettingsCustomEntitiesDialogProps) => {
|
||||||
const { LL } = useI18nContext();
|
const { LL } = useI18nContext();
|
||||||
const [editItem, setEditItem] = useState<EntityItem>(selectedItem);
|
const [editItem, setEditItem] = useState<EntityItem>(selectedItem);
|
||||||
const [fieldErrors, setFieldErrors] = useState<ValidateFieldsError>();
|
const [fieldErrors, setFieldErrors] = useState<ValidateFieldsError>();
|
||||||
@@ -249,4 +249,4 @@ const SettingsEntitiesDialog = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SettingsEntitiesDialog;
|
export default SettingsCustomEntitiesDialog;
|
||||||
@@ -88,7 +88,7 @@ export const writeSchedule = (data: any) => alovaInstance.Post('/rest/schedule',
|
|||||||
|
|
||||||
// SettingsEntities
|
// SettingsEntities
|
||||||
export const readCustomEntities = () =>
|
export const readCustomEntities = () =>
|
||||||
alovaInstance.Get<EntityItem[]>('/rest/customentities', {
|
alovaInstance.Get<EntityItem[]>('/rest/customEntities', {
|
||||||
name: 'entities',
|
name: 'entities',
|
||||||
transformData(data: any) {
|
transformData(data: any) {
|
||||||
return data.entities.map((ei: EntityItem) => ({
|
return data.entities.map((ei: EntityItem) => ({
|
||||||
@@ -106,4 +106,4 @@ export const readCustomEntities = () =>
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
export const writeCustomEntities = (data: any) => alovaInstance.Post('/rest/customentities', data);
|
export const writeCustomEntities = (data: any) => alovaInstance.Post('/rest/customEntities', data);
|
||||||
|
|||||||
@@ -1861,7 +1861,7 @@ __metadata:
|
|||||||
lodash-es: "npm:^4.17.21"
|
lodash-es: "npm:^4.17.21"
|
||||||
mime-types: "npm:^2.1.35"
|
mime-types: "npm:^2.1.35"
|
||||||
preact: "npm:^10.19.3"
|
preact: "npm:^10.19.3"
|
||||||
prettier: "npm:^3.2.1"
|
prettier: "npm:^3.2.2"
|
||||||
react: "npm:latest"
|
react: "npm:latest"
|
||||||
react-dom: "npm:latest"
|
react-dom: "npm:latest"
|
||||||
react-dropzone: "npm:^14.2.3"
|
react-dropzone: "npm:^14.2.3"
|
||||||
@@ -7091,12 +7091,12 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"prettier@npm:^3.2.1":
|
"prettier@npm:^3.2.2":
|
||||||
version: 3.2.1
|
version: 3.2.2
|
||||||
resolution: "prettier@npm:3.2.1"
|
resolution: "prettier@npm:3.2.2"
|
||||||
bin:
|
bin:
|
||||||
prettier: bin/prettier.cjs
|
prettier: bin/prettier.cjs
|
||||||
checksum: a26d26a74ba5cbf23a9741074ceef4f53a08ced03c42449dc9615ecd08ada9d19d5247ad2b0dfb15b2c8e57ec9f516074627b85b9f03270b08c184c64e7d8f64
|
checksum: ab9470ff6cfd19f28bc424f22e58f2fc4a488d148b9384f6c3739235017c8350cae82b3697392c23d9b098b9d8dfaa1cc9ff4ef25fd45f54c97b95f9cc7a1f7d
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
@@ -414,28 +414,35 @@ const signin = {
|
|||||||
};
|
};
|
||||||
const generate_token = { token: '1234' };
|
const generate_token = { token: '1234' };
|
||||||
|
|
||||||
|
//
|
||||||
// EMS-ESP Project specific
|
// EMS-ESP Project specific
|
||||||
|
//
|
||||||
const EMSESP_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'settings';
|
const EMSESP_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'settings';
|
||||||
const EMSESP_CORE_DATA_ENDPOINT = REST_ENDPOINT_ROOT + 'coreData';
|
const EMSESP_CORE_DATA_ENDPOINT = REST_ENDPOINT_ROOT + 'coreData';
|
||||||
const EMSESP_SENSOR_DATA_ENDPOINT = REST_ENDPOINT_ROOT + 'sensorData';
|
const EMSESP_SENSOR_DATA_ENDPOINT = REST_ENDPOINT_ROOT + 'sensorData';
|
||||||
const EMSESP_DEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'devices';
|
const EMSESP_DEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'devices';
|
||||||
const EMSESP_SCANDEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'scanDevices';
|
const EMSESP_SCANDEVICES_ENDPOINT = REST_ENDPOINT_ROOT + 'scanDevices';
|
||||||
|
|
||||||
// const EMSESP_DEVICEDATA_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceData/:id';
|
// const EMSESP_DEVICEDATA_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceData/:id';
|
||||||
// const EMSESP_DEVICEENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceEntities/:id';
|
// const EMSESP_DEVICEENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceEntities/:id';
|
||||||
|
|
||||||
const EMSESP_DEVICEDATA_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceData';
|
const EMSESP_DEVICEDATA_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceData';
|
||||||
const EMSESP_DEVICEENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceEntities';
|
const EMSESP_DEVICEENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'deviceEntities';
|
||||||
|
|
||||||
const EMSESP_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'status';
|
const EMSESP_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'status';
|
||||||
const EMSESP_BOARDPROFILE_ENDPOINT = REST_ENDPOINT_ROOT + 'boardProfile';
|
const EMSESP_BOARDPROFILE_ENDPOINT = REST_ENDPOINT_ROOT + 'boardProfile';
|
||||||
const EMSESP_WRITE_VALUE_ENDPOINT = REST_ENDPOINT_ROOT + 'writeDeviceValue';
|
const EMSESP_WRITE_DEVICEVALUE_ENDPOINT = REST_ENDPOINT_ROOT + 'writeDeviceValue';
|
||||||
const EMSESP_WRITE_SENSOR_ENDPOINT = REST_ENDPOINT_ROOT + 'writeTemperatureSensor';
|
const EMSESP_WRITE_TEMPSENSOR_ENDPOINT = REST_ENDPOINT_ROOT + 'writeTemperatureSensor';
|
||||||
const EMSESP_WRITE_ANALOG_ENDPOINT = REST_ENDPOINT_ROOT + 'writeAnalogSensor';
|
const EMSESP_WRITE_ANALOGSENSOR_ENDPOINT = REST_ENDPOINT_ROOT + 'writeAnalogSensor';
|
||||||
const EMSESP_CUSTOMIZATION_ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'customizationEntities';
|
const EMSESP_CUSTOMIZATION_ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'customizationEntities';
|
||||||
const EMSESP_RESET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'resetCustomizations';
|
const EMSESP_RESET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'resetCustomizations';
|
||||||
const EMSESP_WRITE_SCHEDULE_ENDPOINT = REST_ENDPOINT_ROOT + 'schedule';
|
|
||||||
const EMSESP_WRITE_ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'entities';
|
const EMSESP_SCHEDULE_ENDPOINT = REST_ENDPOINT_ROOT + 'schedule';
|
||||||
|
const EMSESP_CUSTOMENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'customEntities';
|
||||||
|
|
||||||
|
const EMSESP_GET_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'getSettings';
|
||||||
|
const EMSESP_GET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'getCustomizations';
|
||||||
|
const EMSESP_GET_ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'getEntities';
|
||||||
|
const EMSESP_GET_SCHEDULE_ENDPOINT = REST_ENDPOINT_ROOT + 'getSchedule';
|
||||||
|
|
||||||
|
const EMSESP_SYSTEM_INFO_ENDPOINT = API_ENDPOINT_ROOT + 'system/info';
|
||||||
|
|
||||||
const emsesp_info = {
|
const emsesp_info = {
|
||||||
System: {
|
System: {
|
||||||
@@ -742,7 +749,7 @@ const emsesp_coredata = {
|
|||||||
d: 1,
|
d: 1,
|
||||||
p: 1,
|
p: 1,
|
||||||
v: '',
|
v: '',
|
||||||
e: 1
|
e: 2
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@@ -788,7 +795,7 @@ const status = {
|
|||||||
// 1 - RC35 thermo
|
// 1 - RC35 thermo
|
||||||
// 2 - RC20 thermo
|
// 2 - RC20 thermo
|
||||||
// 3 - Buderus GB125 boiler
|
// 3 - Buderus GB125 boiler
|
||||||
// 4 - RC100 themo
|
// 4 - RC100 thermostat
|
||||||
// 5 - Mixer MM10
|
// 5 - Mixer MM10
|
||||||
// 6 - Solar SM10
|
// 6 - Solar SM10
|
||||||
// 7 - Nefit Trendline boiler
|
// 7 - Nefit Trendline boiler
|
||||||
@@ -2048,6 +2055,11 @@ const emsesp_devicedata_99 = {
|
|||||||
u: 1,
|
u: 1,
|
||||||
id: '00boiler_flowtemp',
|
id: '00boiler_flowtemp',
|
||||||
c: 'boiler_flowtemp'
|
c: 'boiler_flowtemp'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
v: 0,
|
||||||
|
u: 0,
|
||||||
|
id: '00wwExtra1'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@@ -2065,7 +2077,20 @@ let emsesp_customentities = {
|
|||||||
name: 'boiler_flowtemp',
|
name: 'boiler_flowtemp',
|
||||||
uom: 1,
|
uom: 1,
|
||||||
value_type: 1,
|
value_type: 1,
|
||||||
writeable: true
|
writeable: true,
|
||||||
|
value: 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
device_id: 16,
|
||||||
|
type_id: 797,
|
||||||
|
offset: 0,
|
||||||
|
factor: 1,
|
||||||
|
name: 'wwExtra1',
|
||||||
|
uom: 0,
|
||||||
|
value_type: 0,
|
||||||
|
writeable: false,
|
||||||
|
value: 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
@@ -2458,15 +2483,16 @@ router
|
|||||||
// EMS-ESP Project stuff
|
// EMS-ESP Project stuff
|
||||||
//
|
//
|
||||||
router
|
router
|
||||||
.post(EMSESP_RESET_CUSTOMIZATIONS_ENDPOINT, async (request: any) => {
|
|
||||||
return new Response('OK', { status: 200 });
|
// EMS-ESP Settings
|
||||||
})
|
|
||||||
.get(EMSESP_SETTINGS_ENDPOINT, () => new Response(JSON.stringify(settings), { headers }))
|
.get(EMSESP_SETTINGS_ENDPOINT, () => new Response(JSON.stringify(settings), { headers }))
|
||||||
.post(EMSESP_SETTINGS_ENDPOINT, async (request: any) => {
|
.post(EMSESP_SETTINGS_ENDPOINT, async (request: any) => {
|
||||||
settings = await request.json();
|
settings = await request.json();
|
||||||
return new Response('OK', { status: 200 }); // no restart needed
|
return new Response('OK', { status: 200 }); // no restart needed
|
||||||
// return new Response('OK', { status: 205 }); // restart needed
|
// return new Response('OK', { status: 205 }); // restart needed
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Device Dashboard Data
|
||||||
.get(EMSESP_CORE_DATA_ENDPOINT, () => new Response(JSON.stringify(emsesp_coredata), { headers }))
|
.get(EMSESP_CORE_DATA_ENDPOINT, () => new Response(JSON.stringify(emsesp_coredata), { headers }))
|
||||||
.get(EMSESP_SENSOR_DATA_ENDPOINT, () => new Response(JSON.stringify(emsesp_sensordata), { headers }))
|
.get(EMSESP_SENSOR_DATA_ENDPOINT, () => new Response(JSON.stringify(emsesp_sensordata), { headers }))
|
||||||
.get(EMSESP_DEVICES_ENDPOINT, () => new Response(JSON.stringify(emsesp_devices), { headers }))
|
.get(EMSESP_DEVICES_ENDPOINT, () => new Response(JSON.stringify(emsesp_devices), { headers }))
|
||||||
@@ -2527,6 +2553,8 @@ router
|
|||||||
return new Response(encoder.encode(emsesp_deviceentities_7), { headers });
|
return new Response(encoder.encode(emsesp_deviceentities_7), { headers });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Customization
|
||||||
.post(EMSESP_CUSTOMIZATION_ENTITIES_ENDPOINT, async (request: any) => {
|
.post(EMSESP_CUSTOMIZATION_ENTITIES_ENDPOINT, async (request: any) => {
|
||||||
const content = await request.json();
|
const content = await request.json();
|
||||||
const id = content.id;
|
const id = content.id;
|
||||||
@@ -2549,17 +2577,28 @@ router
|
|||||||
}
|
}
|
||||||
return new Response('OK', { status: 200 });
|
return new Response('OK', { status: 200 });
|
||||||
})
|
})
|
||||||
.post(EMSESP_WRITE_SCHEDULE_ENDPOINT, async (request: any) => {
|
.post(EMSESP_RESET_CUSTOMIZATIONS_ENDPOINT, async (request: any) => {
|
||||||
|
return new Response('OK', { status: 200 });
|
||||||
|
})
|
||||||
|
|
||||||
|
// Scheduler
|
||||||
|
.post(EMSESP_SCHEDULE_ENDPOINT, async (request: any) => {
|
||||||
const content = await request.json();
|
const content = await request.json();
|
||||||
emsesp_schedule = content;
|
emsesp_schedule = content;
|
||||||
return new Response('OK', { status: 200 });
|
return new Response('OK', { status: 200 });
|
||||||
})
|
})
|
||||||
.post(EMSESP_WRITE_ENTITIES_ENDPOINT, async (request: any) => {
|
.get(EMSESP_SCHEDULE_ENDPOINT, () => new Response(JSON.stringify(emsesp_schedule), { headers }))
|
||||||
|
|
||||||
|
// Custom Entities
|
||||||
|
.post(EMSESP_CUSTOMENTITIES_ENDPOINT, async (request: any) => {
|
||||||
const content = await request.json();
|
const content = await request.json();
|
||||||
emsesp_customentities = content;
|
emsesp_customentities = content;
|
||||||
return new Response('OK', { status: 200 });
|
return new Response('OK', { status: 200 });
|
||||||
})
|
})
|
||||||
.post(EMSESP_WRITE_VALUE_ENDPOINT, async (request: any) => {
|
.get(EMSESP_CUSTOMENTITIES_ENDPOINT, () => new Response(JSON.stringify(emsesp_customentities), { headers }))
|
||||||
|
|
||||||
|
// Device Dashboard
|
||||||
|
.post(EMSESP_WRITE_DEVICEVALUE_ENDPOINT, async (request: any) => {
|
||||||
const content = await request.json();
|
const content = await request.json();
|
||||||
const command = content.c;
|
const command = content.c;
|
||||||
const value = content.v;
|
const value = content.v;
|
||||||
@@ -2603,7 +2642,9 @@ router
|
|||||||
await delay(1000); // wait to show spinner
|
await delay(1000); // wait to show spinner
|
||||||
return new Response('OK', { status: 200 }); // or 400 for bad request
|
return new Response('OK', { status: 200 }); // or 400 for bad request
|
||||||
})
|
})
|
||||||
.post(EMSESP_WRITE_SENSOR_ENDPOINT, async (request: any) => {
|
|
||||||
|
// Temperature & Analog Sensors
|
||||||
|
.post(EMSESP_WRITE_TEMPSENSOR_ENDPOINT, async (request: any) => {
|
||||||
const ts = await request.json();
|
const ts = await request.json();
|
||||||
var objIndex = emsesp_sensordata.ts.findIndex((obj) => obj.id == ts.id_str);
|
var objIndex = emsesp_sensordata.ts.findIndex((obj) => obj.id == ts.id_str);
|
||||||
if (objIndex !== -1) {
|
if (objIndex !== -1) {
|
||||||
@@ -2612,7 +2653,7 @@ router
|
|||||||
}
|
}
|
||||||
return new Response('OK', { status: 200 });
|
return new Response('OK', { status: 200 });
|
||||||
})
|
})
|
||||||
.post(EMSESP_WRITE_ANALOG_ENDPOINT, async (request: any) => {
|
.post(EMSESP_WRITE_ANALOGSENSOR_ENDPOINT, async (request: any) => {
|
||||||
const as = await request.json();
|
const as = await request.json();
|
||||||
var objIndex = emsesp_sensordata.as.findIndex((obj) => obj.g == as.gpio);
|
var objIndex = emsesp_sensordata.as.findIndex((obj) => obj.g == as.gpio);
|
||||||
if (objIndex === -1) {
|
if (objIndex === -1) {
|
||||||
@@ -2645,6 +2686,8 @@ router
|
|||||||
|
|
||||||
return new Response('OK', { status: 200 });
|
return new Response('OK', { status: 200 });
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Settings - board profile
|
||||||
.post(EMSESP_BOARDPROFILE_ENDPOINT, async (request: any) => {
|
.post(EMSESP_BOARDPROFILE_ENDPOINT, async (request: any) => {
|
||||||
const content = await request.json();
|
const content = await request.json();
|
||||||
const board_profile = content.code;
|
const board_profile = content.code;
|
||||||
@@ -2774,26 +2817,18 @@ router
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Response(JSON.stringify(data), { headers });
|
return new Response(JSON.stringify(data), { headers });
|
||||||
});
|
})
|
||||||
|
|
||||||
// API and calls
|
// Download Settings
|
||||||
const SYSTEM_INFO_ENDPOINT = API_ENDPOINT_ROOT + 'system/info';
|
.get(EMSESP_GET_SETTINGS_ENDPOINT, () => new Response(JSON.stringify(emsesp_info), { headers }))
|
||||||
const GET_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'getSettings';
|
.get(EMSESP_GET_CUSTOMIZATIONS_ENDPOINT, () => new Response(JSON.stringify(emsesp_deviceentities_1), { headers }))
|
||||||
const GET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'getCustomizations';
|
.get(EMSESP_GET_ENTITIES_ENDPOINT, () => new Response(JSON.stringify(emsesp_customentities), { headers }))
|
||||||
const GET_ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'getEntities';
|
.get(EMSESP_GET_SCHEDULE_ENDPOINT, () => new Response(JSON.stringify(emsesp_schedule), { headers }));
|
||||||
const GET_SCHEDULE_ENDPOINT = REST_ENDPOINT_ROOT + 'getSchedule';
|
|
||||||
const SCHEDULE_ENDPOINT = REST_ENDPOINT_ROOT + 'schedule';
|
|
||||||
const ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'customentities';
|
|
||||||
|
|
||||||
|
// API which are usually POST for security
|
||||||
router
|
router
|
||||||
.post(SYSTEM_INFO_ENDPOINT, () => new Response(JSON.stringify(emsesp_info), { headers }))
|
.post(EMSESP_SYSTEM_INFO_ENDPOINT, () => new Response(JSON.stringify(emsesp_info), { headers }))
|
||||||
.get(SYSTEM_INFO_ENDPOINT, () => new Response(JSON.stringify(emsesp_info), { headers }))
|
.get(EMSESP_SYSTEM_INFO_ENDPOINT, () => new Response(JSON.stringify(emsesp_info), { headers }))
|
||||||
.get(GET_SETTINGS_ENDPOINT, () => new Response(JSON.stringify(emsesp_info), { headers }))
|
|
||||||
.get(GET_CUSTOMIZATIONS_ENDPOINT, () => new Response(JSON.stringify(emsesp_deviceentities_1), { headers }))
|
|
||||||
.get(GET_ENTITIES_ENDPOINT, () => new Response(JSON.stringify(emsesp_customentities), { headers }))
|
|
||||||
.get(GET_SCHEDULE_ENDPOINT, () => new Response(JSON.stringify(emsesp_schedule), { headers }))
|
|
||||||
.get(SCHEDULE_ENDPOINT, () => new Response(JSON.stringify(emsesp_schedule), { headers }))
|
|
||||||
.get(ENTITIES_ENDPOINT, () => new Response(JSON.stringify(emsesp_customentities), { headers }))
|
|
||||||
.post(API_ENDPOINT_ROOT, async (request: any) => {
|
.post(API_ENDPOINT_ROOT, async (request: any) => {
|
||||||
const data = await request.json();
|
const data = await request.json();
|
||||||
if (data.device === 'system') {
|
if (data.device === 'system') {
|
||||||
@@ -2807,7 +2842,9 @@ router
|
|||||||
return new Response('Not Found', { status: 404 });
|
return new Response('Not Found', { status: 404 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
// Event Source // TODO fix event source later
|
// Event Source // TODO fix event source later
|
||||||
|
//
|
||||||
|
|
||||||
// const data = {
|
// const data = {
|
||||||
// t: '000+00:00:00.000',
|
// t: '000+00:00:00.000',
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.6.5-dev.8"
|
#define EMSESP_APP_VERSION "3.6.5-dev.9"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#define WebCustomEntityService_h
|
#define WebCustomEntityService_h
|
||||||
|
|
||||||
#define EMSESP_CUSTOMENTITY_FILE "/config/emsespEntity.json"
|
#define EMSESP_CUSTOMENTITY_FILE "/config/emsespEntity.json"
|
||||||
#define EMSESP_CUSTOMENTITY_SERVICE_PATH "/rest/customentities" // GET and POST
|
#define EMSESP_CUSTOMENTITY_SERVICE_PATH "/rest/customEntities" // GET and POST
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,7 @@ using namespace std::placeholders; // for `_1` etc
|
|||||||
bool WebCustomization::_start = true;
|
bool WebCustomization::_start = true;
|
||||||
|
|
||||||
WebCustomizationService::WebCustomizationService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager)
|
WebCustomizationService::WebCustomizationService(AsyncWebServer * server, FS * fs, SecurityManager * securityManager)
|
||||||
: _httpEndpoint(WebCustomization::read,
|
: _fsPersistence(WebCustomization::read, WebCustomization::update, this, fs, EMSESP_CUSTOMIZATION_FILE)
|
||||||
WebCustomization::update,
|
|
||||||
this,
|
|
||||||
server,
|
|
||||||
EMSESP_CUSTOMIZATION_SERVICE_PATH,
|
|
||||||
securityManager,
|
|
||||||
AuthenticationPredicates::IS_AUTHENTICATED)
|
|
||||||
, _fsPersistence(WebCustomization::read, WebCustomization::update, this, fs, EMSESP_CUSTOMIZATION_FILE)
|
|
||||||
, _masked_entities_handler(CUSTOMIZATION_ENTITIES_PATH,
|
, _masked_entities_handler(CUSTOMIZATION_ENTITIES_PATH,
|
||||||
securityManager->wrapCallback(std::bind(&WebCustomizationService::customization_entities, this, _1, _2),
|
securityManager->wrapCallback(std::bind(&WebCustomizationService::customization_entities, this, _1, _2),
|
||||||
AuthenticationPredicates::IS_AUTHENTICATED)) {
|
AuthenticationPredicates::IS_AUTHENTICATED)) {
|
||||||
@@ -85,7 +78,7 @@ void WebCustomization::read(WebCustomization & customizations, JsonObject root)
|
|||||||
entityJson["product_id"] = entityCustomization.product_id;
|
entityJson["product_id"] = entityCustomization.product_id;
|
||||||
entityJson["device_id"] = entityCustomization.device_id;
|
entityJson["device_id"] = entityCustomization.device_id;
|
||||||
|
|
||||||
// entries are in the form <XX><shortname>[|optional customname] e.g "08heatingactive|heating is on"
|
// entries are in the form <XX><shortname>[optional customname] e.g "08heatingactive|heating is on"
|
||||||
JsonArray masked_entityJson = entityJson["entity_ids"].to<JsonArray>();
|
JsonArray masked_entityJson = entityJson["entity_ids"].to<JsonArray>();
|
||||||
for (std::string entity_id : entityCustomization.entity_ids) {
|
for (std::string entity_id : entityCustomization.entity_ids) {
|
||||||
masked_entityJson.add(entity_id);
|
masked_entityJson.add(entity_id);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
// GET
|
// GET
|
||||||
#define DEVICES_SERVICE_PATH "/rest/devices"
|
#define DEVICES_SERVICE_PATH "/rest/devices"
|
||||||
#define EMSESP_CUSTOMIZATION_SERVICE_PATH "/rest/customization"
|
|
||||||
#define DEVICE_ENTITIES_PATH "/rest/deviceEntities"
|
#define DEVICE_ENTITIES_PATH "/rest/deviceEntities"
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
@@ -89,7 +88,6 @@ class WebCustomizationService : public StatefulService<WebCustomization> {
|
|||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HttpEndpoint<WebCustomization> _httpEndpoint;
|
|
||||||
FSPersistence<WebCustomization> _fsPersistence;
|
FSPersistence<WebCustomization> _fsPersistence;
|
||||||
|
|
||||||
// GET
|
// GET
|
||||||
|
|||||||
Reference in New Issue
Block a user