Merge pull request #1572 from proddy/dev

update web standalone with variable custom entity
This commit is contained in:
Proddy
2024-01-20 21:00:20 +01:00
committed by GitHub
6 changed files with 9 additions and 11 deletions

View File

@@ -2070,6 +2070,7 @@ let emsesp_customentities = {
entities: [ entities: [
{ {
id: 0, id: 0,
ram: 0,
device_id: 8, device_id: 8,
type_id: 24, type_id: 24,
offset: 0, offset: 0,
@@ -2082,6 +2083,7 @@ let emsesp_customentities = {
}, },
{ {
id: 1, id: 1,
ram: 0,
device_id: 16, device_id: 16,
type_id: 797, type_id: 797,
offset: 0, offset: 0,

View File

@@ -563,9 +563,9 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
} }
return devices_list; return devices_list;
} else if (current_arguments.size() == 1) { } else if (current_arguments.size() == 1) {
std::vector<std::string> command_list; uint8_t device_type = EMSdevice::device_name_2_device_type(current_arguments[0].c_str());
uint8_t device_type = EMSdevice::device_name_2_device_type(current_arguments[0].c_str());
if (Command::device_has_commands(device_type)) { if (Command::device_has_commands(device_type)) {
std::vector<std::string> command_list;
for (const auto & cf : Command::commands()) { for (const auto & cf : Command::commands()) {
if (cf.device_type_ == device_type) { if (cf.device_type_ == device_type) {
command_list.emplace_back(cf.cmd_); command_list.emplace_back(cf.cmd_);

View File

@@ -392,7 +392,6 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) {
// extract the shortname from the key, which is in brackets // extract the shortname from the key, which is in brackets
std::size_t first_bracket = key.find_last_of('('); std::size_t first_bracket = key.find_last_of('(');
std::size_t last_bracket = key.find_last_of(')'); std::size_t last_bracket = key.find_last_of(')');
std::string shortname = key.substr(first_bracket + 1, last_bracket - first_bracket - 1);
std::string uom = emsdevice->get_value_uom(key.substr(first_bracket + 1, last_bracket - first_bracket - 1)); std::string uom = emsdevice->get_value_uom(key.substr(first_bracket + 1, last_bracket - first_bracket - 1));
shell.printfln(" %s: %s%s %s%s", key.c_str(), COLOR_BRIGHT_GREEN, p.value().as<std::string>().c_str(), uom.c_str(), COLOR_RESET); shell.printfln(" %s: %s%s %s%s", key.c_str(), COLOR_BRIGHT_GREEN, p.value().as<std::string>().c_str(), uom.c_str(), COLOR_RESET);

View File

@@ -629,7 +629,7 @@ void System::send_info_mqtt() {
} }
// create the json for heartbeat // create the json for heartbeat
bool System::heartbeat_json(JsonObject output) { void System::heartbeat_json(JsonObject output) {
uint8_t bus_status = EMSESP::bus_status(); uint8_t bus_status = EMSESP::bus_status();
if (bus_status == EMSESP::BUS_STATUS_TX_ERRORS) { if (bus_status == EMSESP::BUS_STATUS_TX_ERRORS) {
output["bus_status"] = "txerror"; output["bus_status"] = "txerror";
@@ -681,8 +681,6 @@ bool System::heartbeat_json(JsonObject output) {
output["wifistrength"] = wifi_quality(rssi); output["wifistrength"] = wifi_quality(rssi);
} }
#endif #endif
return true;
} }
// send periodic MQTT message with system information // send periodic MQTT message with system information
@@ -697,9 +695,8 @@ void System::send_heartbeat() {
JsonDocument doc; JsonDocument doc;
JsonObject json = doc.to<JsonObject>(); JsonObject json = doc.to<JsonObject>();
if (heartbeat_json(json)) { heartbeat_json(json);
Mqtt::queue_publish(F_(heartbeat), json); // send to MQTT with retain off. This will add to MQTT queue. Mqtt::queue_publish(F_(heartbeat), json); // send to MQTT with retain off. This will add to MQTT queue.
}
} }
// initializes network // initializes network

View File

@@ -79,7 +79,7 @@ class System {
void syslog_init(); void syslog_init();
bool check_upgrade(bool factory_settings); bool check_upgrade(bool factory_settings);
bool check_restore(); bool check_restore();
bool heartbeat_json(JsonObject output); void heartbeat_json(JsonObject output);
void send_heartbeat(); void send_heartbeat();
void send_info_mqtt(); void send_info_mqtt();

View File

@@ -414,8 +414,8 @@ bool TemperatureSensor::get_value_info(JsonObject output, const char * cmd, cons
if (Helpers::toLower(command_s) == Helpers::toLower(sensor.name().c_str()) || Helpers::toLower(command_s) == Helpers::toLower(sensor.id().c_str())) { if (Helpers::toLower(command_s) == Helpers::toLower(sensor.name().c_str()) || Helpers::toLower(command_s) == Helpers::toLower(sensor.id().c_str())) {
output["id"] = sensor.id(); output["id"] = sensor.id();
output["name"] = sensor.name(); output["name"] = sensor.name();
char val[10];
if (Helpers::hasValue(sensor.temperature_c)) { if (Helpers::hasValue(sensor.temperature_c)) {
char val[10];
output["value"] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0)); output["value"] = serialized(Helpers::render_value(val, sensor.temperature_c, 10, EMSESP::system_.fahrenheit() ? 2 : 0));
} }