Skip to content

Commit

Permalink
mqtt name switchprog, mqtt publish
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Aug 29, 2024
1 parent 28fb6c0 commit 4203b39
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/devices/thermostat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4790,6 +4790,7 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->switchtime2, DeviceValueType::JSON, FL_(rc35), FL_(switchtime2), DeviceValueUOM::NONE, MAKE_CF_CB(set_switchtime2));
break;
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS:
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS_OLD:
register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode4), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode));
register_device_value(tag, &hc->modetype, DeviceValueType::ENUM, FL_(enum_modetype4), FL_(modetype), DeviceValueUOM::NONE);
register_device_value(
Expand Down Expand Up @@ -4835,6 +4836,10 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
tag, &hc->heatingtype, DeviceValueType::ENUM, FL_(enum_heatingtype1), FL_(heatingtype), DeviceValueUOM::NONE, MAKE_CF_CB(set_heatingtype));
register_device_value(
tag, &hc->controlmode, DeviceValueType::ENUM, FL_(enum_controlmode3), FL_(controlmode), DeviceValueUOM::NONE, MAKE_CF_CB(set_controlmode));
init_switchtime(hc->switchtime1, 84);
register_device_value(tag, &hc->switchtime1, DeviceValueType::JSON, FL_(junkers), FL_(switchtime1), DeviceValueUOM::NONE, MAKE_CF_CB(set_switchtime1));
init_switchtime(hc->switchtime2, 84);
register_device_value(tag, &hc->switchtime2, DeviceValueType::JSON, FL_(junkers), FL_(switchtime2), DeviceValueUOM::NONE, MAKE_CF_CB(set_switchtime2));
break;
default:
break;
Expand Down Expand Up @@ -4957,7 +4962,13 @@ void Thermostat::register_device_values_dhw(std::shared_ptr<Thermostat::DhwCircu
register_device_value(tag, &dhw->wwVacation_, DeviceValueType::STRING, FL_(tpl_holidays), FL_(wwVacations), DeviceValueUOM::NONE, MAKE_CF_CB(set_wwVacation));
break;
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS:
case EMSdevice::EMS_DEVICE_FLAG_JUNKERS_OLD:
register_device_value(tag, &dhw->wwCharge_, DeviceValueType::BOOL, FL_(wwCharge), DeviceValueUOM::NONE, MAKE_CF_CB(set_wwcharge));
init_switchtime(dhw->switchtime, 84);
register_device_value(tag, &dhw->switchtime, DeviceValueType::JSON, FL_(junkers), FL_(switchtime), DeviceValueUOM::NONE, MAKE_CF_CB(set_wwSwitchTime));
init_switchtime(dhw->circswitchtime, 84);
register_device_value(
tag, &dhw->circswitchtime, DeviceValueType::JSON, FL_(junkers), FL_(circswitchtime), DeviceValueUOM::NONE, MAKE_CF_CB(set_wwCircSwitchTime));
break;
case EMSdevice::EMS_DEVICE_FLAG_EASY:
case EMSdevice::EMS_DEVICE_FLAG_CRF:
Expand Down
34 changes: 34 additions & 0 deletions src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,39 @@ void EMSESP::publish_device_values(uint8_t device_type) {
}
}

// publish the timer json value
void EMSESP::publish_thermostat_timer() {
JsonDocument output;
for (int8_t tag = DeviceValueTAG::TAG_HC1; tag <= DeviceValueTAG::TAG_DHW2; tag++) {
JsonObject circuit;
for (const auto & emsdevice : emsdevices) {
if (emsdevice->device_type() == DeviceType::THERMOSTAT) {
JsonDocument doc;
JsonObject json = doc.to<JsonObject>();
const char * name[] = {"switchprog1", "switchprog2", "switchprog", "circswitchprog"};
for (uint8_t i = 0; i < sizeof(name) / sizeof(char *); i++) {
if (emsdevice->get_value_info(json, name[i], tag)) {
if (json.containsKey("value")) {
if ((Mqtt::is_nested())) {
if (circuit.isNull()) {
circuit = output[EMSdevice::tag_to_mqtt(tag)].to<JsonObject>();
}
circuit[name[i]] = json["value"];
} else {
std::string topic = "thermostat_" + std::string(name[i]) + "_" + std::string(EMSdevice::tag_to_mqtt(tag));
Mqtt::queue_publish(topic, json["value"].as<std::string>());
}
}
}
}
}
}
}
if (output.size()) {
Mqtt::queue_publish("thermostat_switchprog", output.as<JsonObject>());
}
}

// call the devices that don't need special attention
void EMSESP::publish_other_values() {
publish_device_values(EMSdevice::DeviceType::SWITCH);
Expand All @@ -691,6 +724,7 @@ void EMSESP::publish_other_values() {

webSchedulerService.publish();
webCustomEntityService.publish();
publish_thermostat_timer();
}

// publish both the temperature and analog sensor values
Expand Down
1 change: 1 addition & 0 deletions src/emsesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class EMSESP {
static void publish_device_values(uint8_t device_type);
static void publish_other_values();
static void publish_sensor_values(const bool time, const bool force = false);
static void publish_thermostat_timer();
static void publish_all(bool force = false);
static void reset_mqtt_ha();

Expand Down
1 change: 1 addition & 0 deletions src/locale_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ MAKE_NOTRANSLATION(progf, "prog f")
MAKE_NOTRANSLATION(rc35, "RC35")
MAKE_NOTRANSLATION(rc30, "RC30")
MAKE_NOTRANSLATION(rc300, "RC300")
MAKE_NOTRANSLATION(junkers, "Junkers")
MAKE_NOTRANSLATION(0kW, "0 kW")
MAKE_NOTRANSLATION(2kW, "2 kW")
MAKE_NOTRANSLATION(3kW, "3 kW")
Expand Down
11 changes: 4 additions & 7 deletions src/locale_translations.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,13 +622,10 @@ MAKE_TRANSLATION(wwOneTimeKey, "onetimekey", "one time key function", "Einmallad
MAKE_TRANSLATION(wwSolarTemp, "solartemp", "solar boiler temperature", "Solarboiler Temperatur", "Zonneboiler temperatuur", "Solpanel Temp", "temperatura zasobnika solarnego", "solpaneltemp", "température chaudière solaire", "güneş enerjisi kazan sıcaklığı", "temperatura pannello solare", "teplota solárneho kotla")

// mqtt values / commands
// MAKE_TRANSLATION(switchtimeA, "switchtimeA", "program switchtime A", "Programm Schaltzeit A", "Programma schakeltijd", "Program Bytestid", "program czasowy", "programbyttetid", "heure commutation programme", "program değiştirme süresi", "ora commutazione programmata", "čas prepnutia programu")
// MAKE_TRANSLATION(switchtimeB, "switchtimeB", "program switchtime B", "Programm Schaltzeit B", "Programma schakeltijd", "Program Bytestid", "program czasowy", "programbyttetid", "heure commutation programme", "program değiştirme süresi", "ora commutazione programmata", "čas prepnutia programu")
MAKE_TRANSLATION(switchtime, "switchtime", "program switchtime", "Programm Schaltzeit", "Programma schakeltijd", "Program Bytestid", "program czasowy", "programbyttetid", "heure commutation programme", "program değiştirme süresi", "ora commutazione programmata", "čas prepnutia programu")
MAKE_TRANSLATION(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", "program1 değiştirme süresi", "ora commutazione programma 1", "vlastný 1 program prepnutia")
MAKE_TRANSLATION(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", "program1 değiştirme süresi", "ora commutazione programma 2", "vlastný 2 program prepnutia")
// MAKE_TRANSLATION(wwswitchtime, "switchtime", "program switchtime", "Programm Schaltzeit", "Warm water programma schakeltijd", "Varmvattenprogram Bytestid", "program czasowy", "byttetid varmtvannsprogram", "heure commutation programme", "sıcak kullanıom suyu program değiştirme süresi", "Tempo di commutazione del programma", "čas prepnutia programu")
MAKE_TRANSLATION(circswitchtime, "circswitchtime", "circulation program switchtime", "Zirculationsprogramm Schaltzeit", "Schakeltijd circulatieprogramma", "Cirkulationsprogram Bytestid", "program cyrkulacji", "byttetid sirkulasjonsprogram", "heure commutation programme circulation", "sirkülasyon program değiştirme süresi", "ora commutazione programma circolazione", "čas prepnutia cirkulačného programu")
MAKE_TRANSLATION(switchtime, "switchprog", "program switchtime", "Programm Schaltzeit", "Programma schakeltijd", "Program Bytestid", "program czasowy", "programbyttetid", "heure commutation programme", "program değiştirme süresi", "ora commutazione programmata", "čas prepnutia programu")
MAKE_TRANSLATION(switchtime1, "switchprog1", "program 1 switchtime", "Programm 1 Schaltzeit", "Schakeltijd programma 1", "Program 1 Bytestid", "program przełączania 1", "byttetidprogram 1", "heure de commutation programme 1", "program1 değiştirme süresi", "ora commutazione programma 1", "vlastný 1 program prepnutia")
MAKE_TRANSLATION(switchtime2, "switchprog2", "program 2 switchtime", "Programm 2 Schaltzeit", "Schakeltijd programma 2", "Program 2 Bytestid", "program przełączania 2", "byttetid program 2", "heure de changement programme 2", "program1 değiştirme süresi", "ora commutazione programma 2", "vlastný 2 program prepnutia")
MAKE_TRANSLATION(circswitchtime, "circswitchprog", "circulation program switchtime", "Zirculationsprogramm Schaltzeit", "Schakeltijd circulatieprogramma", "Cirkulationsprogram Bytestid", "program cyrkulacji", "byttetid sirkulasjonsprogram", "heure commutation programme circulation", "sirkülasyon program değiştirme süresi", "ora commutazione programma circolazione", "čas prepnutia cirkulačného programu")
MAKE_TRANSLATION(dateTime, "datetime", "date/time", "Datum/Zeit", "Datum/Tijd", "Datum/Tid", "data i godzina", "dato/tid", "date/heure", "zaman/saat", "Data/Ora", "dátum/čas")
MAKE_TRANSLATION(errorCode, "errorcode", "error code", "Fehlernummer", "Foutmeldingscode", "Felkod", "kod błędu", "feikode", "code erreur", "hata kodu", "codice errore", "error kód")
MAKE_TRANSLATION(ibaMainDisplay, "display", "display", "Anzeige", "Display", "Display", "wyświetlacz", "skjerm", "affichage", "ekran", "Display", "display")
Expand Down

0 comments on commit 4203b39

Please sign in to comment.