How to automatically ping devices and use the result

Some battery operated devices can be pinged indeed, mostly those with bigger batteries , eg. Aqara Roller E1.
I don’t know how to ping, but this script might provide workaround.