show unknown devices as generic

This commit is contained in:
proddy
2020-10-17 16:53:45 +02:00
parent 87d49be7b3
commit d613e8ff9c
5 changed files with 106 additions and 3 deletions

48
src/devices/generic.cpp Normal file
View File

@@ -0,0 +1,48 @@
/*
* EMS-ESP - https://github.com/proddy/EMS-ESP
* Copyright 2019 Paul Derbyshire
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "generic.h"
namespace emsesp {
REGISTER_FACTORY(Generic, EMSdevice::DeviceType::GENERIC);
uuid::log::Logger Generic::logger_{F_(generic), uuid::log::Facility::CONSOLE};
Generic::Generic(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand)
: EMSdevice(device_type, device_id, product_id, version, name, flags, brand) {
}
void Generic::device_info_web(JsonArray & root) {
}
// display all values into the shell console
void Generic::show_values(uuid::console::Shell & shell) {
// EMSdevice::show_values(shell); // always call this to show header
}
// publish values via MQTT
void Generic::publish_values(JsonObject & data) {
}
// check to see if values have been updated
bool Generic::updated_values() {
return false;
}
} // namespace emsesp

49
src/devices/generic.h Normal file
View File

@@ -0,0 +1,49 @@
/*
* EMS-ESP - https://github.com/proddy/EMS-ESP
* Copyright 2019 Paul Derbyshire
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EMSESP_GENERIC_H
#define EMSESP_GENERIC_H
#include <Arduino.h>
#include <ArduinoJson.h>
#include <uuid/log.h>
#include "emsdevice.h"
#include "telegram.h"
#include "helpers.h"
#include "mqtt.h"
namespace emsesp {
class Generic : public EMSdevice {
public:
Generic(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand);
virtual void show_values(uuid::console::Shell & shell);
virtual void publish_values(JsonObject & data);
virtual void device_info_web(JsonArray & root);
virtual bool updated_values();
private:
static uuid::log::Logger logger_;
};
} // namespace emsesp
#endif

View File

@@ -90,10 +90,13 @@ MAKE_PSTR_WORD(gateway)
MAKE_PSTR_WORD(controller) MAKE_PSTR_WORD(controller)
MAKE_PSTR_WORD(connect) MAKE_PSTR_WORD(connect)
MAKE_PSTR_WORD(heatpump) MAKE_PSTR_WORD(heatpump)
MAKE_PSTR_WORD(generic)
// dallas sensors // dallas sensors
MAKE_PSTR_WORD(sensor) MAKE_PSTR_WORD(sensor)
MAKE_PSTR(1space, " ")
MAKE_PSTR(2spaces, " ")
MAKE_PSTR(kwh, "kWh") MAKE_PSTR(kwh, "kWh")
MAKE_PSTR(wh, "Wh") MAKE_PSTR(wh, "Wh")
MAKE_PSTR(master_thermostat_fmt, "Master Thermostat Device ID = %s") MAKE_PSTR(master_thermostat_fmt, "Master Thermostat Device ID = %s")

View File

@@ -28,7 +28,7 @@ namespace emsesp {
// used with the 'test' command, under su/admin // used with the 'test' command, under su/admin
void Test::run_test(uuid::console::Shell & shell, const std::string & command) { void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
if (command == "default") { if (command == "default") {
run_test(shell, "mixing"); // add the default test case here run_test(shell, "unknown"); // add the default test case here
} }
if (command.empty()) { if (command.empty()) {
@@ -172,7 +172,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
// note there is no brand (byte 9) // note there is no brand (byte 9)
rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x59, 0x09, 0x0a}); rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x59, 0x09, 0x0a});
EMSESP::show_device_values(shell); shell.invoke_command("show devices");
shell.invoke_command("call system report");
} }
if (command == "unknown2") { if (command == "unknown2") {
@@ -808,6 +809,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) {
uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A}); uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A});
shell.invoke_command("show"); shell.invoke_command("show");
shell.invoke_command("call");
shell.invoke_command("call system report");
} }
// finally dump to console // finally dump to console

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "2.1.0b7" #define EMSESP_APP_VERSION "2.1.0b8"