1

I use the PiIR module to record infrared light buttons and it works. But when I use piir play I get the following error. Does anyone know how fix that?

Keep in mind: I use Python 3.7 and PiIR 0.2.4

Traceback (most recent call last):
  File "/usr/local/bin/piir", line 10, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.7/site-packages/piir/cli.py", line 243, in main
    args.func(args)
  File "/home/pi/.local/lib/python3.7/site-packages/piir/cli.py", line 69, in play
    remote.send(key, repeat=args.repeat)
  File "/home/pi/.local/lib/python3.7/site-packages/piir/remote.py", line 96, in send
    self.send_pulses(pulses, gap, carrier, repeat)
  File "/home/pi/.local/lib/python3.7/site-packages/piir/remote.py", line 70, in send_pulses
    t = gap / 1e6 - (time() - self.last_sent)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'
1
  • 2
    gap is None which troubles the division. gap is your problem, you need to look there. – Ghanima May 10 at 6:53
-1

The error message reports "type" error in the last line (Line 70 of remote.py):

File "/home/pi/.local/lib/python3.7/site-packages/piir/remote.py", line 70, in send_pulses
    t = gap / 1e6 - (time() - self.last_sent)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

The trouble maker seems to be the space character before the character "/".

One possibility is that you have carelessly inserted a redundant space between "gap" and "/".

In other words, removing the wrongly inserted space might solved the problem.


Update 2021may10hkt1743

On second thought, I now wildly guess that "1e6" should be the trouble maker. I think "1e6" is a float, and this float object is not supported by remote.py. My usual debugging trick is to replace "1e6" by an integer say "321" and see if the error message disappears.

3
  • 2
    An ordinary space (as in "not-a-spurious non-printable character") cannot be the problem. – Ghanima May 10 at 6:54
  • @Ghanima, you are probably right. On second thought, I now wildly guess that "1e6" should be the trouble maker. I think "1e6" is a float, and this float object is not supported by remote.py. My usual debugging trick is to replace "1e6" by an integer say "321" and see if the error message disappears. – tlfong01 May 10 at 7:05
  • The error fairly clearly shows the problem is gap is not defined. TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'. It is a NoneType. – joan May 10 at 15:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.