eslavnov / pylips

Control Philips TVs (2015+) and Ambilight (+ Hue) through their reverse-engineered API (+ MQTT support!)
MIT License
342 stars 60 forks source link

[BUG] "TypeError: option values must be strings" when writing apiversion to config #98

Closed DavidSchmidt00 closed 3 years ago

DavidSchmidt00 commented 3 years ago

Describe the bug

When trying to setup pylips with an old PhilipsTV (model 42PFL6097K/12 using apiversion 1) it throws a TypeError, because in line 156 it tries to write an integer to the config.

Console output

python pylips.py --host 192.168.178.24

Checking API version and port...
Trying http://192.168.178.24:1925/6/system
Trying http://192.168.178.24:1925/5/system
Connection refused
Trying http://192.168.178.24:1925/1/system
Could not find a valid API version! Pylips will try to use ' 1 '
Traceback (most recent call last):
  File "pylips.py", line 477, in <module>
    pylips = Pylips(args.config)
  File "pylips.py", line 83, in __init__
    if self.find_api_version(self.verbose):
  File "pylips.py", line 156, in find_api_version
    self.config["TV"]["apiv"] = api_version
  File "C:\Users\davod\AppData\Local\Programs\Python\Python38\lib\configparser.py", line 1258, in __setitem__
    self._parser._validate_value_types(option=key, value=value)
  File "C:\Users\davod\AppData\Local\Programs\Python\Python38\lib\configparser.py", line 1185, in _validate_value_types
    raise TypeError("option values must be strings")
TypeError: option values must be strings

How to fix Change line 156 to: self.config["TV"]["apiv"] = str(api_version)

eslavnov commented 3 years ago

Thanks @DavidSchmidt00!

Wow, this is embarrassing - I guess I've been spending too much time with JS lately... Fixed now, sorry about that!

DavidSchmidt00 commented 3 years ago

Thanks :)