Skip to content

Commit

Permalink
Adds numbersArray to SdOfflineLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
TonProtofy committed Nov 12, 2024
1 parent 69af5a5 commit b7d887b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/protodevice/src/device/SdOfflineLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class SdOfflineLogger {
publishDataWhenOnline;
publishDataTopic;
sensorsArray;
numbersArray;

constructor(name, timeId, jsonFileName, intervalSeconds, publishDataWhenOnline, publishDataTopic) {
this.name = name;
Expand All @@ -19,6 +20,7 @@ class SdOfflineLogger {
this.publishDataWhenOnline = publishDataWhenOnline;
this.publishDataTopic = publishDataTopic;
this.sensorsArray = [];
this.numbersArray = [];
}

extractNestedComponents(element, deviceComponents) {
Expand Down Expand Up @@ -64,6 +66,12 @@ class SdOfflineLogger {
}
});

deviceComponents?.number?.forEach((text_sensor) => {
if (text_sensor.id){
this.numbersArray.push(text_sensor.id);
}
});

const componentObjects = [
{
name: "external_components",
Expand All @@ -84,14 +92,9 @@ class SdOfflineLogger {
interval_seconds: this.intervalSeconds,
publish_data_when_online: this.publishDataWhenOnline,
publish_data_topic: deviceComponents.mqtt?.topic_prefix+this.publishDataTopic,
sensors: this.sensorsArray,
sensors: this.sensorsArray.length > 0 ? this.sensorsArray : undefined,
numbers: this.numbersArray.length > 0 ? this.numbersArray : undefined
},
},
{
name: "esphome",
config: {
libraries: ["spi", "FS", "SD"]
}
}
];

Expand Down

0 comments on commit b7d887b

Please sign in to comment.