-
Notifications
You must be signed in to change notification settings - Fork 1
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
TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple' #1
Comments
@akeshan, thanks for taking time to test this out and report a bug. Can you let me know the exact version of Python this is please? I've been using this with Python 3.5.1 and I'd like to try and reproduce this on my machine. I have an idea for a fix (in https://github.com/clach04/x10_any, looks like default_type needs a to_byte()), but I'd like to see it failing locally first. |
No problem, I believe that I have version 3.4.2 |
@akeshan just the information I needed. Thank you. I've been able to get hold of Python 3.4.4 and reproduced the problem. So there are 2-3 options for you at the moment:
If you are willing to try #2 that would give me more confidence in testing before I publish the next version. |
Thanks for the quick response. I tried #2 and downloaded the new file and the error is gone. However, I have a new issue now where I interact with the switches but the command isn't executed till I manually run a command through mochad. For example I have toggled three switches to the off state and then see no response so I manually go and try to turn one off and then I see all of them execute at once: pi@raspberrypi:~ $ telnet 0 1099 |
@akeshan thanks for being willing to test this! I do not have access to the hardware that Mochad uses so I've only tested this with a fake Mochad server so far. I think I know what the problem is, I've opened a new issue clach04/x10_any#1 which has a proposed fix (search for |
@akeshan I believe we've found a bug in Mochad but also in x10_any. I believe I have a fix for clach04/x10_any#1 and it is submitted. Can you give that a shot (same procedure as before)? One option which may be easier/quicker would be for you to checkout x10_any and then try a modified version of the sample from the readme, e.g.:
|
I tried replacing the '\n' with '\r' in the mochad_cmd line as suggested in the fix, however the issue still remains. I also tried it with '\r\n' and got the same result. The command is buffered until I run another one through telnet. |
@akeshan does:
work? If so I could remove the code that does a read from Mochad and clone nc behavior which is a write (no read) only operation instead. It may be that setting up a proxy server to record traffic would be a help but lets hold that idea in reserve for a while. |
Yes that works! |
@akeshan so the nc sample above works? Cool, I've removed the read code and made x10_any use |
https://pypi.python.org/pypi/x10_any/0.0.6 now posted and should be pip installable. Addresses both original problem with Python versions earlier than 3.5 and support real Mochad servers. |
I have setup the component to use Mochad.
When i try to toggle any of the switches, I receive the following TypeError. Please let me know how to resolve this. Thanks.
Jul 18 04:58:09 raspberrypi hass[3095]: 16-07-18 04:58:09 ERROR (ThreadPool Worker 16) [homeassistant.core] BusHandler:Exception doing job
Jul 18 04:58:09 raspberrypi hass[3095]: Traceback (most recent call last):
Jul 18 04:58:09 raspberrypi hass[3095]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 835, in job_handler
Jul 18 04:58:09 raspberrypi hass[3095]: func(arg)
Jul 18 04:58:09 raspberrypi hass[3095]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 688, in _execute_service
Jul 18 04:58:09 raspberrypi hass[3095]: service(call)
Jul 18 04:58:09 raspberrypi hass[3095]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/core.py", line 547, in call
Jul 18 04:58:09 raspberrypi hass[3095]: self.func(call)
Jul 18 04:58:09 raspberrypi hass[3095]: File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/switch/init.py", line 84, in handle_switch_service
Jul 18 04:58:09 raspberrypi hass[3095]: switch.turn_on()
Jul 18 04:58:09 raspberrypi hass[3095]: File "/home/pi/.homeassistant/custom_components/switch/x10.py", line 80, in turn_on
Jul 18 04:58:09 raspberrypi hass[3095]: self._device.x10_command(self._house_code, self._unit_number, 'ON')
Jul 18 04:58:09 raspberrypi hass[3095]: File "/home/pi/.homeassistant/deps/x10_any/init.py", line 154, in x10_command
Jul 18 04:58:09 raspberrypi hass[3095]: return self._x10_command(house_code, unit_number, state)
Jul 18 04:58:09 raspberrypi hass[3095]: File "/home/pi/.homeassistant/deps/x10_any/init.py", line 243, in _x10_command
Jul 18 04:58:09 raspberrypi hass[3095]: mochad_cmd = b"%s %s %s\n" % (self.default_type, house_and_unit, state)
Jul 18 04:58:09 raspberrypi hass[3095]: TypeError: unsupported operand type(s) for %: 'bytes' and 'tuple'
The text was updated successfully, but these errors were encountered: