mqtt publish peiod per device, publish on change, ADC

This commit is contained in:
MichaelDvP
2020-09-05 16:50:21 +02:00
parent 1636059823
commit 18421d3d1e
22 changed files with 531 additions and 286 deletions

View File

@@ -292,22 +292,37 @@ void EMSESP::show_sensor_values(uuid::console::Shell & shell) {
shell.println();
}
// publish all values from each EMS device to MQTT
// plus the heartbeat and sensor if activated
void EMSESP::publish_all_values() {
void EMSESP::publish_device_values(uint8_t device_type) {
if (Mqtt::connected()) {
// Dallas sensors first
sensors_.publish_values();
// all the connected EMS devices we known about
for (const auto & emsdevice : emsdevices) {
if (emsdevice) {
if (emsdevice && (emsdevice->device_type() == device_type)) {
emsdevice->publish_values();
}
}
}
}
void EMSESP::publish_other_values() {
if (Mqtt::connected()) {
for (const auto & emsdevice : emsdevices) {
if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::BOILER)
&& (emsdevice->device_type() != EMSdevice::DeviceType::THERMOSTAT)
&& (emsdevice->device_type() != EMSdevice::DeviceType::SOLAR)
&& (emsdevice->device_type() != EMSdevice::DeviceType::MIXING)) {
emsdevice->publish_values();
}
}
}
}
void EMSESP::publish_sensor_values(const bool force) {
if (Mqtt::connected()) {
if (sensors_.updated_values() || force) {
sensors_.publish_values();
}
}
}
// search for recognized device_ids : Me, All, otherwise print hex value
std::string EMSESP::device_tostring(const uint8_t device_id) {
if ((device_id & 0x7F) == rxservice_.ems_bus_id()) {
@@ -508,7 +523,7 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
found = emsdevice->handle_telegram(telegram);
// check to see if we need to follow up after the telegram has been processed
if (found) {
if (emsdevice->updated_values() || telegram->type_id == publish_id_) {
if ((mqtt_.get_publish_onchange(emsdevice->device_type()) && emsdevice->updated_values()) || telegram->type_id == publish_id_) {
if (telegram->type_id == publish_id_) {
publish_id_ = 0;
}