How to check if printer is out of paper

How can I check if cups printer is out of paper using commands only (no gui).

EDIT: Is it possible to check that using python?

EDIT2:
I tried it with different printer (EPSON TM-m30). When I try to print without paper it stuck in Processing.

printer-state = processing
printer-state-message = Rendering completed
printer-state-reasons = none

But I still cant get info about paper.

I am not sure if it can help you, I created json file from some python code which reads printer attribues: https://pastebin.com/u97U9TnQ

Update

We bought another printer (Star Micronics TUP542), the printer has out of paper sensor: Near End Paper Sensor, but I can’t find any manual how to work with this sensor (sensor is plugged into printer). Does cups have some command for it? Or do I need to use some different tool?

I tried to get attributes using python, here is the result (json): https://pastebin.com/Z3Tiz5g9

BTW, printer-state is always 3, with or without paper. Is it supposed to change when printer is out of paper?
I think printer-state-reasons should say something about missing paper, but there is always ['none']

Update 2

Maybe I should try ESC/POS commands (here).
I found some codes on page 157 Transmission of status.

n = 1, 49: Sends paper detector status

But I am not sure what does mean n = 1, 49 Is it string or decimal or hex values? Why there is comma between 1 and 49.

I tried this python code:

command = [0x1D, 0x72, 1]
dest="/dev/usb/lp1"

with open(dest,"wb") as file:
    file.write(bytearray(command))

with open(dest,"rb") as file:
    data = file.read() # hangs
    print(data)

But read function hangs and never returns.

PS: I also tried different values ([0x1D, 0x72, 49], [0x1D, 0x72, 1, 49], [0x1D, 0x72, 1, 0x49]), but without success.

By the way, when I use sudo cat /dev/usb/lp1 it prints lot of ###.

When I use hexdump after cat I see this repeating sequence: 23 06 00 00 00 00 00 00 00