Skip to content

Commit

Permalink
Merge pull request #1572 from proddy/dev
Browse files Browse the repository at this point in the history
update web standalone with variable custom entity
  • Loading branch information
proddy authored Jan 20, 2024
2 parents ec411a7 + d992224 commit 1b27e1f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 2 additions & 0 deletions mock-api/Handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,7 @@ let emsesp_customentities = {
entities: [
{
id: 0,
ram: 0,
device_id: 8,
type_id: 24,
offset: 0,
Expand All @@ -2082,6 +2083,7 @@ let emsesp_customentities = {
},
{
id: 1,
ram: 0,
device_id: 16,
type_id: 797,
offset: 0,
Expand Down
4 changes: 2 additions & 2 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,9 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
}
return devices_list;
} 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)) {
std::vector<std::string> command_list;
for (const auto & cf : Command::commands()) {
if (cf.device_type_ == device_type) {
command_list.emplace_back(cf.cmd_);
Expand Down
1 change: 0 additions & 1 deletion src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) {
// extract the shortname from the key, which is in brackets
std::size_t first_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));

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);
Expand Down
9 changes: 3 additions & 6 deletions src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ void System::send_info_mqtt() {
}

// create the json for heartbeat
bool System::heartbeat_json(JsonObject output) {
void System::heartbeat_json(JsonObject output) {
uint8_t bus_status = EMSESP::bus_status();
if (bus_status == EMSESP::BUS_STATUS_TX_ERRORS) {
output["bus_status"] = "txerror";
Expand Down Expand Up @@ -681,8 +681,6 @@ bool System::heartbeat_json(JsonObject output) {
output["wifistrength"] = wifi_quality(rssi);
}
#endif

return true;
}

// send periodic MQTT message with system information
Expand All @@ -697,9 +695,8 @@ void System::send_heartbeat() {
JsonDocument doc;
JsonObject json = doc.to<JsonObject>();

if (heartbeat_json(json)) {
Mqtt::queue_publish(F_(heartbeat), json); // send to MQTT with retain off. This will add to MQTT queue.
}
heartbeat_json(json);
Mqtt::queue_publish(F_(heartbeat), json); // send to MQTT with retain off. This will add to MQTT queue.
}

// initializes network
Expand Down
2 changes: 1 addition & 1 deletion src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class System {
void syslog_init();
bool check_upgrade(bool factory_settings);
bool check_restore();
bool heartbeat_json(JsonObject output);
void heartbeat_json(JsonObject output);
void send_heartbeat();
void send_info_mqtt();

Expand Down
2 changes: 1 addition & 1 deletion src/temperaturesensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
output["id"] = sensor.id();
output["name"] = sensor.name();
char val[10];
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));
}

Expand Down

0 comments on commit 1b27e1f

Please sign in to comment.