From 374bd7c5c2f6aab360170f6cdc0ac8992497d037 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 26 Oct 2023 15:08:24 +0200 Subject: [PATCH] extension module instead of pumpp module --- interface/src/project/DeviceIcon.tsx | 8 +- interface/src/project/types.ts | 2 +- src/device_library.h | 4 +- src/devices/extension.cpp | 132 +++++++++++++++++++++++++++ src/devices/extension.h | 59 ++++++++++++ src/devices/pump.cpp | 29 ------ src/devices/pump.h | 33 ------- src/emsdevice.cpp | 12 +-- src/emsdevice.h | 4 +- src/locale_common.h | 1 + src/locale_translations.h | 3 +- 11 files changed, 209 insertions(+), 78 deletions(-) create mode 100644 src/devices/extension.cpp create mode 100644 src/devices/extension.h delete mode 100644 src/devices/pump.cpp delete mode 100644 src/devices/pump.h diff --git a/interface/src/project/DeviceIcon.tsx b/interface/src/project/DeviceIcon.tsx index e471928f5..85ae139f7 100644 --- a/interface/src/project/DeviceIcon.tsx +++ b/interface/src/project/DeviceIcon.tsx @@ -1,9 +1,9 @@ -import { AiOutlineControl, AiOutlineGateway, AiOutlineAlert, AiOutlineChrome } from 'react-icons/ai'; +import { AiOutlineControl, AiOutlineGateway, AiOutlineAlert } from 'react-icons/ai'; import { CgSmartHomeBoiler } from 'react-icons/cg'; import { FaSolarPanel } from 'react-icons/fa'; import { GiHeatHaze } from 'react-icons/gi'; -import { MdThermostatAuto, MdOutlineSensors, MdOutlineExtension } from 'react-icons/md'; +import { MdThermostatAuto, MdOutlineSensors, MdOutlineExtension, MdOutlineDevices } from 'react-icons/md'; import { TiFlowSwitch } from 'react-icons/ti'; import { VscVmConnect } from 'react-icons/vsc'; import { DeviceType } from './types'; @@ -38,8 +38,8 @@ const DeviceIcon: FC = ({ type_id }) => { return ; case DeviceType.ALERT: return ; - case DeviceType.PUMP: - return ; + case DeviceType.EXTENSION: + return ; case DeviceType.CUSTOM: return ; default: diff --git a/interface/src/project/types.ts b/interface/src/project/types.ts index f13d4726c..ae83534bc 100644 --- a/interface/src/project/types.ts +++ b/interface/src/project/types.ts @@ -364,7 +364,7 @@ export const enum DeviceType { CONTROLLER, CONNECT, ALERT, - PUMP, + EXTENSION, GENERIC, HEATSOURCE, CUSTOM, diff --git a/src/device_library.h b/src/device_library.h index eeaa03f3f..e4c93e66e 100644 --- a/src/device_library.h +++ b/src/device_library.h @@ -169,8 +169,8 @@ // Switches - 0x11 { 71, DeviceType::SWITCH, "WM10", DeviceFlags::EMS_DEVICE_FLAG_NONE}, -// EM10/EM100 module - 0x15 -{ 243, DeviceType::ALERT, "EM10/EM100", DeviceFlags::EMS_DEVICE_FLAG_NONE}, +// EM10/100 extension module, pump module - 0x15 +{ 243, DeviceType::EXTENSION, "EM10/EM100", DeviceFlags::EMS_DEVICE_FLAG_NONE}, // EM10 error contact and analog flowtemp control- 0x12 { 74, DeviceType::ALERT, "EM10", DeviceFlags::EMS_DEVICE_FLAG_NONE}, diff --git a/src/devices/extension.cpp b/src/devices/extension.cpp new file mode 100644 index 000000000..c67a8a184 --- /dev/null +++ b/src/devices/extension.cpp @@ -0,0 +1,132 @@ +/* + * EMS-ESP - https://github.com/emsesp/EMS-ESP + * Copyright 2020-2023 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 . + */ + +#include "extension.h" + +namespace emsesp { + +REGISTER_FACTORY(Extension, EMSdevice::DeviceType::EXTENSION); + +Extension::Extension(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand) + : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { + register_telegram_type(0x935, "EM100SetMessage", true, MAKE_PF_CB(process_EM100SetMessage)); + register_telegram_type(0x937, "EM100TempMessage", false, MAKE_PF_CB(process_EM100TempMessage)); + register_telegram_type(0x938, "EM100InputMessage", false, MAKE_PF_CB(process_EM100InputMessage)); + register_telegram_type(0x939, "EM100MonitorMessage", false, MAKE_PF_CB(process_EM100MonitorMessage)); + register_telegram_type(0x93A, "EM100ConfigMessage", false, MAKE_PF_CB(process_EM100ConfigMessage)); + + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &headerTemp_, + DeviceValueType::SHORT, + DeviceValueNumOp::DV_NUMOP_DIV10, + FL_(flowTempVf), + DeviceValueUOM::DEGREES); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &input_, DeviceValueType::USHORT, DeviceValueNumOp::DV_NUMOP_DIV10, FL_(input), DeviceValueUOM::VOLTS); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &outPower_, DeviceValueType::BOOL, FL_(outPower), DeviceValueUOM::NONE); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &setPower_, DeviceValueType::UINT, FL_(setPower), DeviceValueUOM::PERCENT); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &setPoint_, DeviceValueType::UINT, FL_(setPoint), DeviceValueUOM::DEGREES); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &minV_, + DeviceValueType::UINT, + DeviceValueNumOp::DV_NUMOP_DIV10, + FL_(minV), + DeviceValueUOM::VOLTS, + MAKE_CF_CB(set_minV)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, + &maxV_, + DeviceValueType::UINT, + DeviceValueNumOp::DV_NUMOP_DIV10, + FL_(maxV), + DeviceValueUOM::VOLTS, + MAKE_CF_CB(set_maxV)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &minT_, DeviceValueType::UINT, FL_(minT), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_minT)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &maxT_, DeviceValueType::UINT, FL_(maxT), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_maxT)); + register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &dip_, DeviceValueType::UINT, FL_(mode), DeviceValueUOM::NONE); + // register_device_value(DeviceValueTAG::TAG_DEVICE_DATA, &errorState_, DeviceValueType::BOOL, FL_(error), DeviceValueUOM::NONE); +} + + +// 0x935 needs fetch +void Extension::process_EM100SetMessage(std::shared_ptr telegram) { + has_update(telegram, minV_, 1); // Input for off, is / 10 + has_update(telegram, maxV_, 2); // Input for 100%, is / 10 + has_update(telegram, minT_, 3); // min temp + has_update(telegram, maxT_, 4); // max temp +} + +// alert(0x15) -B-> All(0x00), ?(0x093A), data: 00 00 00 00 00 00 00 00 00 03 01 +void Extension::process_EM100ConfigMessage(std::shared_ptr telegram) { + has_update(telegram, dip_, 9); +} + +// alert(0x15) -B-> All(0x00), ?(0x0938), data: 01 62 +void Extension::process_EM100InputMessage(std::shared_ptr telegram) { + has_update(telegram, outPower_, 0); // IO1 + has_update(telegram, input_, 1); +} + +// alert(0x15) -B-> All(0x00), ?(0x0939), data: 64 4E 00 00 +void Extension::process_EM100MonitorMessage(std::shared_ptr telegram) { + has_update(telegram, setPower_, 0); // percent + has_update(telegram, setPoint_, 1); // °C + // has_update(telegram, errorState_, 2); // OE1 + // has_update(telegram, errorPump_, 3); // IE0 +} + +// alert(0x15) -B-> All(0x00), ?(0x0937), data: 80 00 +void Extension::process_EM100TempMessage(std::shared_ptr telegram) { + has_update(telegram, headerTemp_, 0); +} + +bool Extension::set_minV(const char * value, const int8_t id) { + float v; + if (!Helpers::value2float(value, v)) { + return false; + } + write_command(0x935, 1, (uint8_t)(v * 10)); + return true; +} + +bool Extension::set_maxV(const char * value, const int8_t id) { + float v; + if (!Helpers::value2float(value, v)) { + return false; + } + write_command(0x935, 2, (uint8_t)(v * 10)); + return true; +} + +bool Extension::set_minT(const char * value, const int8_t id) { + int v; + if (!Helpers::value2temperature(value, v)) { + return false; + } + write_command(0x935, 3, v); + return true; +} + +bool Extension::set_maxT(const char * value, const int8_t id) { + int v; + if (!Helpers::value2temperature(value, v)) { + return false; + } + write_command(0x935, 4, v); + return true; +} + +} // namespace emsesp \ No newline at end of file diff --git a/src/devices/extension.h b/src/devices/extension.h new file mode 100644 index 000000000..ceaba27a0 --- /dev/null +++ b/src/devices/extension.h @@ -0,0 +1,59 @@ +/* + * EMS-ESP - https://github.com/emsesp/EMS-ESP + * Copyright 2020-2023 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 . + */ + +#ifndef EMSESP_EXTENSION_H +#define EMSESP_EXTENSION_H + +#include "emsesp.h" + +namespace emsesp { + +class Extension : public EMSdevice { + public: + Extension(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand); + + private: + void process_EM100SetMessage(std::shared_ptr telegram); + void process_EM100MonitorMessage(std::shared_ptr telegram); + void process_EM100TempMessage(std::shared_ptr telegram); + void process_EM100InputMessage(std::shared_ptr telegram); + void process_EM100ConfigMessage(std::shared_ptr telegram); + + bool set_minV(const char * value, const int8_t id); + bool set_maxV(const char * value, const int8_t id); + bool set_minT(const char * value, const int8_t id); + bool set_maxT(const char * value, const int8_t id); + + + int16_t headerTemp_; // T0 + int16_t input_; // IO1 + uint8_t errorState_; // OE1 + uint8_t errorPump_; // IE0 + uint8_t outPower_; // IO1 + uint8_t setPower_; // request + uint8_t setPoint_; + uint8_t dip_; // dip switch + uint8_t minV_; + uint8_t maxV_; + uint8_t minT_; + uint8_t maxT_; +}; + +} // namespace emsesp + +#endif diff --git a/src/devices/pump.cpp b/src/devices/pump.cpp deleted file mode 100644 index b55e3cd8a..000000000 --- a/src/devices/pump.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * EMS-ESP - https://github.com/emsesp/EMS-ESP - * Copyright 2020-2023 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 . - */ - -#include "pump.h" - -namespace emsesp { - -REGISTER_FACTORY(Pump, EMSdevice::DeviceType::PUMP); - -Pump::Pump(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand) - : EMSdevice(device_type, device_id, product_id, version, name, flags, brand) { -} - -} // namespace emsesp \ No newline at end of file diff --git a/src/devices/pump.h b/src/devices/pump.h deleted file mode 100644 index 8064de6f6..000000000 --- a/src/devices/pump.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * EMS-ESP - https://github.com/emsesp/EMS-ESP - * Copyright 2020-2023 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 . - */ - -#ifndef EMSESP_PUMP_H -#define EMSESP_PUMP_H - -#include "emsesp.h" - -namespace emsesp { - -class Pump : public EMSdevice { - public: - Pump(uint8_t device_type, uint8_t device_id, uint8_t product_id, const char * version, const char * name, uint8_t flags, uint8_t brand); -}; - -} // namespace emsesp - -#endif diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index 7ce2b602f..2e48ecfaa 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -131,8 +131,8 @@ const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) { return F_(gateway); case DeviceType::ALERT: return F_(alert); - case DeviceType::PUMP: - return F_(pump); + case DeviceType::EXTENSION: + return F_(extension); case DeviceType::HEATSOURCE: return F_(heatsource); case DeviceType::CUSTOM: @@ -168,8 +168,8 @@ const char * EMSdevice::device_type_2_device_name_translated() { 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::EXTENSION: + return Helpers::translated_word(FL_(extension_device)); case DeviceType::HEATSOURCE: return Helpers::translated_word(FL_(heatsource_device)); case DeviceType::VENTILATION: @@ -229,8 +229,8 @@ uint8_t EMSdevice::device_name_2_device_type(const char * topic) { if (!strcmp(lowtopic, F_(alert))) { return DeviceType::ALERT; } - if (!strcmp(lowtopic, F_(pump))) { - return DeviceType::PUMP; + if (!strcmp(lowtopic, F_(extension))) { + return DeviceType::EXTENSION; } if (!strcmp(lowtopic, F_(heatsource))) { return DeviceType::HEATSOURCE; diff --git a/src/emsdevice.h b/src/emsdevice.h index 62810471e..93986a76e 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -350,7 +350,7 @@ class EMSdevice { CONTROLLER, CONNECT, ALERT, - PUMP, + EXTENSION, GENERIC, HEATSOURCE, CUSTOM, @@ -375,7 +375,7 @@ class EMSdevice { static constexpr uint8_t EMS_DEVICE_ID_CLOCK = 0x0F; static constexpr uint8_t EMS_DEVICE_ID_SWITCH = 0x11; // Switch WM10 static constexpr uint8_t EMS_DEVICE_ID_ALERT = 0x12; // Error module EM10 - static constexpr uint8_t EMS_DEVICE_ID_PUMP = 0x15; // Pump module PM10 + static constexpr uint8_t EMS_DEVICE_ID_EXTENSION = 0x15; // Extension module EM1000, Pump module PM10 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; diff --git a/src/locale_common.h b/src/locale_common.h index e6fbeec10..7d8a5db83 100644 --- a/src/locale_common.h +++ b/src/locale_common.h @@ -97,6 +97,7 @@ MAKE_WORD(analogsensor) MAKE_WORD(temperaturesensor) MAKE_WORD(alert) MAKE_WORD(pump) +MAKE_WORD(extension) MAKE_WORD(heatsource) MAKE_WORD(scheduler) MAKE_WORD(custom) diff --git a/src/locale_translations.h b/src/locale_translations.h index 68e293d03..bf75cddcf 100644 --- a/src/locale_translations.h +++ b/src/locale_translations.h @@ -46,7 +46,8 @@ MAKE_WORD_TRANSLATION(controller_device, "Controller Module", "Kontrollmodul", " MAKE_WORD_TRANSLATION(switch_device, "Switch Module", "Schaltmodul", "Switch Module", "Relämodul", "Moduł przełączający", "Switch modul", "", "Anahtar", "Modulo Switch") // TODO translate MAKE_WORD_TRANSLATION(gateway_device, "Gateway Module", "Gateway Modul", "Gateway Module", "Gateway", "Moduł IP", "Gateway", "", "Ağ Geçidi", "Modulo Gateway") // TODO translate MAKE_WORD_TRANSLATION(alert_device, "Alert Module", "Alarmmodul", "Alert Module", "Larmmodul", "Moduł alarmowy", "Alarmmodul", "", "Alarm Cihazı", "Module Avviso") // TODO translate -MAKE_WORD_TRANSLATION(pump_device, "Pump Module", "Pumpenmodul", "Pump Module", "Pumpmodul", "Moduł pompy", "Pumpemodul", "", "Pompa", "Module Pompa") // TODO translate +//MAKE_WORD_TRANSLATION(pump_device, "Pump Module", "Pumpenmodul", "Pump Module", "Pumpmodul", "Moduł pompy", "Pumpemodul", "", "Pompa", "Module Pompa") // TODO translate +MAKE_WORD_TRANSLATION(extension_device, "Extension Module", "Erweiterungsnmodul", "Module", "Modul", "Moduł", "Modul", "", "", "Module") // TODO translate MAKE_WORD_TRANSLATION(heatsource_device, "Heatsource", "Heizquelle", "Heatsource", "Värmekälla", "Źródło ciepła", "Varmekilde", "", "Isı Kaynağı", "Fonte di calore") // TODO translate MAKE_WORD_TRANSLATION(sensors_device, "Sensors", "Sensoren", "Sensoren", "Sensorer", "Czujniki", "Sensorer", "Capteurs", "Sensör Cihazı", "Sensori") MAKE_WORD_TRANSLATION(unknown_device, "Unknown", "Unbekannt", "Onbekend", "Okänt", "Nieznane urządzenie", "Ukjent", "Inconnu", "Bilinmeyen", "Sconosciuto")