I'm creating a flow that warns me in case of high mobile data usage. My phone sends the data used to Home Assistant multiple times per hour.
However when my smartphone reboots the counter is reset to 0. My wife has a OnePlus which has a problem where sometimes the data goes down.
How I want to adress this:
Every time a new value comes in, I fetch the values of the last hour in an array.
The array is sorted based on time and in normal situations the data used is also in increasing order. It Only in the case of the two above problems will data usage not be in ascending order.
What I would therefore like to achieve is that when it sees an entry in the array that is not in ascending order that this entry is deleted as well as all the entries before that.
So in the example below the two first entries should be deleted, while the remaining two entries should be kept.
Problem is that I don't know how to accomplish that. All the rest of the flow I have been able to develop but I'm missing that part. Does anybody know how to do this?
Many thanks!
{
"_msgid":"f82704f1a1af8c25",
"payload":[
{
"entity_id":"sensor.mobile_quizzical_mobile_data_consumed_since_reboot",
"state":"0.05",
"attributes":{
"state_class":"total_increasing",
"unit_of_measurement":"GB",
"friendly_name":"Mobile quizzical mobile data consumed since reboot"
},
"last_changed":"2022-07-31T16:09:24.574000+00:00",
"last_updated":"2022-07-31T16:09:24.574000+00:00"
},
{
"entity_id":"sensor.mobile_quizzical_mobile_data_consumed_since_reboot",
"state":"0.051",
"attributes":{
"state_class":"total_increasing",
"unit_of_measurement":"GB",
"friendly_name":"Mobile quizzical mobile data consumed since reboot"
},
"last_changed":"2022-07-31T16:27:45.603872+00:00",
"last_updated":"2022-07-31T16:27:45.603872+00:00"
},
{
"entity_id":"sensor.mobile_quizzical_mobile_data_consumed_since_reboot",
"state":"0.0",
"attributes":{
"state_class":"total_increasing",
"unit_of_measurement":"GB",
"friendly_name":"Mobile quizzical mobile data consumed since reboot"
},
"last_changed":"2022-07-31T16:31:41.465519+00:00",
"last_updated":"2022-07-31T16:31:41.465519+00:00"
},
{
"entity_id":"sensor.mobile_quizzical_mobile_data_consumed_since_reboot",
"state":"0.008",
"attributes":{
"state_class":"total_increasing",
"unit_of_measurement":"GB",
"friendly_name":"Mobile quizzical mobile data consumed since reboot"
},
"last_changed":"2022-07-31T17:07:51.227835+00:00",
"last_updated":"2022-07-31T17:07:51.227835+00:00"
}
],
"topic":"",
"startdate":"2022-07-31T16:09:24.574Z",
"enddate":"2022-07-31T17:09:24.574Z",
"entity_id":"sensor.mobile_quizzical_mobile_data_consumed_since_reboot"
}