Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find_ballasts.py #36

Closed
fabltd opened this issue Sep 14, 2016 · 8 comments
Closed

find_ballasts.py #36

fabltd opened this issue Sep 14, 2016 · 8 comments

Comments

@fabltd
Copy link

fabltd commented Sep 14, 2016

When running this module I get the following error:

TypeError: unsupported operand type(s) for >>: 'float' and 'int'

It appears that :
low = 0
high = 0xffffff

if response.value is True:
midpoint = (low + high) / 2

results in a value of 838607.5 (float)

Whats the fix?

@rnixx
Copy link
Contributor

rnixx commented Sep 14, 2016

I'd say

midpoint = round((low + high) / 2)

@sde1000 ?

@fabltd
Copy link
Author

fabltd commented Sep 14, 2016

Hi

Its a python 3 issue:

In Python 3, / is float division

In Python 2, / is integer division (assuming int inputs)

In both 2 and 3, // is integer division

@sde1000
Copy link
Owner

sde1000 commented Sep 14, 2016

...and you can get the python 3 behaviour in python 2 using from __future__ import division

python-dali doesn't support python 3 at the moment. I will be fixing this before the end of November because I need python 3 support myself!

@fabltd
Copy link
Author

fabltd commented Sep 14, 2016

@sde1000

Thanks. I have been modifying the code to run with Python 3 and an RS232 interface.

Do you expect the find ballast process to be quite slow?

@sde1000
Copy link
Owner

sde1000 commented Sep 14, 2016

Depending on the number of ballasts, yes it is slow.

@dgomes
Copy link
Contributor

dgomes commented Dec 21, 2016

Using python3 (trying to integrate DALI into home-assistant.io) and except for this all works in python3

@sde1000
Copy link
Owner

sde1000 commented Dec 21, 2016

Commit 27f8909 which I've just pushed may help with this.

If it doesn't, can you let me know how it's failing? I don't have a test environment set up at the moment; I need to buy another DALI interface...

@dgomes
Copy link
Contributor

dgomes commented Dec 21, 2016

well I fixed it myself in the example code :) didn't notice there were more about it in the code.

Thanks for all your work!

@sde1000 sde1000 closed this as completed Mar 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants