mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-05-03 14:49:33 +00:00
Tariff thresholds on MQTT
This commit is contained in:
@@ -199,6 +199,15 @@ bool RawMqttHandler::publishRealtime(EnergyAccounting* ea) {
|
||||
mqtt.loop();
|
||||
mqtt.publish(topic + "/realtime/export/month", String(ea->getProducedThisMonth(), 1));
|
||||
mqtt.loop();
|
||||
uint32_t now = millis();
|
||||
if(lastThresholdPublish == 0 || now-lastThresholdPublish > 3600000) {
|
||||
EnergyAccountingConfig* conf = ea->getConfig();
|
||||
for(uint8_t i = 0; i < 9; i++) {
|
||||
mqtt.publish(topic + "/realtime/import/thresholds/" + String(i+1, 10), String(conf->thresholds[i], 10), true, 0);
|
||||
mqtt.loop();
|
||||
}
|
||||
lastThresholdPublish = now;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -328,6 +337,15 @@ bool RawMqttHandler::publishPrices(PriceService* ps) {
|
||||
mqtt.publish(topic + "/price/cheapest/6hr", String(ts6hr), true, 0);
|
||||
mqtt.loop();
|
||||
}
|
||||
|
||||
float exportPrice = ps->getEnergyPriceForHour(PRICE_DIRECTION_EXPORT, now, 0);
|
||||
if(exportPrice == PRICE_NO_VALUE) {
|
||||
mqtt.publish(topic + "/exportprice/0", "", true, 0);
|
||||
mqtt.loop();
|
||||
} else {
|
||||
mqtt.publish(topic + "/exportprice/0", String(exportPrice, 4), true, 0);
|
||||
mqtt.loop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user