mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
Merge branch 'idf4' into idf4_no_master
This commit is contained in:
2061
interface/package-lock.json
generated
2061
interface/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -7,11 +7,11 @@
|
|||||||
"@emotion/react": "^11.9.0",
|
"@emotion/react": "^11.9.0",
|
||||||
"@emotion/styled": "^11.8.1",
|
"@emotion/styled": "^11.8.1",
|
||||||
"@msgpack/msgpack": "^2.7.2",
|
"@msgpack/msgpack": "^2.7.2",
|
||||||
"@mui/icons-material": "^5.6.2",
|
"@mui/icons-material": "^5.8.0",
|
||||||
"@mui/material": "^5.6.4",
|
"@mui/material": "^5.8.0",
|
||||||
"@table-library/react-table-library": "^3.1.0",
|
"@table-library/react-table-library": "^3.1.2",
|
||||||
"@types/lodash": "^4.14.182",
|
"@types/lodash": "^4.14.182",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.34",
|
||||||
"@types/react": "^17.0.43",
|
"@types/react": "^17.0.43",
|
||||||
"@types/react-dom": "^17.0.14",
|
"@types/react-dom": "^17.0.14",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
"http-proxy-middleware": "^2.0.6",
|
"http-proxy-middleware": "^2.0.6",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"notistack": "^2.0.4",
|
"notistack": "^2.0.5",
|
||||||
"parse-ms": "^3.0.0",
|
"parse-ms": "^3.0.0",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-app-rewired": "^2.2.1",
|
"react-app-rewired": "^2.2.1",
|
||||||
|
|||||||
@@ -38,3 +38,4 @@ export function updateLogSettings(logSettings: LogSettings): AxiosPromise<LogSet
|
|||||||
export function readLogEntries(): AxiosPromise<LogEntries> {
|
export function readLogEntries(): AxiosPromise<LogEntries> {
|
||||||
return AXIOS_BIN.get('/fetchLog');
|
return AXIOS_BIN.get('/fetchLog');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,22 @@ const HelpInformation: FC = () => {
|
|||||||
|
|
||||||
const { me } = useContext(AuthenticatedContext);
|
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 {
|
try {
|
||||||
const response = await EMSESP.API({
|
const response = await EMSESP.API({
|
||||||
device: 'system',
|
device: 'system',
|
||||||
@@ -34,19 +49,33 @@ const HelpInformation: FC = () => {
|
|||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
enqueueSnackbar('API call failed', { variant: 'error' });
|
enqueueSnackbar('API call failed', { variant: 'error' });
|
||||||
} else {
|
} else {
|
||||||
const json = response.data;
|
saveFile(response.data, endpoint);
|
||||||
const a = document.createElement('a');
|
}
|
||||||
const filename = 'emsesp_' + endpoint + '.json';
|
} catch (error: unknown) {
|
||||||
a.href = URL.createObjectURL(
|
enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' });
|
||||||
new Blob([JSON.stringify(json, null, 2)], {
|
}
|
||||||
type: 'text/plain'
|
};
|
||||||
})
|
|
||||||
);
|
const downloadSettings = async () => {
|
||||||
a.setAttribute('download', filename);
|
try {
|
||||||
document.body.appendChild(a);
|
const response = await EMSESP.getSettings();
|
||||||
a.click();
|
if (response.status !== 200) {
|
||||||
document.body.removeChild(a);
|
enqueueSnackbar('Unable to get settings', { variant: 'error' });
|
||||||
enqueueSnackbar('File downloaded', { variant: 'info' });
|
} 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) {
|
} catch (error: unknown) {
|
||||||
enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' });
|
enqueueSnackbar(extractErrorMessage(error, 'Problem with downloading'), { variant: 'error' });
|
||||||
@@ -103,7 +132,7 @@ const HelpInformation: FC = () => {
|
|||||||
</ListItemAvatar>
|
</ListItemAvatar>
|
||||||
<ListItemText>
|
<ListItemText>
|
||||||
To report an issue or request a feature, please
|
To report an issue or request a feature, please
|
||||||
<Link component="button" variant="body1" onClick={() => onDownload('info')}>
|
<Link component="button" variant="body1" onClick={() => callAPI('info')}>
|
||||||
download
|
download
|
||||||
</Link>
|
</Link>
|
||||||
the debug information and include in a new
|
the debug information and include in a new
|
||||||
@@ -131,7 +160,7 @@ const HelpInformation: FC = () => {
|
|||||||
startIcon={<DownloadIcon />}
|
startIcon={<DownloadIcon />}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => onDownload('settings')}
|
onClick={() => downloadSettings()}
|
||||||
>
|
>
|
||||||
settings
|
settings
|
||||||
</Button>
|
</Button>
|
||||||
@@ -139,7 +168,7 @@ const HelpInformation: FC = () => {
|
|||||||
startIcon={<DownloadIcon />}
|
startIcon={<DownloadIcon />}
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={() => onDownload('customizations')}
|
onClick={() => downloadCustomizations()}
|
||||||
>
|
>
|
||||||
customizations
|
customizations
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -86,3 +86,11 @@ export function resetCustomizations(): AxiosPromise<void> {
|
|||||||
export function API(apiCall: APIcall): AxiosPromise<void> {
|
export function API(apiCall: APIcall): AxiosPromise<void> {
|
||||||
return AXIOS_API.post('/', apiCall);
|
return AXIOS_API.post('/', apiCall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSettings(): AxiosPromise<void> {
|
||||||
|
return AXIOS.get('/getSettings');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCustomizations(): AxiosPromise<void> {
|
||||||
|
return AXIOS.get('/getCustomizations');
|
||||||
|
}
|
||||||
|
|||||||
@@ -1192,16 +1192,19 @@ rest_server.get(SYSTEM_INFO_ENDPOINT, (req, res) => {
|
|||||||
res.json(emsesp_info)
|
res.json(emsesp_info)
|
||||||
})
|
})
|
||||||
|
|
||||||
const SYSTEM_SETTINGS_ENDPOINT = API_ENDPOINT_ROOT + 'system/settings'
|
const GET_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'getSettings'
|
||||||
rest_server.post(SYSTEM_SETTINGS_ENDPOINT, (req, res) => {
|
rest_server.get(GET_SETTINGS_ENDPOINT, (req, res) => {
|
||||||
console.log('System Settings POST: ' + JSON.stringify(req.body))
|
console.log('System Settings:')
|
||||||
res.sendStatus(200)
|
|
||||||
})
|
|
||||||
rest_server.get(SYSTEM_SETTINGS_ENDPOINT, (req, res) => {
|
|
||||||
console.log('System Settings GET')
|
|
||||||
res.json(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
|
// start server
|
||||||
const expressServer = rest_server.listen(port, () =>
|
const expressServer = rest_server.listen(port, () =>
|
||||||
console.log(`Mock server for EMS-ESP is up and running at http://localhost:${port}`),
|
console.log(`Mock server for EMS-ESP is up and running at http://localhost:${port}`),
|
||||||
|
|||||||
@@ -130,6 +130,7 @@
|
|||||||
|
|
||||||
// Heat Pumps - 0x38
|
// Heat Pumps - 0x38
|
||||||
{200, DeviceType::HEATPUMP, F("HP Module"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
{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},
|
{252, DeviceType::HEATPUMP, F("HP Module"), DeviceFlags::EMS_DEVICE_FLAG_NONE},
|
||||||
|
|
||||||
// Connect devices - 0x02
|
// Connect devices - 0x02
|
||||||
|
|||||||
@@ -1163,7 +1163,7 @@ bool Boiler::set_ww_temp(const char * value, const int8_t id) {
|
|||||||
return false;
|
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_UBAFlags, 3, v, EMS_TYPE_UBAParameterWWPlus); // test for #96
|
||||||
write_command(EMS_TYPE_UBAParameterWWPlus, 6, v, EMS_TYPE_UBAParameterWWPlus);
|
write_command(EMS_TYPE_UBAParameterWWPlus, 6, v, EMS_TYPE_UBAParameterWWPlus);
|
||||||
} else {
|
} else {
|
||||||
@@ -1205,7 +1205,7 @@ bool Boiler::set_ww_disinfect_temp(const char * value, const int8_t id) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_fetch(EMS_TYPE_UBAParametersPlus)) {
|
if (is_fetch(EMS_TYPE_UBAParameterWWPlus)) {
|
||||||
write_command(EMS_TYPE_UBAParameterWWPlus, 12, v, EMS_TYPE_UBAParameterWWPlus);
|
write_command(EMS_TYPE_UBAParameterWWPlus, 12, v, EMS_TYPE_UBAParameterWWPlus);
|
||||||
} else {
|
} else {
|
||||||
write_command(EMS_TYPE_UBAParameterWW, 8, v, EMS_TYPE_UBAParameterWW);
|
write_command(EMS_TYPE_UBAParameterWW, 8, v, EMS_TYPE_UBAParameterWW);
|
||||||
|
|||||||
@@ -936,7 +936,7 @@ void Thermostat::process_RC300Summer(std::shared_ptr<const Telegram> telegram) {
|
|||||||
has_update(telegram, hc->offsettemp, 2);
|
has_update(telegram, hc->offsettemp, 2);
|
||||||
if (!is_fetch(summer2_typeids[hc->hc()])) {
|
if (!is_fetch(summer2_typeids[hc->hc()])) {
|
||||||
has_update(telegram, hc->summertemp, 6);
|
has_update(telegram, hc->summertemp, 6);
|
||||||
has_update(telegram, hc->summer_setmode, 7);
|
has_update(telegram, hc->summersetmode, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hc->heatingtype < 3) {
|
if (hc->heatingtype < 3) {
|
||||||
@@ -956,7 +956,7 @@ void Thermostat::process_RC300Summer2(std::shared_ptr<const Telegram> telegram)
|
|||||||
if (hc == nullptr) {
|
if (hc == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
has_update(telegram, hc->summer_setmode, 0);
|
has_update(telegram, hc->hpoperatingmode, 0);
|
||||||
has_update(telegram, hc->summertemp, 1);
|
has_update(telegram, hc->summertemp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,7 +1209,8 @@ void Thermostat::process_RC35Set(std::shared_ptr<const Telegram> telegram) {
|
|||||||
has_update(telegram, hc->vacreducemode, 41); // vacations reduce mode
|
has_update(telegram, hc->vacreducemode, 41); // vacations reduce mode
|
||||||
has_update(telegram, hc->minflowtemp, 16);
|
has_update(telegram, hc->minflowtemp, 16);
|
||||||
|
|
||||||
if (hc->heatingtype == 3) { // floor heating
|
// RC35 stores values for floorheating in different position
|
||||||
|
if (hc->heatingtype == 3 && model() == EMS_DEVICE_FLAG_RC35) {
|
||||||
has_update(telegram, hc->designtemp, 36); // is * 1
|
has_update(telegram, hc->designtemp, 36); // is * 1
|
||||||
has_update(telegram, hc->maxflowtemp, 35); // is * 1
|
has_update(telegram, hc->maxflowtemp, 35); // is * 1
|
||||||
} else { // radiator/convector
|
} else { // radiator/convector
|
||||||
@@ -2309,13 +2310,16 @@ bool Thermostat::set_summermode(const char * value, const int8_t id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t set = 0xFF;
|
uint8_t set = 0xFF;
|
||||||
if (!Helpers::value2enum(value, set, FL_(enum_summermode))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_fetch(summer2_typeids[hc->hc()])) {
|
if (is_fetch(summer2_typeids[hc->hc()])) {
|
||||||
|
if (!Helpers::value2enum(value, set, FL_(enum_hpoperatingmode))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
write_command(summer2_typeids[hc->hc()], 0, set, summer2_typeids[hc->hc()]);
|
write_command(summer2_typeids[hc->hc()], 0, set, summer2_typeids[hc->hc()]);
|
||||||
} else {
|
} else {
|
||||||
|
if (!Helpers::value2enum(value, set, FL_(enum_summermode))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
write_command(summer_typeids[hc->hc()], 7, set, summer_typeids[hc->hc()]);
|
write_command(summer_typeids[hc->hc()], 7, set, summer_typeids[hc->hc()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2924,7 +2928,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
|||||||
factor = 1;
|
factor = 1;
|
||||||
break;
|
break;
|
||||||
case HeatingCircuit::Mode::DESIGN:
|
case HeatingCircuit::Mode::DESIGN:
|
||||||
if (hc->heatingtype == 3) {
|
if (hc->heatingtype == 3 && model == EMS_DEVICE_FLAG_RC35) {
|
||||||
offset = EMS_OFFSET_RC35Set_temp_design_floor;
|
offset = EMS_OFFSET_RC35Set_temp_design_floor;
|
||||||
} else {
|
} else {
|
||||||
offset = EMS_OFFSET_RC35Set_temp_design;
|
offset = EMS_OFFSET_RC35Set_temp_design;
|
||||||
@@ -2963,7 +2967,7 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
|
|||||||
factor = 1;
|
factor = 1;
|
||||||
break;
|
break;
|
||||||
case HeatingCircuit::Mode::MAXFLOW:
|
case HeatingCircuit::Mode::MAXFLOW:
|
||||||
if (hc->heatingtype == 3) {
|
if (hc->heatingtype == 3 && model == EMS_DEVICE_FLAG_RC35) {
|
||||||
offset = 35;
|
offset = 35;
|
||||||
} else {
|
} else {
|
||||||
offset = 15;
|
offset = 15;
|
||||||
@@ -3770,7 +3774,9 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
|
|||||||
register_device_value(
|
register_device_value(
|
||||||
tag, &hc->heatingtype, DeviceValueType::ENUM, FL_(enum_heatingtype), FL_(heatingtype), DeviceValueUOM::NONE, MAKE_CF_CB(set_heatingtype));
|
tag, &hc->heatingtype, DeviceValueType::ENUM, FL_(enum_heatingtype), FL_(heatingtype), DeviceValueUOM::NONE, MAKE_CF_CB(set_heatingtype));
|
||||||
register_device_value(
|
register_device_value(
|
||||||
tag, &hc->summer_setmode, DeviceValueType::ENUM, FL_(enum_summermode), FL_(summersetmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_summermode));
|
tag, &hc->summersetmode, DeviceValueType::ENUM, FL_(enum_summermode), FL_(summersetmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_summermode));
|
||||||
|
register_device_value(
|
||||||
|
tag, &hc->hpoperatingmode, DeviceValueType::ENUM, FL_(enum_hpoperatingmode), FL_(hpoperatingmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_summermode));
|
||||||
register_device_value(tag, &hc->summermode, DeviceValueType::ENUM, FL_(enum_summer), FL_(summermode), DeviceValueUOM::NONE);
|
register_device_value(tag, &hc->summermode, DeviceValueType::ENUM, FL_(enum_summer), FL_(summermode), DeviceValueUOM::NONE);
|
||||||
register_device_value(
|
register_device_value(
|
||||||
tag, &hc->controlmode, DeviceValueType::ENUM, FL_(enum_controlmode), FL_(controlmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_controlmode));
|
tag, &hc->controlmode, DeviceValueType::ENUM, FL_(enum_controlmode), FL_(controlmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_controlmode));
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ class Thermostat : public EMSdevice {
|
|||||||
uint8_t designtemp; // heating curve design temp at MinExtTemp
|
uint8_t designtemp; // heating curve design temp at MinExtTemp
|
||||||
int8_t offsettemp; // heating curve offest temp at roomtemp signed!
|
int8_t offsettemp; // heating curve offest temp at roomtemp signed!
|
||||||
uint8_t manualtemp;
|
uint8_t manualtemp;
|
||||||
uint8_t summer_setmode;
|
uint8_t summersetmode;
|
||||||
|
uint8_t hpoperatingmode;
|
||||||
uint8_t roominfluence;
|
uint8_t roominfluence;
|
||||||
uint8_t roominfl_factor;
|
uint8_t roominfl_factor;
|
||||||
int16_t curroominfl;
|
int16_t curroominfl;
|
||||||
|
|||||||
@@ -645,7 +645,6 @@ std::string EMSESP::pretty_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
std::string src_name("");
|
std::string src_name("");
|
||||||
std::string dest_name("");
|
std::string dest_name("");
|
||||||
std::string type_name("");
|
std::string type_name("");
|
||||||
std::string direction("");
|
|
||||||
for (const auto & emsdevice : emsdevices) {
|
for (const auto & emsdevice : emsdevices) {
|
||||||
if (emsdevice) {
|
if (emsdevice) {
|
||||||
// get src & dest
|
// get src & dest
|
||||||
@@ -682,16 +681,15 @@ std::string EMSESP::pretty_telegram(std::shared_ptr<const Telegram> telegram) {
|
|||||||
type_name = read_flash_string(F("?"));
|
type_name = read_flash_string(F("?"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (telegram->operation == Telegram::Operation::RX_READ) {
|
|
||||||
direction = read_flash_string(F("<-"));
|
|
||||||
} else {
|
|
||||||
direction = read_flash_string(F("->"));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string str;
|
std::string str;
|
||||||
str.reserve(200);
|
str.reserve(200);
|
||||||
str = src_name + "(" + Helpers::hextoa(src) + ") " + direction + " " + dest_name + "(" + Helpers::hextoa(dest) + "), " + type_name + "("
|
if (telegram->operation == Telegram::Operation::RX_READ) {
|
||||||
+ Helpers::hextoa(telegram->type_id) + "), data: " + telegram->to_string_message();
|
str = src_name + "(" + Helpers::hextoa(src) + ") <- " + dest_name + "(" + Helpers::hextoa(dest) + "), " + type_name + "("
|
||||||
|
+ Helpers::hextoa(telegram->type_id) + "), length: " + Helpers::hextoa(telegram->message_data[0]);
|
||||||
|
} else {
|
||||||
|
str = src_name + "(" + Helpers::hextoa(src) + ") -> " + dest_name + "(" + Helpers::hextoa(dest) + "), " + type_name + "("
|
||||||
|
+ Helpers::hextoa(telegram->type_id) + "), data: " + telegram->to_string_message();
|
||||||
|
}
|
||||||
|
|
||||||
if (offset) {
|
if (offset) {
|
||||||
str += " (offset " + Helpers::itoa(offset) + ")";
|
str += " (offset " + Helpers::itoa(offset) + ")";
|
||||||
|
|||||||
@@ -361,6 +361,7 @@ MAKE_PSTR_LIST(enum_wwMode2, F_(off), F_(on), F_(auto))
|
|||||||
MAKE_PSTR_LIST(enum_wwMode3, F_(on), F_(off), F_(auto))
|
MAKE_PSTR_LIST(enum_wwMode3, F_(on), F_(off), F_(auto))
|
||||||
MAKE_PSTR_LIST(enum_heatingtype, F_(off), F_(radiator), F_(convector), F_(floor))
|
MAKE_PSTR_LIST(enum_heatingtype, F_(off), F_(radiator), F_(convector), F_(floor))
|
||||||
MAKE_PSTR_LIST(enum_summermode, F_(summer), F_(auto), F_(winter))
|
MAKE_PSTR_LIST(enum_summermode, F_(summer), F_(auto), F_(winter))
|
||||||
|
MAKE_PSTR_LIST(enum_hpoperatingmode, F_(off), F_(auto), F("heizen"), F("kühlen"))
|
||||||
MAKE_PSTR_LIST(enum_summer, F_(winter), F_(summer))
|
MAKE_PSTR_LIST(enum_summer, F_(winter), F_(summer))
|
||||||
|
|
||||||
MAKE_PSTR_LIST(enum_mode, F_(manual), F_(auto)) // RC100, RC300, RC310
|
MAKE_PSTR_LIST(enum_mode, F_(manual), F_(auto)) // RC100, RC300, RC310
|
||||||
@@ -646,6 +647,7 @@ MAKE_PSTR_LIST(nofrosttemp, F("nofrosttemp"), F("Frostschutztemperatur"))
|
|||||||
MAKE_PSTR_LIST(targetflowtemp, F("targetflowtemp"), F("berechnete Flusstemperatur"))
|
MAKE_PSTR_LIST(targetflowtemp, F("targetflowtemp"), F("berechnete Flusstemperatur"))
|
||||||
MAKE_PSTR_LIST(heatingtype, F("heatingtype"), F("Heizungstyp"))
|
MAKE_PSTR_LIST(heatingtype, F("heatingtype"), F("Heizungstyp"))
|
||||||
MAKE_PSTR_LIST(summersetmode, F("summersetmode"), F("Einstellung Sommerbetrieb"))
|
MAKE_PSTR_LIST(summersetmode, F("summersetmode"), F("Einstellung Sommerbetrieb"))
|
||||||
|
MAKE_PSTR_LIST(hpoperatingmode, F("hpoperatingmode"), F("Wärmepumpe Betriebsmodus"))
|
||||||
MAKE_PSTR_LIST(controlmode, F("controlmode"), F("Kontrollmodus"))
|
MAKE_PSTR_LIST(controlmode, F("controlmode"), F("Kontrollmodus"))
|
||||||
MAKE_PSTR_LIST(control, F("control"), F("Fernsteuerung"))
|
MAKE_PSTR_LIST(control, F("control"), F("Fernsteuerung"))
|
||||||
MAKE_PSTR_LIST(holidays, F("holidays"), F("holiday dates"))
|
MAKE_PSTR_LIST(holidays, F("holidays"), F("holiday dates"))
|
||||||
|
|||||||
@@ -362,6 +362,7 @@ MAKE_PSTR_LIST(enum_wwMode2, F_(off), F_(on), F_(auto))
|
|||||||
MAKE_PSTR_LIST(enum_wwMode3, F_(on), F_(off), F_(auto))
|
MAKE_PSTR_LIST(enum_wwMode3, F_(on), F_(off), F_(auto))
|
||||||
MAKE_PSTR_LIST(enum_heatingtype, F_(off), F_(radiator), F_(convector), F_(floor))
|
MAKE_PSTR_LIST(enum_heatingtype, F_(off), F_(radiator), F_(convector), F_(floor))
|
||||||
MAKE_PSTR_LIST(enum_summermode, F_(summer), F_(auto), F_(winter))
|
MAKE_PSTR_LIST(enum_summermode, F_(summer), F_(auto), F_(winter))
|
||||||
|
MAKE_PSTR_LIST(enum_hpoperatingmode, F_(off), F_(auto), F("heating"), F("cooling"))
|
||||||
MAKE_PSTR_LIST(enum_summer, F_(winter), F_(summer))
|
MAKE_PSTR_LIST(enum_summer, F_(winter), F_(summer))
|
||||||
|
|
||||||
MAKE_PSTR_LIST(enum_mode, F_(manual), F_(auto)) // RC100, RC300, RC310
|
MAKE_PSTR_LIST(enum_mode, F_(manual), F_(auto)) // RC100, RC300, RC310
|
||||||
@@ -636,6 +637,7 @@ MAKE_PSTR_LIST(nofrosttemp, F("nofrosttemp"), F("nofrost temperature"))
|
|||||||
MAKE_PSTR_LIST(targetflowtemp, F("targetflowtemp"), F("target flow temperature"))
|
MAKE_PSTR_LIST(targetflowtemp, F("targetflowtemp"), F("target flow temperature"))
|
||||||
MAKE_PSTR_LIST(heatingtype, F("heatingtype"), F("heating type"))
|
MAKE_PSTR_LIST(heatingtype, F("heatingtype"), F("heating type"))
|
||||||
MAKE_PSTR_LIST(summersetmode, F("summersetmode"), F("set summer mode"))
|
MAKE_PSTR_LIST(summersetmode, F("summersetmode"), F("set summer mode"))
|
||||||
|
MAKE_PSTR_LIST(hpoperatingmode, F("hpoperatingmode"), F("heatpump operating mode"))
|
||||||
MAKE_PSTR_LIST(controlmode, F("controlmode"), F("control mode"))
|
MAKE_PSTR_LIST(controlmode, F("controlmode"), F("control mode"))
|
||||||
MAKE_PSTR_LIST(control, F("control"), F("control device"))
|
MAKE_PSTR_LIST(control, F("control"), F("control device"))
|
||||||
MAKE_PSTR_LIST(holidays, F("holidays"), F("holiday dates"))
|
MAKE_PSTR_LIST(holidays, F("holidays"), F("holiday dates"))
|
||||||
|
|||||||
@@ -689,8 +689,6 @@ void System::commands_init() {
|
|||||||
|
|
||||||
// these commands will return data in JSON format
|
// these commands will return data in JSON format
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, F("show system status"));
|
Command::add(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info, F("show system status"));
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(settings), System::command_settings, F("fetch system settings"), CommandFlag::ADMIN_ONLY);
|
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(customizations), System::command_customizations, F("fetch system customizations"));
|
|
||||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, F("fetch system commands"));
|
Command::add(EMSdevice::DeviceType::SYSTEM, F_(commands), System::command_commands, F("fetch system commands"));
|
||||||
|
|
||||||
#if defined(EMSESP_DEBUG)
|
#if defined(EMSESP_DEBUG)
|
||||||
@@ -973,34 +971,6 @@ bool System::saveSettings(const char * filename, const char * section, JsonObjec
|
|||||||
return false; // not found
|
return false; // not found
|
||||||
}
|
}
|
||||||
|
|
||||||
// export all settings to JSON text
|
|
||||||
// we need to keep the original format so the import/upload works as we just replace files
|
|
||||||
// http://ems-esp/api/system/settings
|
|
||||||
bool System::command_settings(const char * value, const int8_t id, JsonObject & output) {
|
|
||||||
output["type"] = "settings";
|
|
||||||
|
|
||||||
JsonObject node = output.createNestedObject("System");
|
|
||||||
node["version"] = EMSESP_APP_VERSION;
|
|
||||||
|
|
||||||
extractSettings(NETWORK_SETTINGS_FILE, "Network", output);
|
|
||||||
extractSettings(AP_SETTINGS_FILE, "AP", output);
|
|
||||||
extractSettings(MQTT_SETTINGS_FILE, "MQTT", output);
|
|
||||||
extractSettings(NTP_SETTINGS_FILE, "NTP", output);
|
|
||||||
extractSettings(OTA_SETTINGS_FILE, "OTA", output);
|
|
||||||
extractSettings(SECURITY_SETTINGS_FILE, "Security", output);
|
|
||||||
extractSettings(EMSESP_SETTINGS_FILE, "Settings", output);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// http://ems-esp/api/system/customizations
|
|
||||||
// we need to keep the original format so the import/upload works as we just replace file
|
|
||||||
bool System::command_customizations(const char * value, const int8_t id, JsonObject & output) {
|
|
||||||
output["type"] = "customizations";
|
|
||||||
extractSettings(EMSESP_CUSTOMIZATION_FILE, "Customizations", output);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// export status information including the device information
|
// export status information including the device information
|
||||||
// http://ems-esp/api/system/info
|
// http://ems-esp/api/system/info
|
||||||
bool System::command_info(const char * value, const int8_t id, JsonObject & output) {
|
bool System::command_info(const char * value, const int8_t id, JsonObject & output) {
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ class System {
|
|||||||
static bool command_watch(const char * value, const int8_t id);
|
static bool command_watch(const char * value, const int8_t id);
|
||||||
|
|
||||||
static bool command_info(const char * value, const int8_t id, JsonObject & output);
|
static bool command_info(const char * value, const int8_t id, JsonObject & output);
|
||||||
static bool command_settings(const char * value, const int8_t id, JsonObject & output);
|
|
||||||
static bool command_customizations(const char * value, const int8_t id, JsonObject & output);
|
|
||||||
static bool command_commands(const char * value, const int8_t id, JsonObject & output);
|
static bool command_commands(const char * value, const int8_t id, JsonObject & output);
|
||||||
|
|
||||||
std::string reset_reason(uint8_t cpu) const;
|
std::string reset_reason(uint8_t cpu) const;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
static QueueHandle_t uart_queue;
|
static QueueHandle_t uart_queue;
|
||||||
uint8_t tx_mode_;
|
uint8_t tx_mode_ = 0xFF;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* receive task, wait for break and call incoming_telegram
|
* receive task, wait for break and call incoming_telegram
|
||||||
@@ -58,7 +58,7 @@ void EMSuart::uart_event_task(void * pvParameters) {
|
|||||||
uart_read_bytes(EMSUART_NUM, buf, length, portMAX_DELAY);
|
uart_read_bytes(EMSUART_NUM, buf, length, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
length = 0;
|
length = 0;
|
||||||
} else if (event.type == UART_BUFFER_FULL) { // if we miss something
|
} else if (event.type == UART_BUFFER_FULL) {
|
||||||
uart_flush_input(EMSUART_NUM);
|
uart_flush_input(EMSUART_NUM);
|
||||||
length = 0;
|
length = 0;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@ void EMSuart::uart_event_task(void * pvParameters) {
|
|||||||
* init UART driver
|
* init UART driver
|
||||||
*/
|
*/
|
||||||
void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t tx_gpio) {
|
void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t tx_gpio) {
|
||||||
if (!uart_is_driver_installed(EMSUART_NUM)) {
|
if (tx_mode_ == 0xFF) {
|
||||||
uart_config_t uart_config = {
|
uart_config_t uart_config = {
|
||||||
.baud_rate = EMSUART_BAUD,
|
.baud_rate = EMSUART_BAUD,
|
||||||
.data_bits = UART_DATA_8_BITS,
|
.data_bits = UART_DATA_8_BITS,
|
||||||
@@ -85,7 +85,7 @@ void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t
|
|||||||
uart_set_pin(EMSUART_NUM, tx_gpio, rx_gpio, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
uart_set_pin(EMSUART_NUM, tx_gpio, rx_gpio, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||||
uart_set_rx_full_threshold(EMSUART_NUM, 1);
|
uart_set_rx_full_threshold(EMSUART_NUM, 1);
|
||||||
uart_set_rx_timeout(EMSUART_NUM, 0); // disable
|
uart_set_rx_timeout(EMSUART_NUM, 0); // disable
|
||||||
xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, configMAX_PRIORITIES - 1, NULL);
|
xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, configMAX_PRIORITIES - 3, NULL);
|
||||||
}
|
}
|
||||||
tx_mode_ = tx_mode;
|
tx_mode_ = tx_mode;
|
||||||
uart_enable_intr_mask(EMSUART_NUM, UART_BRK_DET_INT_ENA | UART_RXFIFO_FULL_INT_ENA);
|
uart_enable_intr_mask(EMSUART_NUM, UART_BRK_DET_INT_ENA | UART_RXFIFO_FULL_INT_ENA);
|
||||||
@@ -95,7 +95,9 @@ void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t
|
|||||||
* Stop, disable interrupt
|
* Stop, disable interrupt
|
||||||
*/
|
*/
|
||||||
void EMSuart::stop() {
|
void EMSuart::stop() {
|
||||||
uart_disable_intr_mask(EMSUART_NUM, UART_BRK_DET_INT_ENA | UART_RXFIFO_FULL_INT_ENA);
|
if (tx_mode_ != 0xFF) { // only call after driver initialisation
|
||||||
|
uart_disable_intr_mask(EMSUART_NUM, UART_BRK_DET_INT_ENA | UART_RXFIFO_FULL_INT_ENA);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.4.0b17idf4"
|
#define EMSESP_APP_VERSION "3.4.0b18idf4"
|
||||||
|
|||||||
@@ -32,6 +32,12 @@ WebAPIService::WebAPIService(AsyncWebServer * server, SecurityManager * security
|
|||||||
, _apiHandler("/api", std::bind(&WebAPIService::webAPIService_post, this, _1, _2), 256) { // for POSTS, must use 'Content-Type: application/json' in header
|
, _apiHandler("/api", std::bind(&WebAPIService::webAPIService_post, this, _1, _2), 256) { // for POSTS, must use 'Content-Type: application/json' in header
|
||||||
server->on("/api", HTTP_GET, std::bind(&WebAPIService::webAPIService_get, this, _1)); // for GETS
|
server->on("/api", HTTP_GET, std::bind(&WebAPIService::webAPIService_get, this, _1)); // for GETS
|
||||||
server->addHandler(&_apiHandler);
|
server->addHandler(&_apiHandler);
|
||||||
|
|
||||||
|
// for settings
|
||||||
|
server->on(GET_SETTINGS_PATH, HTTP_GET, securityManager->wrapRequest(std::bind(&WebAPIService::getSettings, this, _1), AuthenticationPredicates::IS_ADMIN));
|
||||||
|
server->on(GET_CUSTOMIZATIONS_PATH,
|
||||||
|
HTTP_GET,
|
||||||
|
securityManager->wrapRequest(std::bind(&WebAPIService::getCustomizations, this, _1), AuthenticationPredicates::IS_ADMIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTP GET
|
// HTTP GET
|
||||||
@@ -150,4 +156,37 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebAPIService::getSettings(AsyncWebServerRequest * request) {
|
||||||
|
auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XLARGE_DYN);
|
||||||
|
JsonObject root = response->getRoot();
|
||||||
|
|
||||||
|
root["type"] = "settings";
|
||||||
|
|
||||||
|
JsonObject node = root.createNestedObject("System");
|
||||||
|
node["version"] = EMSESP_APP_VERSION;
|
||||||
|
|
||||||
|
System::extractSettings(NETWORK_SETTINGS_FILE, "Network", root);
|
||||||
|
System::extractSettings(AP_SETTINGS_FILE, "AP", root);
|
||||||
|
System::extractSettings(MQTT_SETTINGS_FILE, "MQTT", root);
|
||||||
|
System::extractSettings(NTP_SETTINGS_FILE, "NTP", root);
|
||||||
|
System::extractSettings(OTA_SETTINGS_FILE, "OTA", root);
|
||||||
|
System::extractSettings(SECURITY_SETTINGS_FILE, "Security", root);
|
||||||
|
System::extractSettings(EMSESP_SETTINGS_FILE, "Settings", root);
|
||||||
|
|
||||||
|
response->setLength();
|
||||||
|
request->send(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebAPIService::getCustomizations(AsyncWebServerRequest * request) {
|
||||||
|
auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XLARGE_DYN);
|
||||||
|
JsonObject root = response->getRoot();
|
||||||
|
|
||||||
|
root["type"] = "customizations";
|
||||||
|
|
||||||
|
System::extractSettings(EMSESP_CUSTOMIZATION_FILE, "Customizations", root);
|
||||||
|
|
||||||
|
response->setLength();
|
||||||
|
request->send(response);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
#define WebAPIService_h
|
#define WebAPIService_h
|
||||||
|
|
||||||
#define EMSESP_API_SERVICE_PATH "/api"
|
#define EMSESP_API_SERVICE_PATH "/api"
|
||||||
|
#define GET_SETTINGS_PATH "/rest/getSettings"
|
||||||
|
#define GET_CUSTOMIZATIONS_PATH "/rest/getCustomizations"
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
@@ -46,6 +48,9 @@ class WebAPIService {
|
|||||||
static uint16_t api_fails_;
|
static uint16_t api_fails_;
|
||||||
|
|
||||||
void parse(AsyncWebServerRequest * request, JsonObject & input);
|
void parse(AsyncWebServerRequest * request, JsonObject & input);
|
||||||
|
|
||||||
|
void getSettings(AsyncWebServerRequest * request);
|
||||||
|
void getCustomizations(AsyncWebServerRequest * request);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
Reference in New Issue
Block a user