Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
replace char * tags with an ID #632
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Dec 14, 2020
1 parent ffa313e commit 6a67808
Show file tree
Hide file tree
Showing 15 changed files with 605 additions and 298 deletions.
1 change: 1 addition & 0 deletions src/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ using uuid::log::Level;
#define LOG_ERROR(...) logger_.err(__VA_ARGS__)

// clang-format off
// strings stored 32 bit aligned on ESP8266/ESP32
#define MAKE_PSTR(string_name, string_literal) static const char __pstr__##string_name[] __attribute__((__aligned__(sizeof(int)))) PROGMEM = string_literal;
#define MAKE_PSTR_WORD(string_name) MAKE_PSTR(string_name, #string_name)
#define F_(string_name) FPSTR(__pstr__##string_name)
Expand Down
348 changes: 248 additions & 100 deletions src/devices/boiler.cpp

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions src/devices/heatpump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ Heatpump::Heatpump(uint8_t device_type, uint8_t device_id, uint8_t product_id, c
register_telegram_type(0x042B, F("HP1"), true, [&](std::shared_ptr<const Telegram> t) { process_HPMonitor1(t); });
register_telegram_type(0x047B, F("HP2"), true, [&](std::shared_ptr<const Telegram> t) { process_HPMonitor2(t); });

std::string empty("");
register_device_value(empty, &airHumidity_, DeviceValueType::UINT, flash_string_vector{F("2")}, F("airHumidity"), F("Relative air humidity"), DeviceValueUOM::NONE);
register_device_value(empty, &dewTemperature_, DeviceValueType::UINT, {}, F("dewTemperature"), F("Dew point temperature"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE, &airHumidity_, DeviceValueType::UINT, flash_string_vector{F("2")}, F("airHumidity"), F("Relative air humidity"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE, &dewTemperature_, DeviceValueType::UINT, {}, F("dewTemperature"), F("Dew point temperature"), DeviceValueUOM::NONE);
}

// publish HA config
Expand Down
20 changes: 12 additions & 8 deletions src/devices/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ void Mixer::register_values(const Type type, uint16_t hc) {
hc_ = hc + 1;
type_ = type;

std::string prefix(10, '\0');
snprintf_P(&prefix[0], sizeof(prefix), PSTR("%s%d"), (type_ == Type::HC) ? "hc" : "wwc", hc + 1);

register_device_value(
prefix, &flowTemp_, DeviceValueType::USHORT, flash_string_vector{F("10")}, F("flowTemp"), F("Current flow temperature"), DeviceValueUOM::DEGREES);
register_device_value(prefix, &flowSetTemp_, DeviceValueType::UINT, {}, F("flowSetTemp"), F("Setpoint flow temperature"), DeviceValueUOM::DEGREES);
register_device_value(prefix, &pumpStatus_, DeviceValueType::BOOL, {}, F("pumpStatus"), F("Pump/Valve status"), DeviceValueUOM::NONE);
register_device_value(prefix, &status_, DeviceValueType::INT, {}, F("status"), F("Current status"), DeviceValueUOM::NONE);
// with hc<n> or wwc<n>
uint8_t tag = DeviceValueTAG::TAG_NONE;
if (type_ == Type::HC) {
tag = DeviceValueTAG::TAG_HC1 + hc - 1;
} else {
tag = DeviceValueTAG::TAG_WWC1 + hc - 1;
}

register_device_value(tag, &flowTemp_, DeviceValueType::USHORT, flash_string_vector{F("10")}, F("flowTemp"), F("Current flow temperature"), DeviceValueUOM::DEGREES);
register_device_value(tag, &flowSetTemp_, DeviceValueType::UINT, {}, F("flowSetTemp"), F("Setpoint flow temperature"), DeviceValueUOM::DEGREES);
register_device_value(tag, &pumpStatus_, DeviceValueType::BOOL, {}, F("pumpStatus"), F("Pump/Valve status"), DeviceValueUOM::NONE);
register_device_value(tag, &status_, DeviceValueType::INT, {}, F("status"), F("Current status"), DeviceValueUOM::NONE);
}


Expand Down
67 changes: 47 additions & 20 deletions src/devices/solar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,54 +60,81 @@ Solar::Solar(uint8_t device_type, uint8_t device_id, uint8_t product_id, const s
register_telegram_type(0x0101, F("ISM1Set"), false, [&](std::shared_ptr<const Telegram> t) { process_ISM1Set(t); });
}

std::string empty("");

// special case for a device_id with 0x2A where it's not actual a solar module
if (device_id == 0x2A) {
register_device_value(empty, &type_, DeviceValueType::TEXT, {}, F("type"), F("Type"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE, &type_, DeviceValueType::TEXT, {}, F("type"), F("Type"), DeviceValueUOM::NONE);
strncpy(type_, "warm water circuit", sizeof(type_));
}

register_device_value(empty,
register_device_value(DeviceValueTAG::TAG_NONE,
&collectorTemp_,
DeviceValueType::SHORT,
flash_string_vector{F("10")},
F("collectorTemp"),
F("Collector temperature (TS1)"),
DeviceValueUOM::DEGREES);
register_device_value(empty,
register_device_value(DeviceValueTAG::TAG_NONE,
&tankBottomTemp_,
DeviceValueType::SHORT,
flash_string_vector{F("10")},
F("tankBottomTemp"),
F("Bottom temperature (TS2)"),
DeviceValueUOM::DEGREES);
register_device_value(empty,
register_device_value(DeviceValueTAG::TAG_NONE,
&tankBottomTemp2_,
DeviceValueType::SHORT,
flash_string_vector{F("10")},
F("tankBottomTemp2"),
F("Bottom temperature (TS5)"),
DeviceValueUOM::DEGREES);
register_device_value(
empty, &heatExchangerTemp_, DeviceValueType::SHORT, {F("10")}, F("heatExchangerTemp"), F("Heat exchanger temperature (TS6)"), DeviceValueUOM::DEGREES);
register_device_value(DeviceValueTAG::TAG_NONE,
&heatExchangerTemp_,
DeviceValueType::SHORT,
{F("10")},
F("heatExchangerTemp"),
F("Heat exchanger temperature (TS6)"),
DeviceValueUOM::DEGREES);

register_device_value(empty, &tank1MaxTempCurrent_, DeviceValueType::UINT, {}, F("tank1MaxTempCurrent"), F("Maximum Tank temperature"), DeviceValueUOM::NONE);
register_device_value(empty, &solarPumpModulation_, DeviceValueType::UINT, {}, F("solarPumpModulation"), F("Solar pump modulation (PS1)"), DeviceValueUOM::PERCENT);
register_device_value(DeviceValueTAG::TAG_NONE,
&tank1MaxTempCurrent_,
DeviceValueType::UINT,
{},
F("tank1MaxTempCurrent"),
F("Maximum Tank temperature"),
DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE,
&solarPumpModulation_,
DeviceValueType::UINT,
{},
F("solarPumpModulation"),
F("Solar pump modulation (PS1)"),
DeviceValueUOM::PERCENT);
register_device_value(
empty, &cylinderPumpModulation_, DeviceValueType::UINT, {}, F("cylinderPumpModulation"), F("Cylinder pump modulation (PS5)"), DeviceValueUOM::PERCENT);
DeviceValueTAG::TAG_NONE, &cylinderPumpModulation_, DeviceValueType::UINT, {}, F("cylinderPumpModulation"), F("Cylinder pump modulation (PS5)"), DeviceValueUOM::PERCENT);

register_device_value(empty, &solarPump_, DeviceValueType::BOOL, {}, F("solarPump"), F("Solar pump (PS1) active"), DeviceValueUOM::NONE);
register_device_value(empty, &valveStatus_, DeviceValueType::BOOL, {}, F("valveStatus"), F("Valve status"), DeviceValueUOM::NONE);
register_device_value(empty, &tankHeated_, DeviceValueType::BOOL, {}, F("tankHeated"), F("Tank heated"), DeviceValueUOM::NONE);
register_device_value(empty, &collectorShutdown_, DeviceValueType::BOOL, {}, F("collectorShutdown"), F("Collector shutdown"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE, &solarPump_, DeviceValueType::BOOL, {}, F("solarPump"), F("Solar pump (PS1) active"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE, &valveStatus_, DeviceValueType::BOOL, {}, F("valveStatus"), F("Valve status"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE, &tankHeated_, DeviceValueType::BOOL, {}, F("tankHeated"), F("Tank heated"), DeviceValueUOM::NONE);
register_device_value(
DeviceValueTAG::TAG_NONE, &collectorShutdown_, DeviceValueType::BOOL, {}, F("collectorShutdown"), F("Collector shutdown"), DeviceValueUOM::NONE);

register_device_value(empty, &pumpWorkMin_, DeviceValueType::TIME, {}, F("pumpWorkMin"), F("Pump working time"), DeviceValueUOM::MINUTES);
register_device_value(DeviceValueTAG::TAG_NONE, &pumpWorkMin_, DeviceValueType::TIME, {}, F("pumpWorkMin"), F("Pump working time"), DeviceValueUOM::MINUTES);

register_device_value(
empty, &energyLastHour_, DeviceValueType::ULONG, flash_string_vector{F("10")}, F("energyLastHour"), F("Energy last hour"), DeviceValueUOM::WH);
register_device_value(empty, &energyTotal_, DeviceValueType::ULONG, flash_string_vector{F("10")}, F("energyTotal"), F("Energy total"), DeviceValueUOM::KWH);
register_device_value(empty, &energyToday_, DeviceValueType::ULONG, {}, F("energyToday"), F("Energy today"), DeviceValueUOM::WH);
register_device_value(DeviceValueTAG::TAG_NONE,
&energyLastHour_,
DeviceValueType::ULONG,
flash_string_vector{F("10")},
F("energyLastHour"),
F("Energy last hour"),
DeviceValueUOM::WH);
register_device_value(DeviceValueTAG::TAG_NONE,
&energyTotal_,
DeviceValueType::ULONG,
flash_string_vector{F("10")},
F("energyTotal"),
F("Energy total"),
DeviceValueUOM::KWH);
register_device_value(DeviceValueTAG::TAG_NONE, &energyToday_, DeviceValueType::ULONG, {}, F("energyToday"), F("Energy today"), DeviceValueUOM::WH);
}

// publish HA config
Expand Down
14 changes: 9 additions & 5 deletions src/devices/switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const
register_telegram_type(0x9C, F("WM10MonitorMessage"), false, [&](std::shared_ptr<const Telegram> t) { process_WM10MonitorMessage(t); });
register_telegram_type(0x9B, F("WM10SetMessage"), false, [&](std::shared_ptr<const Telegram> t) { process_WM10SetMessage(t); });

std::string empty("");
register_device_value(empty, &activated_, DeviceValueType::BOOL, {}, F("activated"), F("Activated"), DeviceValueUOM::NONE);
register_device_value(
empty, &flowTemp_, DeviceValueType::USHORT, flash_string_vector{F("10")}, F("flowTemp"), F("Current flow temperature"), DeviceValueUOM::DEGREES);
register_device_value(empty, &status_, DeviceValueType::INT, {}, F("status"), F("Status"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE, &activated_, DeviceValueType::BOOL, {}, F("activated"), F("Activated"), DeviceValueUOM::NONE);
register_device_value(DeviceValueTAG::TAG_NONE,
&flowTemp_,
DeviceValueType::USHORT,
flash_string_vector{F("10")},
F("flowTemp"),
F("Current flow temperature"),
DeviceValueUOM::DEGREES);
register_device_value(DeviceValueTAG::TAG_NONE, &status_, DeviceValueType::INT, {}, F("status"), F("Status"), DeviceValueUOM::NONE);
}

// publish HA config
Expand Down
Loading

0 comments on commit 6a67808

Please sign in to comment.