Closed koenkooi closed 6 years ago
I have been using the log as a debugging mechanism, sometimes I like to see the raw data. I'll look into getting this stuff silenced. Do you have any other suggestions?
Thanks!
When I say 'log' I mean the button 'log' inside the switch item in the webgui, not 'Settings -> log' log. I'm using the regular to to debug this plugin as well :) The issue I have is that the plugin sends the traceback as status, so when sending this data on or using it in events things get funky :)
I looked into this some more and traced where these things come from. GetTVInfo() does the following:
self.tvPlaying = str(currentChannel + ' (' + currentInfo + ')' )
On my webOs 3.0 TV, 'currentChannel' is truncated JSON and 'currentInfo' is either truncated JSON or invalid leading to a traceback.
If I change it to the following:
- self.tvPlaying = str(currentChannel + ' (' + currentInfo + ')' )
+ # Add check for JSON
+ # pylgtv seems to return invalid JSON, so parse the fragment ourselfs
+ currentChannelInfo = currentChannel.split(',')
+ currentChannelName = next((s for s in currentChannelInfo if 'channelName' in s), None).split('\'')[3]
+ currentChannelNumber = next((s for s in currentChannelInfo if 'channelNumber' in s), None).split('\'')[3]
+
+ self.tvPlaying = str(currentChannelNumber + ': ' + currentChannelName )
I'm no longer getting JSON and traceback sent to domoticz as status, but '24: 24Kitchen HD'. I need to rework the above to use the old behaviour for non-JSON replies and the new for JSON replies and send a PR.
currentInfo will need some more work, since the reply depends on the channel. For my provider and area (Ziggo, Netherlands) 'National Geographic' will give JSON listing a few programs with their start and end times, but '24Kitchen' will return something that leads to the traceback.
Thanks for working on this! I don't have any cable channels, so it's hard for me to test any changes around the channel information.
When looking at the switch log in domoticz it has a lot of spurious data:
It has both traceback from timeouts as well as raw json.