yoctopuce / yoctolib_python

Official Yoctopuce Library for Python
https://www.yoctopuce.com/EN/article/how-to-start-in-python-with-yoctopuce-modulesp
20 stars 12 forks source link

Correct volume attribute name in set_volume setter #7

Closed arslogavitabrevis closed 1 year ago

arslogavitabrevis commented 1 year ago

I run into some issues with the volume not updated and even being 0 after having called the function set_volume from the yoctopuce_buzzer.

After some tinkering, I realised that the "volume" attribute did not exist but the "_volume" did exist. After changing the string parameter for the attribute name it did work.

This may also be linked to how the _setAttr method work.

srinsoz commented 1 year ago

I've double check the code and everything work as expected. The first argument of the _setAttr method is the attribute of the device name to update, not the python variable.

When you call set_volume, the library does not update the _volume variable. It' send the command to the module and invalidate the cache. Then, when you call get_volume, the value is loaded directly from the module.