Problems with ADR plugin

so I migrated my ADR plugin from v3 to v4 as decribed here but it does not work as intended.
When a new device joins it does that always with DR0. With the default builtin ADR that is changed right after the first uplink to DR5 an TX0 if I am close to the gateway.
With my migrated plugin it does not, it stays at DR0 and seems to never change.
I checked it over an over and debugged the script it with the test data, changed the values of the test data to real values from a device and it works and return DR5 and TX0 but not when used in Chirpstack.
I have no idea why is it not working…

And I got a question too, I stumbled over that line here.
If steps are negative and the history does not contain exactly 20 items with the same TX then it just returns? Why is it ‘!=’? Is 20 a magic number? Is 20 the maximum size so if all history items have the same TX then do nothing?

I really need my ADR to get going again because the RN2384 devices have issues if you set TX to 0. I also activated decreasing the DR, I know that is not recommended…

Any help appriciated…