blynkkk / lib-python

Blynk IoT library for Python and Micropython
MIT License
237 stars 83 forks source link

updating a global variable inside a weather like script #10

Closed kindmartin closed 5 years ago

kindmartin commented 5 years ago

Hi there im trying to update a global variable (T_MIN4CF) via a slider widget. all the rest works ok but as soon I move the slider related to T_MIN4CF variable the program brakes. here the error and below the simple original code.

Any idea?

pi@raspizero:~/python/lib-python $ python3 multiTermy.py

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ for Python v0.2.4

Traceback (most recent call last): File "multiTermy.py", line 148, in File "/home/pi/python/lib-python/blynktimer.py", line 88, in run timers_intervals = [curr_timer.run() for curr_timer in Timer.timers.values() if not curr_timer.stopped] File "/home/pi/python/lib-python/blynktimer.py", line 88, in timers_intervals = [curr_timer.run() for curr_timer in Timer.timers.values() if not curr_timer.stopped] File "/home/pi/python/lib-python/blynktimer.py", line 113, in run self.deco(*self.args, **self.kwargs) File "multiTermy.py", line 103, in updateBlynkServer TypeError: unorderable types: float() <= list()

code;:

termy3 - Copy.txt

antohaUa commented 5 years ago

Hi ! Could you please provide listing of "multiTermy.py" cause in code "termy3" there is no line 148 Thus is is hard to say what exactly cause an error, but ... looks like you access not certain list value but whole list . Please check this link https://stackoverflow.com/questions/45409974/error-typeerror-unorderable-types-float-list

kindmartin commented 5 years ago

Thanks a lot AntohaUa, after reading your link and doing some troubleshooting, I found that I wrongly expected that Blynk lib @blynk.handle_event('write V4') pass an int value to python whenever app update the code. but didn't, it pass a python list and then brokes the pipeline. also looking inside the blynk python lib I found the very explicit 'write V4' for instance registered value looking for a List.

In my code instead update T_MIN4CF = V4value, I resolved just aiming the [0] element in the list, (the only one on it ) and then casting to float. T_MIN4CF = float(V4value[0])

@blynk.handle_event('write V4') def write_virtual_pin_handler(pin, V4value): global T_MIN4CF T_MIN4CF = float(V4value[0])

antohaUa commented 5 years ago

Good news!! As I understand for now this issue can be closed as resolved, correct ?

antohaUa commented 5 years ago

Can be closed as resolved.