If you know the time between the measurements, or if the time is deterministic (e.g. you’ll get an update each 10s), then you can calculate it like that.
Otherwise it is not really doable, since you need to get rid of the “per second” which usually means you have a time interval you can use.
Which binding are you using to get the information about the network card? Isn’t there any other channel that provides the total amount of data?
i use data coming from node red,
I know the interval between each change, I use 2 epoch value to know the time of each change, then I multiply the value by the number of seconds
rule "server Nuc_2 network trafic send"
when
Item Nuc_2_Server_NetworkIntf_Send changed
then
var ZonedDateTime zdt = ZonedDateTime.now()// epoch time to date
epochStart = zdt.toInstant.toEpochMilli // create a epoch start`
if(Nuc_2_Server_NetworkIntf_Send_total.state == NULL)
{
Nuc_2_Server_NetworkIntf_Send_total.postUpdate(Nuc_2_Server_NetworkIntf_Send_total.previousState(true,"influxdb").state)
}
else
{
if (epochend != 0 )
{
// to secondes then to megabytes
val avg_send = ( ((Nuc_2_Server_NetworkIntf_Send.state as Number) * ((epochStart - epochend) / 1000)) / 1000000) // to megabyte
logInfo("epoch","avg_send= " + avg_send + "mb")
// adding calculated Mb to Send_total
Nuc_2_Server_NetworkIntf_Send_total.sendCommand(Nuc_2_Server_NetworkIntf_Send_total.state as Number + avg_send as Number)
logInfo("epoch","Nuc_2_Server_NetworkIntf_Send_total= " +(Nuc_2_Server_NetworkIntf_Send_total.state as Number))
}
//update today value since time
Nuc_2_Server_NetworkIntf_Send_today.sendCommand(Nuc_2_Server_NetworkIntf_Send_total.deltaSince(now.with(LocalTime.of(0,0,0,0)),"influxdb") as Number)
//epoch a la sortie de la rule pour comparer avec le passage suivant
epochend = zdt.toInstant.toEpochMilli // create a epoch end`
}
I think that will work OK. You’ll probably end up with rounding errors and such which build up over time but in general that should get you close to the amount of data transmitted over the course of time. The longer the time between reports, the more errors that will creep into the calculation. If you are looking for an accurate measurement of total amount of bytes transmitted over long periods of time, you might have to find ways to get that information elsewhere. But for a number that’s kind of close, this should be good enough.