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

TvControl .. does not work #29

Open
Bonze255 opened this issue Mar 21, 2020 · 11 comments
Open

TvControl .. does not work #29

Bonze255 opened this issue Mar 21, 2020 · 11 comments

Comments

@Bonze255
Copy link

Can you give an example for reading current_channel?
i can connect to the tv and read some system.info(), volume... but when i call get_current_channel(), get_current_program() ... does not work.
I get an error, when i use the example from the readme.

Error 'NoneType' object has no attribute 'text_message'
`
from pywebostv.discovery import *
from pywebostv.connection import *
from pywebostv.controls import *

self._client.connect()
self._tv = TvControl(self._client)
self._tv.subscribe_get_current_channel(callback=self.on_current_channel)

def on_current_channel(status, payload):
if status:
self.logger.debug("LGWebos: current_program {}".format(payload))
else:
self.logger.debug("LGWebos: Something went wrong.")
`

@supersaiyanmode
Copy link
Owner

It's weird, there's no instance (that I could find) of this project reading/writing a field named text_message. Do you have a stacktrace? Where is it coming from?

Also, can you please retry that in a new virtualenv, and share the pip freeze output?

@Bonze255
Copy link
Author

i play around, without a try block self._tv.channel_list() or self._tv.subscribe_channel_list(callback=self.on_channel)
will raise

self._tv.subscribe_channel_list(callback=self.on_channel)

File "/usr/local/lib/python3.7/dist-packages/pywebostv/controls.py", line 76, in getattr
raise AttributeError(name)
AttributeError: subscribe_channel_list

but why?

@supersaiyanmode
Copy link
Owner

That is because channel_list(..) is not something you can subscribe to (because the TV doesn't emit events for it, and there's no subscription attribute that exists there).

However, looking at the source, I think self._tv.subscribe_get_current_channel(callback=self.on_current_channel) should work for you. Can you please paste the stacktrace associated with text_message as in the original post?

@Bonze255
Copy link
Author

ok, i would try it with that code and i would search fot the text_message.. I try it with a simple code now, but i think something is wrong..

self._tv.subscribe_get_current_channel(callback=self.on_current_channel)

returns Traceback (most recent call last): File "test.py", line 78, in <module> test() File "test.py", line 51, in __init__ self._tv.subscribe_get_current_channel(callback=self.on_current_channel) File "/usr/local/lib/python3.7/dist-packages/pywebostv/controls.py", line 76, in __getattr__ raise AttributeError(name) AttributeError: subscribe_get_current_channel

self._data['channel_list'] = self._tv.channel_list()

Traceback (most recent call last): File "test.py", line 78, in <module> test() File "test.py", line 53, in __init__ self._data['channel_list'] = self._tv.channel_list() File "/usr/local/lib/python3.7/dist-packages/pywebostv/controls.py", line 91, in __getattr__ raise AttributeError(name) AttributeError: channel_list
it seems for me, that Class TvControl does not work. The TV is using Webos 05.70. I read a long time ago, with other code the channel infos from the tv, so i know that this must work.

@Bonze255
Copy link
Author

i´ve checked the requirements, so ws4py==0.4.2 was version 0.5.1, i had now downgraded to ws4py==0.4.2 but its the same.
ive checked the pylgtv package, and call the get_current_channel() method, so i get

{'channelId': '7_17_4_0_1089_12020_1', 'signalChannelId': '1089_12020_1', 'channelModeId': 2, 'channelModeName': 'Satellite', 'channelTypeId': 6, 'channelTypeName': 'Satellite Digital TV', 'channelNumber': '4', 'channelName': 'RTL2', 'physicalNumber': 17, 'isSkipped': False, 'isLocked': False, 'isDescrambled': False, 'isScrambled': False, 'isFineTuned': False, 'isInvisible': False, 'favoriteGroup': 'A', 'hybridtvType': 'HBBTV', 'dualChannel': {'dualChannelId': None, 'dualChannelTypeId': None, 'dualChannelTypeName': None, 'dualChannelNumber': None}, 'returnValue': True}

i think there is a bug in your getattr(self, name): or TvControl

@Bonze255 Bonze255 changed the title get_current_channel.. does not work TvControl .. does not work Mar 23, 2020
@Bonze255
Copy link
Author

when i write the TvControl class diretly into my programfile, then it works ..
`class TvControl1(WebOSControlBase):
COMMANDS = {
"channel_down": {"uri": "ssap://tv/channelDown"},
"channel_up": {"uri": "ssap://tv/channelUp"},
"channel_list": {"uri": "ssap://tv/getChannelList"}

     }`

@supersaiyanmode
Copy link
Owner

Hey, hi. I haven't been able to reproduce it. If you are able to have it working in when you recreate the class in your local program as opposed to the installed library -- it sounds like a weird issue.

I noticed that you have the library installed to /usr/local/lib. Can you please retry installing it in a virtualenv?

@Bonze255
Copy link
Author

Bonze255 commented Apr 5, 2020

it works, but i have found something about the failure..

2020-04-05 17:50:37 ERROR CP Server Thread-8 Item tv.befehl.channel_down: problem running <bound method LGWebos.update_item of <plugins.webos.LGWebos object at 0x7fe0c489b748>>: 'NoneType' object has no attribute 'text_message'
Traceback (most recent call last):
File "/usr/local/smarthome/lib/item.py", line 2224, in __update
method(self, caller, source, dest)
File "/usr/local/smarthome/plugins/webos/init.py", line 342, in update_item
self._tv.channel_down()
File "/usr/local/lib/python3.7/dist-packages/pywebostv/controls.py", line 115, in request_func
timeout=timeout)
File "/usr/local/lib/python3.7/dist-packages/pywebostv/controls.py", line 59, in request
get_queue=True)
File "/usr/local/lib/python3.7/dist-packages/pywebostv/connection.py", line 166, in send_message
self.send(json.dumps(obj))
File "/usr/local/lib/python3.7/dist-packages/ws4py/websocket.py", line 299, in send
message_sender = self.stream.binary_message if binary else self.stream.text_message
AttributeError: 'NoneType' object has no attribute 'text_message'

@supersaiyanmode
Copy link
Owner

Sounds like your WebSocket stream is None. Are you sure you called .connect() ? So, the stream attribute should not be None after a successful .connect(). Can you please check when stream is set to None? At the moment, since you say it works for you, I am inclining towards closing this issue. But I'll keep it open in case you are able to find the real root cause.

@Bonze255
Copy link
Author

when i use subcribe, it is not possible to read some other infos from the same class,
when i dont use subscribe it works..

@supersaiyanmode
Copy link
Owner

@Bonze255 That sounds like a bug in the library. Can you please open a new bug (and perhaps close this one)?

Also, can you please include a small reproducible test code?

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

2 participants