This commit is contained in:
MichaelDvP
2023-01-05 11:19:26 +01:00
26 changed files with 11278 additions and 3391 deletions

14370
interface/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
"@emotion/styled": "^11.10.5",
"@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.2",
"@mui/material": "^5.11.3",
"@table-library/react-table-library": "4.0.23",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.18",
@@ -29,7 +29,7 @@
"react-router-dom": "^6.6.1",
"react-scripts": "5.0.1",
"sockette": "^2.0.6",
"typesafe-i18n": "^5.18.0",
"typesafe-i18n": "^5.18.1",
"typescript": "^4.9.4"
},
"scripts": {

View File

@@ -70,7 +70,7 @@ const de: Translation = {
TEMP_SENSOR: 'Temperatursensor',
TEMP_SENSORS: 'Temperatursensoren',
WRITE_CMD_SENT: 'Befehl schreiben wurde gesendet',
WRITE_CMD_FAILED: 'Befehl schreiben failed', // TODO
WRITE_CMD_FAILED: 'Befehl schreiben failed', // TODO translate
EMS_BUS_WARNING: 'EMS-Bus getrennt. Wenn diese Warnung nach einigen Sekunden immer noch besteht, überprüfen Sie bitte die Einstellungen und das Board-Profil',
EMS_BUS_SCANNING: 'Suche nach EMS Geräten...',
CONNECTED: 'Verbunden',

View File

@@ -69,8 +69,8 @@ const fr: Translation = {
SENSOR: 'Capteur',
TEMP_SENSOR: 'Capteur de température',
TEMP_SENSORS: 'Capteurs de température',
WRITE_CMD_SENT: 'Envoyer la commande sent', // TODO
WRITE_CMD_FAILED: 'Envoyer la commande failed', // TODO
WRITE_CMD_SENT: 'Envoyer la commande sent', // TODO translate
WRITE_CMD_FAILED: 'Envoyer la commande failed', // TODO translate
EMS_BUS_WARNING: 'Bus EMS déconnecté. Si ce message persiste après quelques secondes, vérifiez les paramètres et la configuration de la carte.',
EMS_BUS_SCANNING: 'Scan des appareils EMS...',
CONNECTED: 'Connecté',
@@ -249,10 +249,10 @@ const fr: Translation = {
MQTT_INT_HEARTBEAT: 'Battements',
MQTT_QUEUE: 'Queue MQTT',
DEFAULT: 'Défaut',
MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)',// TODO
MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO
MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO
MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO translate
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)',// TODO translate
MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO translate
MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO translate
MQTT_CLEAN_SESSION: 'Flag Clean Session',
MQTT_RETAIN_FLAG: 'Toujours activer le Retain Flag',
INACTIVE: 'Inactif',

View File

@@ -69,8 +69,8 @@ const nl: Translation = {
SENSOR: 'Sensor',
TEMP_SENSOR: 'Temperatuur sensor',
TEMP_SENSORS: 'Temperatuur Sensoren',
WRITE_CMD_SENT: 'Schrijf commando sent', // TODO
WRITE_CMD_FAILED: 'Schrijf commando failed', // TODO
WRITE_CMD_SENT: 'Schrijf commando sent', // TODO translate
WRITE_CMD_FAILED: 'Schrijf commando failed', // TODO translate
EMS_BUS_WARNING: 'EMS bus niet gevonden. Als deze waarschuwing blijft staan na een paar seconden dan loop de instellingen na en in het bijzonder het apparaat type profiel na.',
EMS_BUS_SCANNING: 'Scannen naar EMS apparaten...',
CONNECTED: 'Verbonden',
@@ -249,10 +249,10 @@ const nl: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Default',
MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO
MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO
MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO
MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO translate
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO translate
MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO translate
MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO translate
MQTT_CLEAN_SESSION: 'Clean Session aan',
MQTT_RETAIN_FLAG: 'Retain flag aan',
INACTIVE: 'Inactief',

View File

@@ -69,8 +69,8 @@ const no: Translation = {
SENSOR: 'Sensor',
TEMP_SENSOR: 'Temperatursensor',
TEMP_SENSORS: 'Temperaturesensorer',
WRITE_CMD_SENT: 'Skriv kommando sent', // TODO
WRITE_CMD_FAILED: 'Skriv kommando failed', // TODO
WRITE_CMD_SENT: 'Skriv kommando sent', // TODO translate
WRITE_CMD_FAILED: 'Skriv kommando failed', // TODO translate
EMS_BUS_WARNING: 'EMS bussen koblet ned. Hvis denne advarselen fortsetter etter noen f¨sekunder sjekk instillinger og prosessorkort',
EMS_BUS_SCANNING: 'Søker etter EMS enheter...',
CONNECTED: 'Tilkoblet',
@@ -249,10 +249,10 @@ const no: Translation = {
MQTT_INT_HEARTBEAT: 'Heartbeat',
MQTT_QUEUE: 'MQTT Queue',
DEFAULT: 'Standard',
MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO
MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO
MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO
MQTT_ENTITY_FORMAT: 'Entity ID format', // TODO translate
MQTT_ENTITY_FORMAT_0: 'Single instance, long name (v3.4)', // TODO translate
MQTT_ENTITY_FORMAT_1: 'Single instance, short name', // TODO translate
MQTT_ENTITY_FORMAT_2: 'Multiple instances, short name', // TODO translate
MQTT_CLEAN_SESSION: 'Benytt Clean Session',
MQTT_RETAIN_FLAG: 'Alltid sett Retain flag',
INACTIVE: 'Innaktiv',

View File

@@ -142,7 +142,7 @@ const DashboardData: FC = () => {
common_theme,
{
Table: `
--data-table-library_grid-template-columns: 40px 100px repeat(1, minmax(0, 1fr)) 100px 40px;
--data-table-library_grid-template-columns: 40px 160px repeat(1, minmax(0, 1fr)) 100px 40px;
`,
BaseRow: `
.td {
@@ -704,9 +704,9 @@ const DashboardData: FC = () => {
{tableList.map((device: Device, index: number) => (
<Row key={device.id} item={device}>
<Cell stiff>
<DeviceIcon type={device.t} />
<DeviceIcon type_id={device.t} />
</Cell>
<Cell stiff>{device.t}</Cell>
<Cell stiff>{device.tn}</Cell>
<Cell>{device.n}</Cell>
<Cell stiff>{device.e}</Cell>
<Cell stiff>
@@ -719,7 +719,7 @@ const DashboardData: FC = () => {
{(coreData.active_sensors > 0 || coreData.analog_enabled) && (
<Row key="sensor" item={{ id: 'sensor' }}>
<Cell>
<DeviceIcon type="Sensor" />
<DeviceIcon type_id={1} />
</Cell>
<Cell>Sensors</Cell>
<Cell>{LL.ATTACHED_SENSORS()}</Cell>

View File

@@ -13,33 +13,56 @@ import { AiOutlineAlert } from 'react-icons/ai';
import { AiOutlineChrome } from 'react-icons/ai';
interface DeviceIconProps {
type: string;
type_id: number;
}
const DeviceIcon: FC<DeviceIconProps> = ({ type }) => {
switch (type) {
case 'Boiler':
case 'Heatsource':
return <CgSmartHomeBoiler />;
case 'Sensor':
// matches emsdevice.h DeviceType
const enum DeviceType {
SYSTEM = 0,
DALLASSENSOR,
ANALOGSENSOR,
BOILER,
THERMOSTAT,
MIXER,
SOLAR,
HEATPUMP,
GATEWAY,
SWITCH,
CONTROLLER,
CONNECT,
ALERT,
PUMP,
GENERIC,
HEATSOURCE,
UNKNOWN
}
const DeviceIcon: FC<DeviceIconProps> = ({ type_id }) => {
switch (type_id) {
case DeviceType.DALLASSENSOR:
case DeviceType.ANALOGSENSOR:
return <MdOutlineSensors />;
case 'Solar':
return <FaSolarPanel />;
case 'Thermostat':
case DeviceType.BOILER:
case DeviceType.HEATSOURCE:
return <CgSmartHomeBoiler />;
case DeviceType.THERMOSTAT:
return <MdThermostatAuto />;
case 'Mixer':
case DeviceType.MIXER:
return <AiOutlineControl />;
case 'Heatpump':
case DeviceType.SOLAR:
return <FaSolarPanel />;
case DeviceType.HEATPUMP:
return <GiHeatHaze />;
case 'Switch':
return <TiFlowSwitch />;
case 'Connect':
return <VscVmConnect />;
case 'Gateway':
case DeviceType.GATEWAY:
return <AiOutlineGateway />;
case 'Alert':
case DeviceType.SWITCH:
return <TiFlowSwitch />;
case DeviceType.CONTROLLER:
case DeviceType.CONNECT:
return <VscVmConnect />;
case DeviceType.ALERT:
return <AiOutlineAlert />;
case 'Pump':
case DeviceType.PUMP:
return <AiOutlineChrome />;
default:
return null;

View File

@@ -180,7 +180,7 @@ const SettingsCustomization: FC = () => {
return (
<>
{de.n && (de.n[0] === '!' ? LL.COMMAND() + ': ' + de.n.slice(1) : de.cn && de.cn !== '' ? de.cn : de.n) + ' '}(
<Link target="_blank" href={APIURL + devices?.devices[selectedDevice].t + '/' + de.id}>
<Link target="_blank" href={APIURL + devices?.devices[selectedDevice].tn + '/' + de.id}>
{de.id}
</Link>
)

View File

@@ -59,7 +59,8 @@ export interface Status {
}
export interface Device {
id: string; // id index
t: string; // type
tn: string; // device type translated name
t: number; // device type id
b: string; // brand
n: string; // name
d: number; // deviceid
@@ -110,7 +111,8 @@ export interface DeviceShort {
d?: number; // deviceid
p?: number; // productid
s: string; // shortname
t?: string; // device type name
t?: number; // device type id
tn?: string; // device type internal name
}
export interface Devices {

View File

@@ -37,7 +37,7 @@ class MsgPackDeserializer {
NestingLimit nestingLimit) {
DeserializationError::Code err;
uint8_t code = 0; // TODO: why do we need to initialize this variable?
uint8_t code = 0;
err = readByte(code);
if (err)
return err;

View File

@@ -22,7 +22,7 @@ struct Comparer;
template <typename T>
struct Comparer<T, typename enable_if<IsString<T>::value>::type>
: ComparerBase {
T rhs; // TODO: store adapted string?
T rhs;
explicit Comparer(T value) : rhs(value) {}

View File

@@ -355,17 +355,20 @@ const emsesp_devices = {
{
i: 1,
s: 'Thermostat (RC20/Moduline 300)',
t: 'thermostat',
t: 4,
tn: 'thermostat',
},
{
i: 2,
s: 'Boiler (Nefit GBx72/Trendline/Cerapur/Greenstar Si/27i)',
t: 'boiler',
t: 3,
tn: 'boiler',
},
{
i: 4,
s: 'Thermostat (RC100/Moduline 1000/1010)',
t: 'thermostat',
t: 4,
tn: 'thermostat',
},
],
}
@@ -376,7 +379,8 @@ const emsesp_coredata = {
devices: [
{
id: '2',
t: 'Boiler',
t: 3,
tn: 'Boiler',
b: 'Nefit',
n: 'GBx72/Trendline/Cerapur/Greenstar Si/27i',
d: 8,
@@ -386,7 +390,8 @@ const emsesp_coredata = {
},
{
id: '1',
t: 'Thermostat',
t: 4,
tn: 'Thermostat',
b: '',
n: 'RC20/Moduline 300',
d: 23,
@@ -396,7 +401,8 @@ const emsesp_coredata = {
},
{
id: '4',
t: 'Thermostat',
t: 4,
tn: 'Thermostat',
b: 'Buderus',
n: 'RC100/Moduline 1000/1010',
d: 16,

View File

@@ -68,7 +68,7 @@ std::string EMSdevice::uom_to_string(uint8_t uom) {
}
}
std::string EMSdevice::brand_to_string() const {
const std::string EMSdevice::brand_to_string() {
switch (brand_) {
case EMSdevice::Brand::BOSCH:
return "Bosch";
@@ -89,7 +89,7 @@ std::string EMSdevice::brand_to_string() const {
}
}
// returns the name of the MQTT topic to use for a specific device, without the base
// returns the short name of the device, used in MQTT and console commands, all lowercase
const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) {
switch (device_type) {
case DeviceType::SYSTEM:
@@ -127,7 +127,41 @@ const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) {
}
}
// returns device_type from a string
// returns the translated name of a specific EMS device
// excludes dallassensor, analogsensor and system
const char * EMSdevice::device_type_2_device_name_translated() {
switch (device_type_) {
case DeviceType::BOILER:
return Helpers::translated_word(FL_(boiler_device));
case DeviceType::THERMOSTAT:
return Helpers::translated_word(FL_(thermostat_device));
case DeviceType::HEATPUMP:
return Helpers::translated_word(FL_(heatpump_device));
case DeviceType::SOLAR:
return Helpers::translated_word(FL_(solar_device));
case DeviceType::CONNECT:
return Helpers::translated_word(FL_(connect_device));
case DeviceType::MIXER:
return Helpers::translated_word(FL_(mixer_device));
case DeviceType::CONTROLLER:
return Helpers::translated_word(FL_(controller_device));
case DeviceType::SWITCH:
return Helpers::translated_word(FL_(switch_device));
case DeviceType::GATEWAY:
return Helpers::translated_word(FL_(gateway_device));
case DeviceType::ALERT:
return Helpers::translated_word(FL_(alert_device));
case DeviceType::PUMP:
return Helpers::translated_word(FL_(pump_device));
case DeviceType::HEATSOURCE:
return Helpers::translated_word(FL_(heatsource_device));
default:
break;
}
return Helpers::translated_word(FL_(unknown));
}
// returns device_type from a non-translated EN string
uint8_t EMSdevice::device_name_2_device_type(const char * topic) {
if (!topic) {
return DeviceType::UNKNOWN;
@@ -183,11 +217,9 @@ uint8_t EMSdevice::device_name_2_device_type(const char * topic) {
return DeviceType::UNKNOWN;
}
// return name of the device type, capitalized
std::string EMSdevice::device_type_name() const {
std::string s = device_type_2_device_name(device_type_);
s[0] = toupper(s[0]);
return s;
// return name of the device type, not translated
const char * EMSdevice::device_type_name() {
return device_type_2_device_name(device_type_);
}
// 0=unknown, 1=bosch, 2=junkers, 3=buderus, 4=nefit, 5=sieger, 11=worcester
@@ -213,7 +245,7 @@ uint8_t EMSdevice::decode_brand(uint8_t value) {
}
// returns string of a human friendly description of the EMS device
std::string EMSdevice::to_string() const {
const std::string EMSdevice::to_string() {
// for devices that haven't been lookup yet, don't show all details
if (product_id_ == 0) {
return std::string(name_) + " (DeviceID:" + Helpers::hextoa(device_id_) + ")";
@@ -228,12 +260,13 @@ std::string EMSdevice::to_string() const {
}
// returns out brand + device name
std::string EMSdevice::to_string_short() const {
// translated
const std::string EMSdevice::to_string_short() {
if (brand_ == Brand::NO_BRAND) {
return device_type_name() + ": " + name_;
return std::string(device_type_2_device_name_translated()) + ": " + name_;
}
return device_type_name() + ": " + brand_to_string() + " " + name_;
return std::string(device_type_2_device_name_translated()) + ": " + brand_to_string() + " " + name_;
}
// for each telegram that has the fetch value set (true) do a read request

View File

@@ -31,7 +31,7 @@ class EMSdevice {
public:
virtual ~EMSdevice() = default; // destructor of base class must always be virtual because it's a polymorphic class
static constexpr uint8_t EMS_DEVICES_MAX_TELEGRAMS = 20;
using process_function_p = std::function<void(std::shared_ptr<const Telegram>)>;
// device_type defines which derived class to use, e.g. BOILER, THERMOSTAT etc..
EMSdevice(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand)
@@ -44,13 +44,16 @@ class EMSdevice {
strlcpy(version_, version, sizeof(version_));
}
std::string device_type_name() const;
// static functions, used outside the class like in console.cpp, command.cpp, emsesp.cpp, mqtt.cpp
static const char * device_type_2_device_name(const uint8_t device_type);
static uint8_t device_name_2_device_type(const char * topic);
static std::string uom_to_string(uint8_t uom);
static std::string tag_to_string(uint8_t tag, const bool translate = true);
static std::string tag_to_mqtt(uint8_t tag);
static uint8_t decode_brand(uint8_t value);
const char * device_type_name(); // returns short non-translated device type name
const char * device_type_2_device_name_translated(); // returns translated device type name
bool has_tag(const uint8_t tag) const;
bool has_cmd(const char * cmd, const int8_t id) const;
@@ -113,7 +116,6 @@ class EMSdevice {
return name_;
}
// unique id of a device
inline uint8_t unique_id() const {
return unique_id_;
}
@@ -174,11 +176,9 @@ class EMSdevice {
}
}
std::string brand_to_string() const;
static uint8_t decode_brand(uint8_t value);
std::string to_string() const;
std::string to_string_short() const;
const std::string brand_to_string();
const std::string to_string();
const std::string to_string_short();
enum Handlers : uint8_t { ALL, RECEIVED, FETCHED, PENDING, IGNORED };
@@ -192,8 +192,6 @@ class EMSdevice {
void setCustomEntity(const std::string & entity_id);
void getCustomEntities(std::vector<std::string> & entity_ids);
using process_function_p = std::function<void(std::shared_ptr<const Telegram>)>;
void register_telegram_type(const uint16_t telegram_type_id, const char * telegram_type_name, bool fetch, const process_function_p cb);
bool handle_telegram(std::shared_ptr<const Telegram> telegram);
@@ -201,10 +199,6 @@ class EMSdevice {
bool get_value_info(JsonObject & root, const char * cmd, const int8_t id);
void get_dv_info(JsonObject & json);
#if defined(EMSESP_STANDALONE_DUMP)
void dump_value_info();
#endif
enum OUTPUT_TARGET : uint8_t { API_VERBOSE, API_SHORTNAMES, MQTT, CONSOLE };
bool generate_values(JsonObject & output, const uint8_t tag_filter, const bool nested, const uint8_t output_target);
void generate_values_web(JsonObject & output);
@@ -350,6 +344,8 @@ class EMSdevice {
UNKNOWN
};
static constexpr uint8_t EMS_DEVICES_MAX_TELEGRAMS = 20;
// static device IDs
static constexpr uint8_t EMS_DEVICE_ID_BOILER = 0x08; // fixed device_id for Master Boiler/UBA
static constexpr uint8_t EMS_DEVICE_ID_HS1 = 0x70; // fixed device_id for 1st. Cascade Boiler/UBA
@@ -369,7 +365,7 @@ class EMSdevice {
static constexpr uint8_t EMS_DEVICE_ID_MODEM = 0x48;
static constexpr uint8_t EMS_DEVICE_ID_RFSENSOR = 0x40; // RF sensor only sending, no reply
static constexpr uint8_t EMS_DEVICE_ID_RFBASE = 0x50;
static constexpr uint8_t EMS_DEVICE_ID_ROOMTHERMOSTAT = 0x17; //TADO using this with no version reply
static constexpr uint8_t EMS_DEVICE_ID_ROOMTHERMOSTAT = 0x17; // TADO using this with no version reply
// generic type IDs
static constexpr uint16_t EMS_TYPE_VERSION = 0x02; // type ID for Version information. Generic across all EMS devices.
@@ -419,6 +415,10 @@ class EMSdevice {
uint8_t count_entities();
bool has_entities() const;
#if defined(EMSESP_STANDALONE_DUMP)
void dump_value_info();
#endif
private:
uint8_t unique_id_;
uint8_t device_type_ = DeviceType::SYSTEM;

View File

@@ -355,8 +355,8 @@ void EMSESP::show_device_values(uuid::console::Shell & shell) {
for (const auto & device_class : EMSFactory::device_handlers()) {
for (const auto & emsdevice : emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_class.first)) {
// print header
shell.printfln("%s: %s (%d)", emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str(), emsdevice->count_entities());
// print header, with device type translated
shell.printfln("%s: %s (%d)", emsdevice->device_type_2_device_name_translated(), emsdevice->to_string().c_str(), emsdevice->count_entities());
DynamicJsonDocument doc(EMSESP_JSON_SIZE_XXLARGE_DYN); // use max size
JsonObject json = doc.to<JsonObject>();
@@ -829,7 +829,7 @@ void EMSESP::process_version(std::shared_ptr<const Telegram> telegram) {
// find the device object that matches the deviceID and see if it has a matching telegram type handler
// but only process if the telegram is sent to us or it's a broadcast (dest=0x00=all)
// We also check for common telgram types, like the Version(0x02)
// We also check for common telegram types, like the Version(0x02)
// returns false if there are none found
bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
// if watching or reading...
@@ -950,12 +950,13 @@ void EMSESP::show_devices(uuid::console::Shell & shell) {
}
}
// for all device objects from emsdevice.h (UNKNOWN, SYSTEM, BOILER, THERMOSTAT, MIXER, SOLAR, HEATPUMP, GATEWAY, SWITCH, CONTROLLER, CONNECT)
// for all device objects from emsdevice.h
// so we keep a consistent order
// don't translate the device type name
for (const auto & device_class : EMSFactory::device_handlers()) {
for (const auto & emsdevice : emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_class.first)) {
shell.printf("%s: %s", emsdevice->device_type_name().c_str(), emsdevice->to_string().c_str());
shell.printf("%s: %s", emsdevice->device_type_name(), emsdevice->to_string().c_str());
shell.println();
emsdevice->show_telegram_handlers(shell);

View File

@@ -718,7 +718,8 @@ uint8_t Helpers::count_items(const char * const ** list) {
}
// returns char pointer to translated description or fullname
const char * Helpers::translated_word(const char * const * strings) {
// if force_en is true always take the EN non-translated word
const char * Helpers::translated_word(const char * const * strings, const bool force_en) {
uint8_t language_index = EMSESP::system_.language_index();
uint8_t index = 0;
@@ -727,7 +728,7 @@ const char * Helpers::translated_word(const char * const * strings) {
}
// see how many translations we have for this entity. if there is no translation for this, revert to EN
if (Helpers::count_items(strings) >= language_index + 1 && strlen(strings[language_index])) {
if (force_en || (Helpers::count_items(strings) >= language_index + 1 && strlen(strings[language_index]))) {
index = language_index;
}
return strings[index];

View File

@@ -77,7 +77,7 @@ class Helpers {
static uint8_t count_items(const char * const ** list);
static uint8_t count_items(const char * const * list);
static const char * translated_word(const char * const * strings);
static const char * translated_word(const char * const * strings, const bool force_en = false);
#ifdef EMSESP_STANDALONE
static char * ultostr(char * ptr, uint32_t value, const uint8_t base);

View File

@@ -89,7 +89,7 @@ MAKE_PSTR_WORD(customizations)
MAKE_PSTR_WORD(value)
MAKE_PSTR_WORD(entities)
// devices
// device types - lowercase, used in MQTT
MAKE_PSTR_WORD(boiler)
MAKE_PSTR_WORD(thermostat)
MAKE_PSTR_WORD(switch)

View File

@@ -32,6 +32,21 @@
// translations are in order en, de, nl, sv, pl, no, fr, ....
// if there is no translation, it will default to en
// device types, as display in Web and Console
// TODO need completed translations
MAKE_PSTR_LIST(boiler_device, "Boiler", "Kessel", "Boiler")
MAKE_PSTR_LIST(thermostat_device, "Thermostat", "Thermostat", "Thermostaat")
MAKE_PSTR_LIST(heatpump_device, "Heat Pump", "Wärmepumpe", "Warmtepomp")
MAKE_PSTR_LIST(solar_device, "Solar Module", "Solarmodul", "Solar Module")
MAKE_PSTR_LIST(connect_device, "Connect Module", "Verbindungsmodul", "Connect Module")
MAKE_PSTR_LIST(mixer_device, "Mixer Module", "Mischermodul", "Mixer Module")
MAKE_PSTR_LIST(controller_device, "Controller Module", "Kontrollmodul", "Controller Module")
MAKE_PSTR_LIST(switch_device, "Switch Module","Schaltmodul","Switch Module")
MAKE_PSTR_LIST(gateway_device, "Gateway Module","Gateway Modul","Gateway Module")
MAKE_PSTR_LIST(alert_device, "Alert Module","Alarmmodul","Alert Module")
MAKE_PSTR_LIST(pump_device, "Pump Module","Pumpenmodul","Pump Module")
MAKE_PSTR_LIST(heatsource_device, "Heatsource","Heizquelle","Heatsource")
// commands
MAKE_PSTR_LIST(info_cmd, "lists all values", "Liste aller Werte")
MAKE_PSTR_LIST(commands_cmd, "lists all commands", "Liste aller Kommandos")
@@ -134,7 +149,7 @@ MAKE_PSTR_LIST(vacuum, "vacuum", "Vakuum", "vacuum", "Vakuum", "próżnia", "vak
MAKE_PSTR_LIST(co2_optimized, "co2 optimized", "CO2 optimiert", "CO2 geoptimaliseerd", "CO2-optimerad", "optymalizacja CO2", "co2 optimalisert", "optimisé en CO2")
MAKE_PSTR_LIST(cost_optimized, "cost optimized", "kostenoptimiert", "kosten geoptimaliseerd", "kostnadsoptimerad", "optymalizacja kosztów", "kostnadsoptimalisert", "optimisé en coût")
MAKE_PSTR_LIST(outside_temp_switched, "outside temp switched", "Außentemp. gesteuert", "Buitentemp. gestuurd", "Utomhustemp korrigerad", "temperatura zewn. przeł.", "utetemp optimalisert", "contrôle par temp. ext.")
MAKE_PSTR_LIST(co2_cost_mix, "co2 cost mix", "Kostenmix", "Kostenmix", "Kostnadsmix", "mieszany koszt CO2", "", "coût mixte CO2")
MAKE_PSTR_LIST(co2_cost_mix, "co2 cost mix", "Kostenmix", "Kostenmix", "Kostnadsmix", "mieszany koszt CO2", "", "coût mixte CO2") // TODO translate
MAKE_PSTR_LIST(analog, "analog", "analog", "analoog", "analog", "analogowy", "analog", "analogique")
MAKE_PSTR_LIST(normal, "normal", "normal", "normaal", "normal", "normalny", "normal", "normal")
MAKE_PSTR_LIST(blocking, "blocking", "Blockierung", "Blokkering", "Blockering", "blokowanie", "blokkering", "bloquant")
@@ -448,7 +463,6 @@ MAKE_PSTR_LIST(wwSelTempLow, "wwseltemplow", "selected lower temperature", "unte
MAKE_PSTR_LIST(wwSelTempOff, "wwseltempoff", "selected temperature for off", "Solltemperatur bei AUS", "Streeftemperatuur bij UIT", "Vald tempereatur för AV", "temperatura gdy grzanie wyłączone", "valgt tempereatur for av", "température sélectionnée pour arrêt")
MAKE_PSTR_LIST(wwSelTempSingle, "wwseltempsingle", "single charge temperature", "Solltemperatur Einmalladung", "Streeftemperatuur enkele lading", "Temperatur Engångsladdning", "temperatura dodatkowej ciepłej wody", "temp engangsoppvarming", "température charge unique")
MAKE_PSTR_LIST(wwCylMiddleTemp, "wwcylmiddletemp", "cylinder middle temperature (TS3)", "Speichertemperatur Mitte", "Buffer temperatuur midden", "Cylinder Temperatur Mitten (TS3)", "temperatura środka cylindra (TS3)", "vanntank midten temperatur (TS3)", "température moyenne ballon (TS3)")
MAKE_PSTR_LIST(wwSetTemp, "wwsettemp", "set temperature", "Solltemperatur", "Streeftemperatuut", "Börtempertur", "temperatura zadana", "innstilt temperatur", "régler température")
MAKE_PSTR_LIST(wwType, "wwtype", "type", "Typ", "type", "Typ", "typ", "type", "type")
MAKE_PSTR_LIST(wwComfort, "wwcomfort", "comfort", "Komfort", "Comfort", "Komfort", "komfort", "komfort", "confort")
@@ -483,12 +497,11 @@ MAKE_PSTR_LIST(wwHystOn, "wwhyston", "hysteresis on temperature", "Einschalttemp
MAKE_PSTR_LIST(wwHystOff, "wwhystoff", "hysteresis off temperature", "Ausschalttemperaturdifferenz", "Uitschakeltemperatuurverschil", "Hysteres AV-temperatur", "histereza wyłączania", "utkoblingstemperaturforskjell", "hystérésis température extinction")
MAKE_PSTR_LIST(wwProgMode, "wwprogmode", "program", "Programmmodus", "Programma", "Program", "program", "program", "programme")
MAKE_PSTR_LIST(wwCircProg, "wwcircprog", "circulation program", "Zirkulationsprogramm", "Circulatieprogramma", "Cirkulationsprogram", "program cyrkulacji c.w.u.", "sirkulationsprogram", "programme circulation")
MAKE_PSTR_LIST(wwMaxTemp, "wwmaxtemp", "maximum temperature", "Maximale Temperatur", "Maximale temperatuur", "Maximal Temperatur", "temperatura maksymalna", "", "température max")
MAKE_PSTR_LIST(wwMaxTemp, "wwmaxtemp", "maximum temperature", "Maximale Temperatur", "Maximale temperatuur", "Maximal Temperatur", "temperatura maksymalna", "", "température max") // TODO translate
MAKE_PSTR_LIST(wwOneTimeKey, "wwonetimekey", "one time key function", "Einmalladungstaste", "Knop voor eenmalig laden buffer", "Engångsfunktion", "przycisk jednorazowego ogrzania", "engangsknapp varme", "fonction touche unique")
MAKE_PSTR_LIST(wwSolarTemp, "wwsolartemp", "solar boiler temperature", "Solarboiler Temperatur", "Zonneboiler temperatuur", "Solpanel Temp", "temperatura zasobnika solarnego", "", "température chaudière solaire") // TODO translate
// mqtt values / commands
MAKE_PSTR_LIST(switchtime, "switchtime", "program switchtime", "Programm Schaltzeit", "Programma schakeltijd", "Program Bytestid", "program czasowy", "programbyttetid", "heure commutation programme")
MAKE_PSTR_LIST(switchtime1, "switchtime1", "own1 program switchtime", "Programm 1 Schaltzeit", "Schakeltijd programma 1", "Program 1 Bytestid", "program przełączania 1", "byttetidprogram 1", "heure de commutation programme 1")
MAKE_PSTR_LIST(switchtime2, "switchtime2", "own2 program switchtime", "Programm 2 Schaltzeit", "Schakeltijd programma 2", "Program 2 Bytestid", "program przełączania 2", "byttetid program 2", "heure de changement programme 2")
@@ -525,7 +538,6 @@ MAKE_PSTR_LIST(wwSetTempLow, "wwsettemplow", "set low temperature", "untere Soll
MAKE_PSTR_LIST(wwWhenModeOff, "wwwhenmodeoff", "when thermostat mode off", "bei Thermostatmodus AUS", "Als Thermostaat op UIT", "när Termostatläge är AV", "gdy wyłączono na termostacie", "når modus er av", "lorsque mode thermostat off")
MAKE_PSTR_LIST(wwExtra1, "wwextra1", "circuit 1 extra", "Kreis 1 Extra", "Circuit 1 extra", "Krets 1 Extra", "obieg dodatkowy 1", "ekstra krets 1", "circuit 1 extra")
MAKE_PSTR_LIST(wwExtra2, "wwextra2", "circuit 2 extra", "Kreis 2 Extra", "Circuit 2 extra", "Kets 2 Extra", "obieg dodatkowy 2", "ekstra krets 2", "circuit 2 extra")
MAKE_PSTR_LIST(wwCharge, "wwcharge", "charge", "Laden", "Laden", "Ladda", "grzanie", "lade", "charge")
MAKE_PSTR_LIST(wwChargeDuration, "wwchargeduration", "charge duration", "Ladedauer", "Laadtijd", "Laddtid", "czas grzania dodatkowej ciepłej wody", "ladetid", "durée charge")
MAKE_PSTR_LIST(wwDisinfect, "wwdisinfect", "disinfection", "Desinfektion", "Desinfectie", "Desinfektion", "dezynfekcja termiczna", "desinfeksjon", "désinfection")
@@ -549,7 +561,7 @@ MAKE_PSTR_LIST(heattemp, "heattemp", "heat temperature", "Heizen Temperatur", "T
MAKE_PSTR_LIST(nighttemp, "nighttemp", "night temperature", "Nachttemperatur", "Nachttemperatuur", "Nattemperatur", "temperatura w nocy", "nattemperatur", "température de nuit")
MAKE_PSTR_LIST(nighttemp2, "nighttemp", "night temperature T1", "Nachttemperatur T1", "Nachttemperatuur T1", "Nattemperatur T1", "temperatura w nocy T1", "nattemperatur T1", "température nuit T1")
MAKE_PSTR_LIST(ecotemp, "ecotemp", "eco temperature", "eco Temperatur", "Temperatuur eco", "Eko-temperatur", "temperatura w trybie eko", "øko temperatur", "température éco")
MAKE_PSTR_LIST(manualtemp, "manualtemp", "manual temperature", "manuelle Temperatur", "temperatuur handmatig", "Temperatur Manuell", "temperatura ustawiona ręcznie", "manuell temperatur", "température manuelle")
MAKE_PSTR_LIST(manualtemp, "manualtemp", "manual temperature", "manuelle Temperatur", "Temperatuur handmatig", "Temperatur Manuell", "temperatura ustawiona ręcznie", "manuell temperatur", "température manuelle")
MAKE_PSTR_LIST(tempautotemp, "tempautotemp", "temporary set temperature automode", "temporäre Solltemperatur", "Streeftemperatuur automodus tijdelijk", "Temporär Aktivering av Auto-läge", "zadana temperatura w pomieszczenia w trybie \"auto\" (tymczasowa)", "temporær valgt temp i automodus", "température temporaire mode automatique")
MAKE_PSTR_LIST(remoteseltemp, "remoteseltemp", "temporary set temperature from remote", "temporäre Solltemperatur Remote", "Temperatuur van afstandsbedieding", "Temperatur från fjärruppkoppling", "zadana zdalnie temperatura a pomieszczeniu (tymczasowa)", "temporær valgt temp fra fjernbetjening", "température temporaire depuis télécommande")
MAKE_PSTR_LIST(comforttemp, "comforttemp", "comfort temperature", "Komforttemperatur", "Comforttemperatuur", "Komforttemperatur", "temperatura w trybie komfort", "komforttemperatur", "température confort")
@@ -579,13 +591,11 @@ MAKE_PSTR_LIST(holidaymode, "holidaymode", "holiday mode", "Urlaubsbetrieb", "Va
MAKE_PSTR_LIST(flowtempoffset, "flowtempoffset", "flow temperature offset for mixer", "Vorlauftemperaturanhebung", "Mixer aanvoertemperatuur offset", "Temperaturkorrigering Flödestemp. Blandningsventil", "korekta temperatury przepływu dla miksera", "temperaturkorrigering av blandingsventil", "décalage température de bascule pour mélangeur")
MAKE_PSTR_LIST(reducemode, "reducemode", "reduce mode", "Absenkmodus", "Gereduceerde modus", "Reducerat Läge", "tryb zredukowany/obniżony", "", "mode réduction") // TODO translate
MAKE_PSTR_LIST(noreducetemp, "noreducetemp", "no reduce below temperature", "Durchheizen unter", "Reduceermodus onderbreken onder", "Inaktivera reducering under", "bez redukcji poniżej temperatury", "inaktiver redusert nedre temp", "pas de réduction en dessous température")
MAKE_PSTR_LIST(reducetemp, "reducetemp", "off/reduce switch temperature", "Absenkmodus unter", "Onderste afschakeltemperatuur", "Avslag/Reducera under", "tryb zredukowany poniżej temperatury", "nedre avstengningstemperatur", "arrêt/réduction température bascule")
MAKE_PSTR_LIST(vacreducetemp, "vacreducetemp", "vacations off/reduce switch temperature", "Urlaub Absenkmodus unter", "Vakantiemodus onderste afschakeltemperatuur", "Helg Avslag/Reducering under", "tryb urlopowy poniżej temperatury", "feriemodus nedre utkoblingstemperatur", "vacances arrêt/réduction température bascule")
MAKE_PSTR_LIST(vacreducemode, "vacreducemode", "vacations reduce mode", "Urlaub Absenkmodus", "Vakantie afschakelmodus", "Helg reduceringsläge", "redukcja w trakcie urlopu", "ferieavstengningsmodus", "mode réduction vacances")
MAKE_PSTR_LIST(nofrostmode, "nofrostmode", "nofrost mode", "Frostschutz Modus", "Vorstbeveiligingsmodus", "Frostskyddsläge", "temperatura wiodąca dla ochrony przed zamarzaniem", "frostbeskyttelsesmodus", "mode protection gel")
MAKE_PSTR_LIST(remotetemp, "remotetemp", "room temperature from remote", "Raumtemperatur Remote", "Ruimtetemperatuur van afstandsbediening", "Rumstemperatur från fjärr", "temperatura w pomieszczeniu (z termostatu)", "romstemperatur fra fjernbetjening", "température pièce depuis télécommande")
MAKE_PSTR_LIST(wwHolidays, "wwholidays", "holiday dates", "Feiertage", "Feestdagen", "Helgdagar", "dni świąteczne", "feriedager varmtvann", "dates vacances")
MAKE_PSTR_LIST(wwVacations, "wwvacations", "vacation dates", "Urlaubstage", "Vakantiedagen", "Semesterdatum Varmvatten", "dni urlopowe", "ferie dato varmtvann", "dates vacances")
MAKE_PSTR_LIST(holidays, "holidays", "holiday dates", "Feiertage", "Feestdagen", "Helgdatum", "święta", "helligdager", "dates vacances")
@@ -631,8 +641,6 @@ MAKE_PSTR_LIST(solarPumpTurnoffDiff, "turnoffdiff", "pump turn off difference",
MAKE_PSTR_LIST(pump2MinMod, "pump2minmod", "minimum pump 2 modulation", "minimale Modulation Pumpe 2", "Minimale modulatie pomp 2", "Min Modulering Pump 2", "minimalna modulacja pompy 2", "minimum pumpmodulering 2", "modulation minimale pompe 2")
MAKE_PSTR_LIST(solarPump2TurnonDiff, "turnondiff2", "pump 2 turn on difference", "Einschalthysterese Pumpe 2", "Inschakelhysterese pomp 2", "Aktiveringshysteres Pump 2", "histereza załączenia pompy 2", "slå på hysteresepumpe 2", "différence activation pompe 2")
MAKE_PSTR_LIST(solarPump2TurnoffDiff, "turnoffdiff2", "pump 2 turn off difference", "Ausschalthysterese Pumpe 2", "Uitschakelhysterese pomp 2", "Avslagshysteres Pump 2", "histereza wyłączenia pompy 2", "slå av hysteresepumpe 2", "différence arrêt pompe 2")
MAKE_PSTR_LIST(collectorTemp, "collectortemp", "collector temperature (TS1)", "Kollektortemperatur (TS1)", "Collectortemperatuur (TS1)", "Kollektor Temperatur (TS1)", "temperatura kolektora (TS1)", "kollektor temperatur (TS1)", "température collecteur (TS1)")
MAKE_PSTR_LIST(collector2Temp, "collector2temp", "collector 2 temperature (TS7)", "Kollector 2 Temperatur (TS7)", "Collector 2 temperatuur (TS7)", "Kollektor 2 Temperatur (TS7)", "temperatura kolektora 2 (TS7)", "kollektor 2 temperatur (TS7)", "température collecteur 2 (TS7)")
MAKE_PSTR_LIST(cylBottomTemp, "cylbottomtemp", "cylinder bottom temperature (TS2)", "Speicher Bodentemperatur (TS2)", "Bodemtemperatuur zonneboiler (TS2)", "Cylindertemperatur Botten (TS2)", "temperatura na spodzie zasobnika (TS2)", "beredertemp i bunn (TS2)", "température fond de cylindre (TS2)")

View File

@@ -1351,7 +1351,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & outp
for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice && (emsdevice->device_type() == device_class.first)) {
JsonObject obj = devices.createNestedObject();
obj["type"] = emsdevice->device_type_name();
obj["type"] = emsdevice->device_type_name(); // non translated name
obj["name"] = emsdevice->name();
obj["device id"] = Helpers::hextoa(emsdevice->device_id());
obj["product id"] = emsdevice->product_id();

View File

@@ -153,8 +153,6 @@ bool Test::run_test(const char * command, int8_t id) {
// HC1 on 0x20
uart_telegram({0xA0, 00, 0xFF, 00, 01, 0xD7, 00, 00, 00, 0x80, 00, 00, 00, 00, 03, 0xC5});
// TODO
return true;
}
@@ -639,7 +637,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// toggle mode
for (const auto & emsdevice : EMSESP::emsdevices) {
Serial.print("Custom: ");
Serial.print(emsdevice->device_type_name().c_str());
Serial.print(emsdevice->device_type_name());
Serial.print(" uniqueid=");
Serial.println(emsdevice->unique_id());

View File

@@ -87,6 +87,8 @@ void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t
uart_driver_install(EMSUART_NUM, 129, 0, (EMS_MAXBUFFERSIZE + 1) * 2, &uart_queue, 0); // buffer must be > fifo
uart_set_rx_full_threshold(EMSUART_NUM, 1);
uart_set_rx_timeout(EMSUART_NUM, 0); // disable
// note setting the static max buffer to 1024 causes OTA to fail
xTaskCreate(uart_event_task, "uart_event_task", 2048, NULL, configMAX_PRIORITIES - 1, NULL);
}
tx_mode_ = tx_mode;
@@ -99,6 +101,7 @@ void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t
void EMSuart::stop() {
if (tx_mode_ != 0xFF) { // only call after driver initialisation
uart_disable_intr_mask(EMSUART_NUM, UART_BRK_DET_INT_ENA | UART_RXFIFO_FULL_INT_ENA);
// TODO should we xTaskSuspend() the event task here?
}
};

View File

@@ -188,8 +188,9 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) {
if (emsdevice->has_entities()) {
JsonObject obj = devices.createNestedObject();
obj["i"] = emsdevice->unique_id(); // its unique id
obj["s"] = emsdevice->device_type_name() + " (" + emsdevice->name() + ")"; // shortname
obj["t"] = Helpers::toLower(emsdevice->device_type_name());
obj["s"] = std::string(emsdevice->device_type_2_device_name_translated()) + " (" + emsdevice->name() + ")"; // shortname, is device type translated
obj["tn"] = emsdevice->device_type_name(); // non-translated, lower-case
obj["t"] = emsdevice->device_type(); // internal device type ID
}
}

View File

@@ -81,7 +81,8 @@ void WebDataService::core_data(AsyncWebServerRequest * request) {
if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::CONTROLLER || emsdevice->count_entities() > 0)) {
JsonObject obj = devices.createNestedObject();
obj["id"] = Helpers::smallitoa(buffer, emsdevice->unique_id()); // a unique id as a string
obj["t"] = emsdevice->device_type_name(); // type
obj["tn"] = emsdevice->device_type_2_device_name_translated(); // translated device type name
obj["t"] = emsdevice->device_type(); // device type number
obj["b"] = emsdevice->brand_to_string(); // brand
obj["n"] = emsdevice->name(); // name
obj["d"] = emsdevice->device_id(); // deviceid

View File

@@ -243,7 +243,7 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings)
EMSESP::system_.locale(settings.locale);
#ifndef EMSESP_STANDALONE
if (!old_local.equals(settings.locale)) {
add_flags(ChangeFlags::MQTT);
add_flags(ChangeFlags::RESTART); // force restart
}
#endif