normen / homebridge-bravia

Homebridge plugin for Sony Bravia TVs (AndroidTV based ones and possibly others)
139 stars 26 forks source link

Getting "Illegal State" error every five seconds (default pull interval) #8

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi there,

I've just started using this plugin and got it working fairly well (TV turns on/off via Siri etc.), but my homebridge log is getting flooded with this error message now:

[7/2/2017, 10:07:50 AM] Homebridge is running on port 51826.
[7/2/2017, 10:08:10 AM] Error?  {"error":[7,"Illegal State"],"id":13}
[7/2/2017, 10:08:26 AM] Error?  {"error":[7,"Illegal State"],"id":13}
[7/2/2017, 10:08:31 AM] Error?  {"error":[7,"Illegal State"],"id":13}
[7/2/2017, 10:08:36 AM] Error?  {"error":[7,"Illegal State"],"id":13}
[7/2/2017, 10:08:41 AM] Error?  {"error":[7,"Illegal State"],"id":13}
[7/2/2017, 10:08:46 AM] Error?  {"error":[7,"Illegal State"],"id":13}

(This is already with the --debug option of homebridge, and I've also tried to check the source of the plugin to see if I could spot the error, but it seems that the message comes from homebridge itself as I couldn't even find the string "Illegal State". (Or is it a response from the Bravia API?) Any idea what might cause this? My TV is only using HDMI, there is no DVB-T/-S/-anything configured, so maybe it's that? When turning on/off via Homebridge it does exactly what I want, though: Just turn on with the most recently used HDMI-input active.

normen commented 7 years ago

No issue. Sometimes the requests get denied because the TV is in some other state or doesn't support features.

ghost commented 7 years ago

How is it not an issue when this happens every five seconds, i.e. on every state check? That's almost a megabyte of log entries per day. I would not have reported it if it would only happen during startup or when I switch channels… it's happening just due to the plugin running, no matter if the TV is set to HDMI, or in the settings, or in the Home menu. It's happening so frequently that other/actual errors or log file entries will be drowned in this "non-issue". If it's not an issue, it should not report the error message to the logfile?

normen commented 7 years ago

Yeah, I'll disable the logging of such errors for the 1.0 release version anyway. You should look into "logrotate".

normen commented 7 years ago

And yeah, it probably is due to you not using the normal TV channels, you can probably avoid this by simply setting a source as in the example config.json file. (Thats why its listed under "required options")

ghost commented 7 years ago

I know about logrotate – doesn't change my opinion about whether this error should be reported in that way or not. ;) I've set all the required options, including tvsource. I'd be happy to help you debug anything in case you want to handle that case or find out if it's really the reason at all. Let me know if there is anything I can do to help you fix this and/or implement #4

normen commented 7 years ago

Well as said these errors won't be logged in the future, the plugin will simply assume the command couldn't be executed. I guess in this case "illegal state" means the TV can't give a list of channels for the dvb source because there is no list - in any case it will simply not provide the channel switching ability if this fails for any TV for any reason.

As for the source switching, its adding two methods and a new way of selecting the channel, I'm not sure if its the best way to add it to the existing channels and make it max_channels+av_inputs+apps or if there should be a new parameter. Heres the API of the sony TV for that:

http://192.168.2.103/sony/avContent

{"results":[["deleteContent",["{\"uri\":\"string\"}"],[],"1.0"],["getContentCount",["{\"source\":\"string\", \"type\":\"string\"}"],["{\"count\":\"int\"}"],"1.0"],["getContentList",["{\"source\":\"string\", \"stIdx\":\"int\", \"cnt\":\"int\", \"type\":\"string\"}"],["{\"uri\":\"string\", \"title\":\"string\", \"index\":\"int\", \"dispNum\":\"string\", \"originalDispNum\":\"string\", \"tripletStr\":\"string\", \"programNum\":\"int\", \"programMediaType\":\"string\", \"directRemoteNum\":\"int\", \"startDateTime\":\"string\", \"durationSec\":\"int\", \"channelName\":\"string\", \"fileSizeByte\":\"int\", \"isProtected\":\"bool\", \"isAlreadyPlayed\":\"bool\"}*"],"1.0"],["getCurrentExternalInputsStatus",[],["{\"uri\":\"string\", \"title\":\"string\", \"connection\":\"bool\", \"label\":\"string\", \"icon\":\"string\"}*"],"1.0"],["getParentalRatingSettings",[],["{\"ratingTypeAge\":\"int\", \"ratingTypeSony\":\"string\", \"ratingCountry\":\"string\", \"ratingCustomTypeTV\":\"string*\", \"ratingCustomTypeMpaa\":\"string\", \"ratingCustomTypeCaEnglish\":\"string\", \"ratingCustomTypeCaFrench\":\"string\", \"unratedLock\":\"bool\"}"],"1.0"],["getPlayingContentInfo",[],["{\"uri\":\"string\", \"source\":\"string\", \"title\":\"string\", \"dispNum\":\"string\", \"originalDispNum\":\"string\", \"tripletStr\":\"string\", \"programNum\":\"int\", \"programTitle\":\"string\", \"startDateTime\":\"string\", \"durationSec\":\"int\", \"mediaType\":\"string\", \"playSpeed\":\"string\", \"bivl_serviceId\":\"string\", \"bivl_assetId\":\"string\", \"bivl_provider\":\"string\"}"],"1.0"],["getSchemeList",[],["{\"scheme\":\"string\"}*"],"1.0"],["getSourceList",["{\"scheme\":\"string\"}"],["{\"source\":\"string\"}*"],"1.0"],["setDeleteProtection",["{\"uri\":\"string\", \"isProtected\":\"bool\"}"],[],"1.0"],["setFavoriteContentList",["{\"favSource\":\"string\", \"contents\":\"string*\"}"],[],"1.0"],["setPlayContent",["{\"uri\":\"string\"}"],[],"1.0"],["setPlayTvContent",["{\"channel\":\"string\"}"],[],"1.0"],["setTvContentVisibility",["{\"uri\":\"string\", \"epgVisibility\":\"string\", \"channelSurfingVisibility\":\"string\", \"visibility\":\"string\"}*"],[],"1.0"],["getMethodTypes",["string"],["string","string*","string*","string"],"1.0"],["getVersions",[],["string*"],"1.0"]],"id":1}

But generally I think its best to control the HDMI device itself, for example I control my PS4 directly via HomeBridge and when it turns on the TV automatically switches the input (or on).

normen commented 6 years ago

Any news on implementing #4?