mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 08:49:52 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev
This commit is contained in:
@@ -314,16 +314,6 @@ const SystemStatus: FC = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<List>
|
<List>
|
||||||
<ListItem>
|
|
||||||
<ListItemAvatar>
|
|
||||||
<Avatar sx={{ bgcolor: busStatusHighlight(), color: 'white' }}>
|
|
||||||
<DirectionsBusIcon />
|
|
||||||
</Avatar>
|
|
||||||
</ListItemAvatar>
|
|
||||||
<ListItemText primary={LL.EMS_BUS_STATUS()} secondary={busStatus()} />
|
|
||||||
</ListItem>
|
|
||||||
<Divider variant="inset" component="li" />
|
|
||||||
|
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar sx={{ bgcolor: '#c5572c', color: 'white' }}>
|
<Avatar sx={{ bgcolor: '#c5572c', color: 'white' }}>
|
||||||
@@ -347,7 +337,6 @@ const SystemStatus: FC = () => {
|
|||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
<Divider variant="inset" component="li" />
|
<Divider variant="inset" component="li" />
|
||||||
|
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar sx={{ bgcolor: '#5d89f7', color: 'white' }}>
|
<Avatar sx={{ bgcolor: '#5d89f7', color: 'white' }}>
|
||||||
@@ -375,8 +364,8 @@ const SystemStatus: FC = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Divider variant="inset" component="li" />
|
|
||||||
|
|
||||||
|
<Divider variant="inset" component="li" />
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
disabled={!me.admin}
|
disabled={!me.admin}
|
||||||
icon={BuildIcon}
|
icon={BuildIcon}
|
||||||
@@ -385,8 +374,18 @@ const SystemStatus: FC = () => {
|
|||||||
text={data.emsesp_version}
|
text={data.emsesp_version}
|
||||||
to="/settings/upload"
|
to="/settings/upload"
|
||||||
/>
|
/>
|
||||||
<Divider variant="inset" component="li" />
|
|
||||||
|
|
||||||
|
<Divider variant="inset" component="li" />
|
||||||
|
<ListMenuItem
|
||||||
|
disabled={!me.admin}
|
||||||
|
icon={DirectionsBusIcon}
|
||||||
|
bgcolor={busStatusHighlight()}
|
||||||
|
label={LL.EMS_BUS_STATUS()}
|
||||||
|
text={busStatus()}
|
||||||
|
to="/system/activity"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Divider variant="inset" component="li" />
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
disabled={!me.admin}
|
disabled={!me.admin}
|
||||||
icon={MemoryIcon}
|
icon={MemoryIcon}
|
||||||
@@ -395,8 +394,8 @@ const SystemStatus: FC = () => {
|
|||||||
text={formatNumber(data.free_heap) + ' KB' + ' ' + LL.FREE_MEMORY()}
|
text={formatNumber(data.free_heap) + ' KB' + ' ' + LL.FREE_MEMORY()}
|
||||||
to="/system/espsystemstatus"
|
to="/system/espsystemstatus"
|
||||||
/>
|
/>
|
||||||
<Divider variant="inset" component="li" />
|
|
||||||
|
|
||||||
|
<Divider variant="inset" component="li" />
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
disabled={!me.admin}
|
disabled={!me.admin}
|
||||||
icon={
|
icon={
|
||||||
@@ -409,8 +408,8 @@ const SystemStatus: FC = () => {
|
|||||||
text={networkStatus()}
|
text={networkStatus()}
|
||||||
to="/settings/network/status"
|
to="/settings/network/status"
|
||||||
/>
|
/>
|
||||||
<Divider variant="inset" component="li" />
|
|
||||||
|
|
||||||
|
<Divider variant="inset" component="li" />
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
disabled={!me.admin}
|
disabled={!me.admin}
|
||||||
icon={DeviceHubIcon}
|
icon={DeviceHubIcon}
|
||||||
@@ -419,8 +418,8 @@ const SystemStatus: FC = () => {
|
|||||||
text={data.mqtt_status ? LL.ACTIVE() : LL.INACTIVE(0)}
|
text={data.mqtt_status ? LL.ACTIVE() : LL.INACTIVE(0)}
|
||||||
to="/settings/mqtt/status"
|
to="/settings/mqtt/status"
|
||||||
/>
|
/>
|
||||||
<Divider variant="inset" component="li" />
|
|
||||||
|
|
||||||
|
<Divider variant="inset" component="li" />
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
disabled={!me.admin}
|
disabled={!me.admin}
|
||||||
icon={AccessTimeIcon}
|
icon={AccessTimeIcon}
|
||||||
@@ -429,8 +428,8 @@ const SystemStatus: FC = () => {
|
|||||||
text={ntpStatus()}
|
text={ntpStatus()}
|
||||||
to="/settings/ntp/status"
|
to="/settings/ntp/status"
|
||||||
/>
|
/>
|
||||||
<Divider variant="inset" component="li" />
|
|
||||||
|
|
||||||
|
<Divider variant="inset" component="li" />
|
||||||
<ListMenuItem
|
<ListMenuItem
|
||||||
disabled={!me.admin}
|
disabled={!me.admin}
|
||||||
icon={SettingsInputAntennaIcon}
|
icon={SettingsInputAntennaIcon}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ChunkPrint : public Print {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// added msgPack by Proddy
|
// added msgPack by proddy for EMS-ESP
|
||||||
class AsyncJsonResponse : public AsyncAbstractResponse {
|
class AsyncJsonResponse : public AsyncAbstractResponse {
|
||||||
protected:
|
protected:
|
||||||
JsonDocument _jsonBuffer;
|
JsonDocument _jsonBuffer;
|
||||||
|
|||||||
@@ -329,9 +329,7 @@ class AsyncWebServerRequest {
|
|||||||
AsyncResponseStream * beginResponseStream(const String & contentType, size_t bufferSize = 1460);
|
AsyncResponseStream * beginResponseStream(const String & contentType, size_t bufferSize = 1460);
|
||||||
AsyncWebServerResponse * beginResponse_P(int code, const String & contentType, const uint8_t * content, size_t len, AwsTemplateProcessor callback = nullptr);
|
AsyncWebServerResponse * beginResponse_P(int code, const String & contentType, const uint8_t * content, size_t len, AwsTemplateProcessor callback = nullptr);
|
||||||
AsyncWebServerResponse * beginResponse_P(int code, const String & contentType, PGM_P content, AwsTemplateProcessor callback = nullptr);
|
AsyncWebServerResponse * beginResponse_P(int code, const String & contentType, PGM_P content, AwsTemplateProcessor callback = nullptr);
|
||||||
|
AsyncWebServerResponse * beginResponse(const String & contentType, const uint8_t * content, size_t len); // added by proddy for EMS-ESP
|
||||||
// added by proddy for EMS-ESP
|
|
||||||
AsyncWebServerResponse * beginResponse(const String & contentType, const uint8_t * content, size_t len);
|
|
||||||
|
|
||||||
size_t headers() const; // get header count
|
size_t headers() const; // get header count
|
||||||
bool hasHeader(const String & name) const; // check if header exists
|
bool hasHeader(const String & name) const; // check if header exists
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -580,6 +580,7 @@ void Mqtt::ha_status() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// These come from the heartbeat MQTT topic
|
// These come from the heartbeat MQTT topic
|
||||||
|
// we don't use camelCase as it would change the HA entity_id and impact historic data
|
||||||
publish_system_ha_sensor_config(DeviceValueType::STRING, "EMS Bus", "bus_status", DeviceValueUOM::NONE);
|
publish_system_ha_sensor_config(DeviceValueType::STRING, "EMS Bus", "bus_status", DeviceValueUOM::NONE);
|
||||||
publish_system_ha_sensor_config(DeviceValueType::STRING, "Uptime", "uptime", DeviceValueUOM::NONE);
|
publish_system_ha_sensor_config(DeviceValueType::STRING, "Uptime", "uptime", DeviceValueUOM::NONE);
|
||||||
publish_system_ha_sensor_config(DeviceValueType::INT8, "Uptime (sec)", "uptime_sec", DeviceValueUOM::SECONDS);
|
publish_system_ha_sensor_config(DeviceValueType::INT8, "Uptime (sec)", "uptime_sec", DeviceValueUOM::SECONDS);
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@ bool System::get_value_info(JsonObject root, const char * command) {
|
|||||||
|
|
||||||
// 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
|
||||||
|
// TODO camelCase - #1860
|
||||||
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) {
|
||||||
JsonObject node;
|
JsonObject node;
|
||||||
|
|
||||||
@@ -1413,7 +1414,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
|||||||
#endif
|
#endif
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & settings) {
|
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & settings) {
|
||||||
if (WiFi.status() == WL_CONNECTED && !settings.bssid.isEmpty()) {
|
if (WiFi.status() == WL_CONNECTED && !settings.bssid.isEmpty()) {
|
||||||
node["BSSID"] = "set"; // TODO why is this not the actual value??
|
node["BSSID"] = "set"; // we don't disclose the name
|
||||||
}
|
}
|
||||||
node["TxPower setting"] = settings.tx_power;
|
node["TxPower setting"] = settings.tx_power;
|
||||||
node["static ip config"] = settings.staticIPConfig;
|
node["static ip config"] = settings.staticIPConfig;
|
||||||
@@ -1591,6 +1592,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
|
|||||||
obj["name"] = emsdevice->name(); // custom name
|
obj["name"] = emsdevice->name(); // custom name
|
||||||
obj["device id"] = Helpers::hextoa(emsdevice->device_id());
|
obj["device id"] = Helpers::hextoa(emsdevice->device_id());
|
||||||
obj["product id"] = emsdevice->product_id();
|
obj["product id"] = emsdevice->product_id();
|
||||||
|
obj["brand"] = emsdevice->brand_to_char();
|
||||||
obj["version"] = emsdevice->version();
|
obj["version"] = emsdevice->version();
|
||||||
obj["entities"] = emsdevice->count_entities();
|
obj["entities"] = emsdevice->count_entities();
|
||||||
char result[500];
|
char result[500];
|
||||||
|
|||||||
@@ -146,3 +146,23 @@ Content-Type: application/json
|
|||||||
< ./standalone_file_export/emsesp_settings.json
|
< ./standalone_file_export/emsesp_settings.json
|
||||||
------WebKitFormBoundary7MA4YWxkTrZu0gW--
|
------WebKitFormBoundary7MA4YWxkTrZu0gW--
|
||||||
|
|
||||||
|
# test calling Home Assistant script
|
||||||
|
# https://developers.home-assistant.io/docs/api/rest/#post-apiservicesdomainservice
|
||||||
|
POST {{host_standalone}}/api
|
||||||
|
|
||||||
|
# HA
|
||||||
|
|
||||||
|
@ha = http://192.168.1.42:8123
|
||||||
|
@ha_token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIwMzMyZjU1MjhlZmM0NGIyOTgyMjIxNThiODU1NDkyNSIsImlhdCI6MTcyMTMwNDg2NSwiZXhwIjoyMDM2NjY0ODY1fQ.Q-Y7E_i7clH3ff4Ma-OMmhZfbN7aMi_CahKwmoar
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
GET {{ha}}/api/services
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer {{ha_token}}
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
POST {{ha}}/api/services/script/test_notify
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: Bearer {{ha_token}}
|
||||||
|
|||||||
16
test/api_test.sh
Executable file
16
test/api_test.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# API
|
||||||
|
|
||||||
|
curl -X GET http://ems-esp.local/api/system/info
|
||||||
|
echo "\n"
|
||||||
|
|
||||||
|
# HA
|
||||||
|
|
||||||
|
ha_url="http://192.168.1.42:8123"
|
||||||
|
ha_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIwMzMyZjU1MjhlZmM0NGIyOTgyMjIxNThiODU1NDkyNSIsImlhdCI6MTcyMTMwNDg2NSwiZXhwIjoyMDM2NjY0ODY1fQ.Q-Y7E_i7clH3ff4Ma-OMmhZfbN7aMi_CahKwmoar"
|
||||||
|
|
||||||
|
curl -X POST \
|
||||||
|
${ha_url}/api/services/script/test_notify \
|
||||||
|
-H "Authorization: Bearer ${ha_token}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
Reference in New Issue
Block a user