n8acl / bmlh_to_mqtt

Bridges the Brandmeister Last Heard API to a local MQTT Broker
7 stars 2 forks source link

NameError: name 'event' is not defined #1

Closed oh2th closed 3 weeks ago

oh2th commented 3 weeks ago

When starting the code, I get numerous errors of this:

File "/home/tj/src/network.bransmeister.lastheard_to_mqtt/bmlh_to_mqtt.py", line 70, in on_mqtt
    elif event == 'Session-Stop' and callsign != '':
         ^^^^^
NameError: name 'event' is not defined
Exception in thread Thread-71 (_handle_eio_message):
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/socketio/client.py", line 705, in _handle_eio_message
    self._handle_event(pkt.namespace, pkt.id, pkt.data)
  File "/usr/lib/python3/dist-packages/socketio/client.py", line 581, in _handle_event
    r = self._trigger_event(data[0], namespace, *data[1:])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/socketio/client.py", line 629, in _trigger_event
    return self.handlers[namespace][event](*args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

paho-mqtt 1.6.1 request 2.28.1 python-socketio[client] 5.7.2

oh2th commented 3 weeks ago

What are those spammers?

n8acl commented 3 weeks ago

Not sure what those spammers are. Ignore them they are wrong. Let me take a look at it when I have a chance today. BM might have changed something again on their data feed.

n8acl commented 3 weeks ago

So I can't blame BM on this one. This one was all me. For some reason and the version I pushed up, I left out the instantiation of the 'event' variable I needed to confirm if the transmission was done. I added that and tested and it works just fine now. go ahead and repull. You might have to copy your config.py file out somewhere else, pull and then put it back. That way you don't loose your configs. Let me know if it is working for you.

oh2th commented 3 weeks ago

Found also, that the event was not pulled from the call and fixed already on my copy :)

n8acl commented 3 weeks ago

Perfect! Well that works! At least then others have the fix now :) Thanks for bringing this to my attention. Since it's working for you now I will go ahead and close this issue :)