mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
added new command called commands
This commit is contained in:
@@ -40,10 +40,17 @@ void DallasSensor::start() {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
bus_.begin(dallas_gpio_);
|
||||
#endif
|
||||
// API call
|
||||
Command::add_with_json(EMSdevice::DeviceType::DALLASSENSOR, F_(info), [&](const char * value, const int8_t id, JsonObject & json) {
|
||||
return command_info(value, id, json);
|
||||
});
|
||||
// API calls
|
||||
Command::add_with_json(
|
||||
EMSdevice::DeviceType::DALLASSENSOR,
|
||||
F_(info),
|
||||
[&](const char * value, const int8_t id, JsonObject & json) { return command_info(value, id, json); },
|
||||
F_(info_cmd));
|
||||
Command::add_with_json(
|
||||
EMSdevice::DeviceType::DALLASSENSOR,
|
||||
F_(commands),
|
||||
[&](const char * value, const int8_t id, JsonObject & json) { return command_commands(value, id, json); },
|
||||
F_(commands_cmd));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,6 +313,11 @@ bool DallasSensor::updated_values() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// list commands
|
||||
bool DallasSensor::command_commands(const char * value, const int8_t id, JsonObject & json) {
|
||||
return Command::list(EMSdevice::DeviceType::DALLASSENSOR, json);
|
||||
}
|
||||
|
||||
// creates JSON doc from values
|
||||
// returns false if empty
|
||||
// e.g. dallassensor_data = {"sensor1":{"id":"28-EA41-9497-0E03-5F","temp":23.30},"sensor2":{"id":"28-233D-9497-0C03-8B","temp":24.0}}
|
||||
@@ -413,7 +425,6 @@ void DallasSensor::publish_values(const bool force) {
|
||||
sensor_no++; // increment sensor count
|
||||
}
|
||||
|
||||
// doc.shrinkToFit();
|
||||
Mqtt::publish(F("dallassensor_data"), doc.as<JsonObject>());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user