joopert / nad_receiver

python api to connect to NAD receivers
MIT License
12 stars 18 forks source link

typeerror cannot concatenate 'str' and 'int' objects #45

Closed joopert closed 3 years ago

joopert commented 3 years ago

I had some time to put the 0.2.0 in a custom component for home assistant. This resulted in the issue for me when setting the volume. Home assistant passes this as an int while in the new code it must be passed as a str.

In the old code we converted it to a str https://github.com/joopert/nad_receiver/blob/0.1.0/nad_receiver/__init__.py#L37 and in the new code we don't https://github.com/joopert/nad_receiver/blob/master/nad_receiver/__init__.py#L46 To be backwards compatible we should convert it to str again?

@gladhorn any suggestion for this? In my custom component I just fixed it with str(value)

andreas-amlabs commented 3 years ago

I want to remember that some platform sent e.g. -20.5 (not the telnet platform). But this fix should work also for that case, but I wonder, is not the 'type' information then incorrect. I guess I would correct the issue @ main_volume to better show where the unexpected input is received. main_volume then also has incorrect type information. Do many other commands also have unexpected input ? Then go with the current patch.

My 5-cents

joopert commented 3 years ago

There was at least one other method which also had some typeerror. I was thinking about the type information as well, so I think your way would be cleaner. I will look into which other method(s) have to be converted to str and do a new commit. Thanks.