Skip to content

Commit

Permalink
Merge branch 'dev' into idf4
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed May 18, 2022
2 parents a3130d4 + ca50c51 commit c7fb339
Show file tree
Hide file tree
Showing 17 changed files with 162 additions and 118 deletions.
69 changes: 24 additions & 45 deletions interface/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions interface/package.json
Expand Up @@ -8,10 +8,10 @@
"@emotion/styled": "^11.8.1",
"@msgpack/msgpack": "^2.7.2",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.4",
"@table-library/react-table-library": "^3.1.0",
"@mui/material": "^5.7.0",
"@table-library/react-table-library": "^3.1.2",
"@types/lodash": "^4.14.182",
"@types/node": "^17.0.31",
"@types/node": "^17.0.33",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@types/react-router-dom": "^5.3.3",
Expand All @@ -20,7 +20,7 @@
"http-proxy-middleware": "^2.0.6",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"notistack": "^2.0.4",
"notistack": "^2.0.5",
"parse-ms": "^3.0.0",
"react": "^17.0.2",
"react-app-rewired": "^2.2.1",
Expand Down
1 change: 1 addition & 0 deletions interface/src/api/system.ts
Expand Up @@ -38,3 +38,4 @@ export function updateLogSettings(logSettings: LogSettings): AxiosPromise<LogSet
export function readLogEntries(): AxiosPromise<LogEntries> {
return AXIOS_BIN.get('/fetchLog');
}

63 changes: 46 additions & 17 deletions interface/src/project/HelpInformation.tsx
Expand Up @@ -24,7 +24,22 @@ const HelpInformation: FC = () => {

const { me } = useContext(AuthenticatedContext);

const onDownload = async (endpoint: string) => {
const saveFile = (json: any, endpoint: string) => {
const a = document.createElement('a');
const filename = 'emsesp_' + endpoint + '.json';
a.href = URL.createObjectURL(
new Blob([JSON.stringify(json, null, 2)], {
type: 'text/plain'
})
);
a.setAttribute('download', filename);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
enqueueSnackbar('File downloaded', { variant: 'info' });
};

const callAPI = async (endpoint: string) => {
try {
const response = await EMSESP.API({
device: 'system',
Expand All @@ -34,19 +49,33 @@ const HelpInformation: FC = () => {
if (response.status !== 200) {
enqueueSnackbar('API call failed', { variant: 'error' });
} else {
const json = response.data;
const a = document.createElement('a');
const filename = 'emsesp_' + endpoint + '.json';
a.href = URL.createObjectURL(
new Blob([JSON.stringify(json, null, 2)], {
type: 'text/plain'
})
);
a.setAttribute('download', filename);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
enqueueSnackbar('File downloaded', { variant: 'info' });
saveFile(response.data, endpoint);
}
} catch (error: unknown) {
enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' });
}
};

const downloadSettings = async () => {
try {
const response = await EMSESP.getSettings();
if (response.status !== 200) {
enqueueSnackbar('Unable to get settings', { variant: 'error' });
} else {
saveFile(response.data, 'settings');
}
} catch (error: unknown) {
enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' });
}
};

const downloadCustomizations = async () => {
try {
const response = await EMSESP.getCustomizations();
if (response.status !== 200) {
enqueueSnackbar('Unable to get customizations', { variant: 'error' });
} else {
saveFile(response.data, 'customizations');
}
} catch (error: unknown) {
enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' });
Expand Down Expand Up @@ -103,7 +132,7 @@ const HelpInformation: FC = () => {
</ListItemAvatar>
<ListItemText>
To report an issue or request a feature, please&nbsp;
<Link component="button" variant="body1" onClick={() => onDownload('info')}>
<Link component="button" variant="body1" onClick={() => callAPI('info')}>
download
</Link>
&nbsp;the debug information and include in a new&nbsp;
Expand Down Expand Up @@ -131,15 +160,15 @@ const HelpInformation: FC = () => {
startIcon={<DownloadIcon />}
variant="outlined"
color="primary"
onClick={() => onDownload('settings')}
onClick={() => downloadSettings()}
>
settings
</Button>
<Button
startIcon={<DownloadIcon />}
variant="outlined"
color="primary"
onClick={() => onDownload('customizations')}
onClick={() => downloadCustomizations()}
>
customizations
</Button>
Expand Down
8 changes: 8 additions & 0 deletions interface/src/project/api.ts
Expand Up @@ -86,3 +86,11 @@ export function resetCustomizations(): AxiosPromise<void> {
export function API(apiCall: APIcall): AxiosPromise<void> {
return AXIOS_API.post('/', apiCall);
}

export function getSettings(): AxiosPromise<void> {
return AXIOS.get('/getSettings');
}

export function getCustomizations(): AxiosPromise<void> {
return AXIOS.get('/getCustomizations');
}
17 changes: 10 additions & 7 deletions mock-api/server.js
Expand Up @@ -1193,16 +1193,19 @@ rest_server.get(SYSTEM_INFO_ENDPOINT, (req, res) => {
res.json(emsesp_info)
})

const SYSTEM_SETTINGS_ENDPOINT = API_ENDPOINT_ROOT + 'system/settings'
rest_server.post(SYSTEM_SETTINGS_ENDPOINT, (req, res) => {
console.log('System Settings POST: ' + JSON.stringify(req.body))
res.sendStatus(200)
})
rest_server.get(SYSTEM_SETTINGS_ENDPOINT, (req, res) => {
console.log('System Settings GET')
const GET_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'getSettings'
rest_server.get(GET_SETTINGS_ENDPOINT, (req, res) => {
console.log('System Settings:')
res.json(settings)
})

const GET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'getCustomizations'
rest_server.get(GET_CUSTOMIZATIONS_ENDPOINT, (req, res) => {
console.log('Customizations:')
// not implemented yet
res.sendStatus(200)
})

// start server
const expressServer = rest_server.listen(port, () =>
console.log(`Mock server for EMS-ESP is up and running at http://localhost:${port}`),
Expand Down
1 change: 1 addition & 0 deletions src/device_library.h
Expand Up @@ -130,6 +130,7 @@

// Heat Pumps - 0x38
{200, DeviceType::HEATPUMP, F("HP Module"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
{248, DeviceType::HEATPUMP, F("Hybrid Manager HM200"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
{252, DeviceType::HEATPUMP, F("HP Module"), DeviceFlags::EMS_DEVICE_FLAG_NONE},

// Connect devices - 0x02
Expand Down
4 changes: 2 additions & 2 deletions src/devices/boiler.cpp
Expand Up @@ -1164,7 +1164,7 @@ bool Boiler::set_ww_temp(const char * value, const int8_t id) {
return false;
}

if (is_fetch(EMS_TYPE_UBAParametersPlus)) {
if (is_fetch(EMS_TYPE_UBAParameterWWPlus)) {
// write_command(EMS_TYPE_UBAFlags, 3, v, EMS_TYPE_UBAParameterWWPlus); // test for #96
write_command(EMS_TYPE_UBAParameterWWPlus, 6, v, EMS_TYPE_UBAParameterWWPlus);
} else {
Expand Down Expand Up @@ -1206,7 +1206,7 @@ bool Boiler::set_ww_disinfect_temp(const char * value, const int8_t id) {
return false;
}

if (is_fetch(EMS_TYPE_UBAParametersPlus)) {
if (is_fetch(EMS_TYPE_UBAParameterWWPlus)) {
write_command(EMS_TYPE_UBAParameterWWPlus, 12, v, EMS_TYPE_UBAParameterWWPlus);
} else {
write_command(EMS_TYPE_UBAParameterWW, 8, v, EMS_TYPE_UBAParameterWW);
Expand Down

0 comments on commit c7fb339

Please sign in to comment.