Added MQTTStore.

This commit is contained in:
2021-10-25 16:52:34 -04:00
parent f45f667af6
commit 5c92213ee0
8 changed files with 308 additions and 65 deletions

View File

@@ -68,7 +68,12 @@ extension Sensor: FetchableTopic where Reading: BufferInitalizable {
extension MQTTNIO.MQTTClient {
func mqttSubscription(topic: String, qos: MQTTQoS = .atLeastOnce, retainAsPublished: Bool = true, retainHandling: MQTTSubscribeInfoV5.RetainHandling = .sendAlways) -> MQTTSubscribeInfoV5 {
func mqttSubscription(
topic: String,
qos: MQTTQoS = .atLeastOnce,
retainAsPublished: Bool = true,
retainHandling: MQTTSubscribeInfoV5.RetainHandling = .sendAlways
) -> MQTTSubscribeInfoV5 {
.init(topicFilter: topic, qos: qos, retainAsPublished: retainAsPublished, retainHandling: retainHandling)
}
@@ -103,7 +108,6 @@ extension MQTTNIO.MQTTClient {
}
func fetch(setPoint: KeyPath<Topics.SetPoints, String>, setPoints: Topics.SetPoints) -> EventLoopFuture<Double> {
// logger.debug("Fetching data for set point: \(setPoint.topic)")
return fetch(mqttSubscription(topic: setPoints[keyPath: setPoint]))
}