add devices alert/Pump #575, #720, UOM:translate times? #752

This commit is contained in:
MichaelDvP
2022-11-19 12:11:30 +01:00
parent 8594c4a7eb
commit deda1daa04
11 changed files with 172 additions and 17 deletions

View File

@@ -9,6 +9,8 @@ import { GiHeatHaze } from 'react-icons/gi';
import { TiFlowSwitch } from 'react-icons/ti'; import { TiFlowSwitch } from 'react-icons/ti';
import { VscVmConnect } from 'react-icons/vsc'; import { VscVmConnect } from 'react-icons/vsc';
import { AiOutlineGateway } from 'react-icons/ai'; import { AiOutlineGateway } from 'react-icons/ai';
import { AiOutlineAlert } from 'react-icons/ai';
import { AiOutlineChrome } from 'react-icons/ai';
interface DeviceIconProps { interface DeviceIconProps {
type: string; type: string;
@@ -34,6 +36,10 @@ const DeviceIcon: FC<DeviceIconProps> = ({ type }) => {
return <VscVmConnect />; return <VscVmConnect />;
case 'Gateway': case 'Gateway':
return <AiOutlineGateway />; return <AiOutlineGateway />;
case 'Alert':
return <AiOutlineAlert />;
case 'Pump':
return <AiOutlineChrome />;
default: default:
return null; return null;
} }

View File

@@ -192,7 +192,7 @@ export const DeviceValueUOM_s = [
'Wh', 'Wh',
'hours', 'hours',
'minutes', 'minutes',
'uA', 'µA',
'bar', 'bar',
'kW', 'kW',
'W', 'W',
@@ -201,8 +201,8 @@ export const DeviceValueUOM_s = [
'dBm', 'dBm',
'°F', '°F',
'mV', 'mV',
'sqm', 'm²',
'm3', 'm³',
'l' 'l'
]; ];

View File

@@ -153,8 +153,11 @@
// Switches - 0x11 // Switches - 0x11
{ 71, DeviceType::SWITCH, "WM10", DeviceFlags::EMS_DEVICE_FLAG_NONE}, { 71, DeviceType::SWITCH, "WM10", DeviceFlags::EMS_DEVICE_FLAG_NONE},
// PM10 Pump module - 0x15
{ 243, DeviceType::PUMP, "PM10", DeviceFlags::EMS_DEVICE_FLAG_NONE},
// EM10 error contact and analog flowtemp control- 0x12 // EM10 error contact and analog flowtemp control- 0x12
{ 74, DeviceType::GATEWAY, "Error Module EM10", DeviceFlags::EMS_DEVICE_FLAG_NONE}, { 74, DeviceType::ALERT, "EM10", DeviceFlags::EMS_DEVICE_FLAG_NONE},
// Gateways - 0x48 // Gateways - 0x48
{189, DeviceType::GATEWAY, "KM200/MB LAN 2", DeviceFlags::EMS_DEVICE_FLAG_NONE}, {189, DeviceType::GATEWAY, "KM200/MB LAN 2", DeviceFlags::EMS_DEVICE_FLAG_NONE},

29
src/devices/alert.cpp Normal file
View File

@@ -0,0 +1,29 @@
/*
* EMS-ESP - https://github.com/emsesp/EMS-ESP
* Copyright 2020 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 "alert.h"
namespace emsesp {
REGISTER_FACTORY(Alert, EMSdevice::DeviceType::ALERT);
Alert::Alert(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

33
src/devices/alert.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* EMS-ESP - https://github.com/emsesp/EMS-ESP
* Copyright 2020 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_ALERT_H
#define EMSESP_ALERT_H
#include "emsesp.h"
namespace emsesp {
class Alert : public EMSdevice {
public:
Alert(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

29
src/devices/pump.cpp Normal file
View File

@@ -0,0 +1,29 @@
/*
* EMS-ESP - https://github.com/emsesp/EMS-ESP
* Copyright 2020 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 "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

33
src/devices/pump.h Normal file
View File

@@ -0,0 +1,33 @@
/*
* EMS-ESP - https://github.com/emsesp/EMS-ESP
* Copyright 2020 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_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

View File

@@ -56,6 +56,17 @@ std::string EMSdevice::uom_to_string(uint8_t uom) {
if (EMSESP::system_.fahrenheit() && (uom == DeviceValueUOM::DEGREES || uom == DeviceValueUOM::DEGREES_R)) { if (EMSESP::system_.fahrenheit() && (uom == DeviceValueUOM::DEGREES || uom == DeviceValueUOM::DEGREES_R)) {
return (DeviceValue::DeviceValueUOM_s[DeviceValueUOM::FAHRENHEIT]); return (DeviceValue::DeviceValueUOM_s[DeviceValueUOM::FAHRENHEIT]);
} }
/* translate times? https://github.com/emsesp/EMS-ESP32/issues/752
if (uom == DeviceValueUOM::HOURS) {
return (Helpers::translated_word(FL_(hours)));
}
if (uom == DeviceValueUOM::MINUTES) {
return (Helpers::translated_word(FL_(minutes)));
}
if (uom == DeviceValueUOM::SECONDS) {
return (Helpers::translated_word(FL_(seconds)));
}
*/
return (DeviceValue::DeviceValueUOM_s[uom]); return (DeviceValue::DeviceValueUOM_s[uom]);
} }
@@ -107,6 +118,10 @@ const char * EMSdevice::device_type_2_device_name(const uint8_t device_type) {
return F_(switch); return F_(switch);
case DeviceType::GATEWAY: case DeviceType::GATEWAY:
return F_(gateway); return F_(gateway);
case DeviceType::ALERT:
return F_(alert);
case DeviceType::PUMP:
return F_(pump);
default: default:
return Helpers::translated_word(FL_(unknown)); return Helpers::translated_word(FL_(unknown));
} }
@@ -128,42 +143,39 @@ uint8_t EMSdevice::device_name_2_device_type(const char * topic) {
if (!strcmp(lowtopic, F_(boiler))) { if (!strcmp(lowtopic, F_(boiler))) {
return DeviceType::BOILER; return DeviceType::BOILER;
} }
if (!strcmp(lowtopic, F_(thermostat))) { if (!strcmp(lowtopic, F_(thermostat))) {
return DeviceType::THERMOSTAT; return DeviceType::THERMOSTAT;
} }
if (!strcmp(lowtopic, F_(system))) { if (!strcmp(lowtopic, F_(system))) {
return DeviceType::SYSTEM; return DeviceType::SYSTEM;
} }
if (!strcmp(lowtopic, F_(heatpump))) { if (!strcmp(lowtopic, F_(heatpump))) {
return DeviceType::HEATPUMP; return DeviceType::HEATPUMP;
} }
if (!strcmp(lowtopic, F_(solar))) { if (!strcmp(lowtopic, F_(solar))) {
return DeviceType::SOLAR; return DeviceType::SOLAR;
} }
if (!strcmp(lowtopic, F_(mixer))) { if (!strcmp(lowtopic, F_(mixer))) {
return DeviceType::MIXER; return DeviceType::MIXER;
} }
if (!strcmp(lowtopic, F_(dallassensor))) { if (!strcmp(lowtopic, F_(dallassensor))) {
return DeviceType::DALLASSENSOR; return DeviceType::DALLASSENSOR;
} }
if (!strcmp(lowtopic, F_(analogsensor))) { if (!strcmp(lowtopic, F_(analogsensor))) {
return DeviceType::ANALOGSENSOR; return DeviceType::ANALOGSENSOR;
} }
if (!strcmp(lowtopic, F_(switch))) { if (!strcmp(lowtopic, F_(switch))) {
return DeviceType::SWITCH; return DeviceType::SWITCH;
} }
if (!strcmp(lowtopic, F_(gateway))) { if (!strcmp(lowtopic, F_(gateway))) {
return DeviceType::GATEWAY; return DeviceType::GATEWAY;
} }
if (!strcmp(lowtopic, F_(alert))) {
return DeviceType::ALERT;
}
if (!strcmp(lowtopic, F_(pump))) {
return DeviceType::PUMP;
}
return DeviceType::UNKNOWN; return DeviceType::UNKNOWN;
} }

View File

@@ -338,6 +338,8 @@ class EMSdevice {
SWITCH, SWITCH,
CONTROLLER, CONTROLLER,
CONNECT, CONNECT,
ALERT,
PUMP,
GENERIC, GENERIC,
UNKNOWN UNKNOWN
}; };

View File

@@ -416,7 +416,7 @@ void EMSESP::publish_all(bool force) {
publish_device_values(EMSdevice::DeviceType::THERMOSTAT); publish_device_values(EMSdevice::DeviceType::THERMOSTAT);
publish_device_values(EMSdevice::DeviceType::SOLAR); publish_device_values(EMSdevice::DeviceType::SOLAR);
publish_device_values(EMSdevice::DeviceType::MIXER); publish_device_values(EMSdevice::DeviceType::MIXER);
publish_other_values(); // switch and heat pump publish_other_values(); // switch and heat pump, ...
publish_sensor_values(true); // includes dallas and analog sensors publish_sensor_values(true); // includes dallas and analog sensors
system_.send_heartbeat(); system_.send_heartbeat();
} }
@@ -546,6 +546,12 @@ void EMSESP::publish_device_values(uint8_t device_type) {
void EMSESP::publish_other_values() { void EMSESP::publish_other_values() {
publish_device_values(EMSdevice::DeviceType::SWITCH); publish_device_values(EMSdevice::DeviceType::SWITCH);
publish_device_values(EMSdevice::DeviceType::HEATPUMP); publish_device_values(EMSdevice::DeviceType::HEATPUMP);
// other devices without values yet
// publish_device_values(EMSdevice::DeviceType::GATEWAY);
// publish_device_values(EMSdevice::DeviceType::CONNECT);
// publish_device_values(EMSdevice::DeviceType::ALERT);
// publish_device_values(EMSdevice::DeviceType::PUMP);
// publish_device_values(EMSdevice::DeviceType::GENERIC);
} }
// publish both the dallas and analog sensor values // publish both the dallas and analog sensor values

View File

@@ -102,6 +102,8 @@ MAKE_PSTR_WORD(heatpump)
MAKE_PSTR_WORD(generic) MAKE_PSTR_WORD(generic)
MAKE_PSTR_WORD(analogsensor) MAKE_PSTR_WORD(analogsensor)
MAKE_PSTR_WORD(dallassensor) MAKE_PSTR_WORD(dallassensor)
MAKE_PSTR_WORD(alert)
MAKE_PSTR_WORD(pump)
MAKE_PSTR(number, "number") MAKE_PSTR(number, "number")
MAKE_PSTR(enum, "enum") MAKE_PSTR(enum, "enum")
@@ -205,7 +207,7 @@ MAKE_PSTR(uom_seconds, "seconds")
MAKE_PSTR(uom_kwh, "kWh") MAKE_PSTR(uom_kwh, "kWh")
MAKE_PSTR(uom_wh, "Wh") MAKE_PSTR(uom_wh, "Wh")
MAKE_PSTR(uom_bar, "bar") MAKE_PSTR(uom_bar, "bar")
MAKE_PSTR(uom_ua, "uA") MAKE_PSTR(uom_ua, "µA")
MAKE_PSTR(uom_lmin, "l/min") MAKE_PSTR(uom_lmin, "l/min")
MAKE_PSTR(uom_kw, "kW") MAKE_PSTR(uom_kw, "kW")
MAKE_PSTR(uom_w, "W") MAKE_PSTR(uom_w, "W")
@@ -213,8 +215,8 @@ MAKE_PSTR(uom_kb, "KB")
MAKE_PSTR(uom_dbm, "dBm") MAKE_PSTR(uom_dbm, "dBm")
MAKE_PSTR(uom_fahrenheit, "°F") MAKE_PSTR(uom_fahrenheit, "°F")
MAKE_PSTR(uom_mv, "mV") MAKE_PSTR(uom_mv, "mV")
MAKE_PSTR(uom_sqm, "sqm") MAKE_PSTR(uom_sqm, "m²")
MAKE_PSTR(uom_m3, "m3") MAKE_PSTR(uom_m3, "m³")
MAKE_PSTR(uom_l, "l") MAKE_PSTR(uom_l, "l")
// MQTT topics and prefixes // MQTT topics and prefixes