diff --git a/src/widget/widgets/value.js b/src/widget/widgets/value.js
index f143cd0..0468b3e 100644
--- a/src/widget/widgets/value.js
+++ b/src/widget/widgets/value.js
@@ -33,31 +33,28 @@ class WidgetValue extends Component {
return null;
}
- // TODO does the following line make sense?
- const ICid = props.icIDs[0];
+ // get the signal with the selected signal ID
let signalID = props.widget.signalIDs[0];
- let signal = props.signals.find(sig => sig.id === signalID);
+ let signal = props.signals.filter(s => s.id === signalID)
+ // determine ID of infrastructure component related to signal[0] (there is only one signal for a value widget)
+ let icID = props.icIDs[signal[0].id];
-
- // update value
- let value = '';
- if (props.data == null
- || props.data[ICid] == null
- || props.data[ICid].output == null
- || props.data[ICid].output.values == null) {
+ // check if data available
+ let value = ''
+ if (props.data == null || props.data[icID] == null || props.data[icID].output == null || props.data[icID].output.values == null) {
value = '';
} else {
// check if value has changed
- const signalData = props.data[ICid].output.values[signal.index];
- if (signalData != null && state.value !== signalData[signalData.length - 1].y) {
- value = signalData[signalData.length - 1].y
+ const data = props.data[icID].output.values[signal[0].index - 1];
+ if (data != null && Number(state.value) !== data[data.length - 1].y) {
+ value = data[data.length - 1].y;
}
}
// Update unit (assuming there is exactly one signal for this widget)
let unit = '';
if(signal !== undefined){
- unit = signal.unit;
+ unit = signal[0].unit;
}
return {
@@ -77,7 +74,7 @@ class WidgetValue extends Component {
{Number.isNaN(value_to_render) ? NaN : format('.3s')(value_to_render)}
{this.props.widget.customProperties.showUnit &&
[{this.state.unit}]
- }
+ }
);
}