AntonioMeireles / homebridge-vieramatic

Homebridge plugin for Panasonic™ Viera™ TVs (includes support for 2018 and later models)
Apache License 2.0
43 stars 9 forks source link

TV not appearing in Home app #67

Closed anoldgreydog closed 3 years ago

anoldgreydog commented 3 years ago

Describe your issue I have installed the plugin and gone through the setup process, apparently successfully. It made the connection and got the two codes. However, it's not appearing under the Accessories tab or in the Home app. Looks like the plugin is hitting an unhandled exception:

  (node:2602) UnhandledPromiseRejectionWarning: Error: Cannot add a Service with the same UUID 
  '000000D9-0000-1000-8000-0026BB765291' and subtype '3' as another Service in this Accessory.

There is a duplicate hdmi entry in the vieramatic.json that looks to be related:

  "hdmi":[{"id":"1","name":"Cable"},{"id":"2","name":"Fire-TV"},{"id":"3","name":"Blu-Ray"},{"id":"3","name":"Blu-ray"}],

it only appears once in the config.json, though.

Issue Context Please add the following items, when applicable:

  1. the homebridge logs, up from starting until the bug popped up there.

    
    [18/02/2021, 09:45:41] [Homebridge UI] Homebridge restart request received
    [18/02/2021, 09:45:41] [Homebridge UI] UI / Bridge settings have not changed; only restarting Homebridge process
    [18/02/2021, 09:45:41] [Homebridge UI] Sending SIGTERM to Homebridge
    [18/02/2021, 09:45:41] Got SIGTERM, shutting down Homebridge...
    [18/02/2021, 09:45:46] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
    [18/02/2021, 09:45:51] [HB Supervisor] Restarting Homebridge...
    [18/02/2021, 09:45:51] [HB Supervisor] Starting Homebridge with extra flags: -I
    [18/02/2021, 09:45:51] [HB Supervisor] Started Homebridge v1.1.7 with PID: 2602
    [18/02/2021, 09:45:53] Loaded config.json with 0 accessories and 4 platforms.
    [18/02/2021, 09:45:53] ---
    [18/02/2021, 09:45:54] Loaded plugin: homebridge-config-ui-x@4.39.0
    [18/02/2021, 09:45:54] Registering platform 'homebridge-config-ui-x.config'
    [18/02/2021, 09:45:54] ---
    [18/02/2021, 09:45:55] Loaded plugin: homebridge-smartthings@2.3.8
    [18/02/2021, 09:45:55] Registering platform 'homebridge-smartthings.SmartThings-v2'
    [18/02/2021, 09:45:55] ---
    [18/02/2021, 09:45:55] Loaded plugin: homebridge-vieramatic@2.0.24
    [18/02/2021, 09:45:55] Registering platform 'homebridge-vieramatic.PanasonicVieraTV'
    [18/02/2021, 09:45:55] ---
    [18/02/2021, 09:45:56] Loaded plugin: @milo526/homebridge-tuya-web@1.0.0
    [18/02/2021, 09:45:56] Registering platform '@milo526/homebridge-tuya-web.TuyaWebPlatform'
    [18/02/2021, 09:45:56] ---
    [18/02/2021, 09:45:56] Loading 4 platforms...
    [18/02/2021, 09:45:56] [Config] Initializing config platform...
    [18/02/2021, 09:45:56] [Config] Running in Service Mode
    [18/02/2021, 09:45:56] [TuyaWebPlatform] Initializing TuyaWebPlatform platform...
    [18/02/2021, 09:45:56] [SmartThings-v2] Initializing SmartThings-v2 platform...
    INFO: Homebridge Version: 2.6
    INFO: SmartThings-v2 Plugin Version: 2.3.8
    INFO: Checking Package Version for Updates...
    [18/02/2021, 09:45:56] [PanasonicVieraTV] Initializing PanasonicVieraTV platform...
    [18/02/2021, 09:45:56] [TuyaWebPlatform] Loading accessory from cache: Socket 2
    [18/02/2021, 09:45:56] [TuyaWebPlatform] Loading accessory from cache: Socket 1
    [18/02/2021, 09:45:56] [TuyaWebPlatform] Loading accessory from cache: Spotlights
    [18/02/2021, 09:45:56] [TuyaWebPlatform] Loading accessory from cache: Worktop
    [18/02/2021, 09:45:56] [TuyaWebPlatform] Loading accessory from cache: Utility
    INFO: Fetching SmartThings-v2 Devices. NOTICE: This may take a moment if you have a large number of device data is being loaded!
    GOOD: Refreshing All Device Data | Source: (First Launch)
    [18/02/2021, 09:45:56] [PanasonicVieraTV] launching encryption helper endpoint on :8973
    [18/02/2021, 09:45:56] [PanasonicVieraTV] handling '192.168.0.50' from config.json
    Setup Payload:
    X-HM://0024MIGCKEIG1
    Enter this code with your HomeKit app on your iOS device to pair with Homebridge:
    
    ┌────────────┐     
    │ 698-39-172 │     
    └────────────┘     

[18/02/2021, 09:45:57] Homebridge is running on port 51825. [18/02/2021, 09:45:57] [PanasonicVieraTV] found a 'Panasonic VIErA' TV (TX-49FX700B) at '192.168.0.50' (requires crypto for comunication).

(node:2602) UnhandledPromiseRejectionWarning: Error: Cannot add a Service with the same UUID '000000D9-0000-1000-8000-0026BB765291' and subtype '3' as another Service in this Accessory. at Accessory._this.addService (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:281:17) at PlatformAccessory.addService (/usr/local/lib/node_modules/homebridge/src/platformAccessory.ts:92:41) at VieramaticPlatformAccessory.configureInputSource (/usr/local/lib/node_modules/homebridge-vieramatic/src/accessory.ts:386:35) at /usr/local/lib/node_modules/homebridge-vieramatic/src/accessory.ts:315:12 at Proxy.forEach () at new VieramaticPlatformAccessory (/usr/local/lib/node_modules/homebridge-vieramatic/src/accessory.ts:313:35) at VieramaticPlatform.deviceSetup (/usr/local/lib/node_modules/homebridge-vieramatic/src/platform.ts:217:14) at processTicksAndRejections (internal/process/task_queues.js:93:5) at /usr/local/lib/node_modules/homebridge-vieramatic/src/platform.ts:63:23 (Use node --trace-warnings ... to show where the warning was created) (node:2602) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:2602) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. NOTICE: Temperature Unit is Now: (C) NOTICE: Updating Global Values | HubIP: 192.168.0.64 | UseLocal: false WARN: Devices to Remove: (0) [] INFO: Devices to Update: (9) GOOD: Devices to Create: (0) [] ALERT: Total Initialization Time: (1 seconds) NOTICE: Unknown Capabilities: [] INFO: SmartThings DeviceCache Size: (9) INFO: WebServer Initiated... INFO: Sending StartDirect Request to SmartThings | SendToLocalHub: (false) INFO: Direct Connect Active | Listening at 192.168.0.83:8000 INFO: SmartThings-v2 Hub Communication Established [18/02/2021, 09:45:58] [TuyaWebPlatform] Missing required id property on device configuration, received: { "device_type": "form" } [18/02/2021, 09:45:58] [TuyaWebPlatform] Existing Accessory found [Name: Socket 2] [Tuya ID: bfc10568288fbaa03cyijx] [HomeBridge ID: 55d9cb9f-054b-4422-8f68-9a078d45904c] [18/02/2021, 09:45:58] [TuyaWebPlatform] [Socket 2] Characteristic.On - {"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]} [18/02/2021, 09:45:58] [TuyaWebPlatform] Existing Accessory found [Name: Socket 1] [Tuya ID: bf0e97b0ddf9684ee2kfxa] [HomeBridge ID: 15279ff5-8fb6-4218-bd46-c6bd640b64fb] [18/02/2021, 09:45:58] [TuyaWebPlatform] [Socket 1] Characteristic.On - {"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]} [18/02/2021, 09:45:58] [TuyaWebPlatform] Existing Accessory found [Name: Spotlights] [Tuya ID: 715280524c11ae18fabd_1] [HomeBridge ID: 1d718dec-3142-4640-9d64-ae251d5a8f60] [18/02/2021, 09:45:58] [TuyaWebPlatform] [Spotlights] Characteristic.On - {"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]} [18/02/2021, 09:45:58] [TuyaWebPlatform] Existing Accessory found [Name: Worktop] [Tuya ID: 715280524c11ae18fabd_2] [HomeBridge ID: f78d0ac1-8e33-4605-8eb0-e906cb794e00] [18/02/2021, 09:45:58] [TuyaWebPlatform] [Worktop] Characteristic.On - {"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]} [18/02/2021, 09:45:58] [TuyaWebPlatform] Existing Accessory found [Name: Utility] [Tuya ID: 715280524c11ae18fabd_3] [HomeBridge ID: af4ec104-3b13-46df-9e90-1749f72a227a] [18/02/2021, 09:45:58] [TuyaWebPlatform] [Utility] Characteristic.On - {"format":"bool","unit":null,"minValue":null,"maxValue":null,"minStep":null,"perms":["pr","pw","ev"]} INFO: INFO: Your plugin version is up-to-date NOTICE: Sending Plugin Status to SmartThings | UpdateAvailable: false | newVersion: 2.3.8

2. your homebridge's `config.json` contents.
```json
        {
            "tvs": [
                {
                    "ipAddress": "192.168.0.50",
                    "encKey": "e4wqOEL5VTYk4rKZHk9uMg==",
                    "appId": "AYRXWLgn64t/ww==",
                    "hdmiInputs": [
                        {
                            "id": "1",
                            "name": "Cable"
                        },
                        {
                            "id": "2",
                            "name": "Fire-TV"
                        },
                        {
                            "id": "3",
                            "name": "Blu-ray"
                        }
                    ],
                    "disabledAppSupport": false,
                    "customVolumeSlider": false
                }
            ],
            "platform": "PanasonicVieraTV"
        }
  1. the contents of accessories/vieramatic.json (path is relative to homebridge's datadir)

    {"4D454930-0200-1000-8001-80C75554415D":{"data":{"inputs":{"applications":{"0":{"id":"0010000200000001","name":"Netflix"},"1":{"id":"0010000100180001","name":"Amazon Prime Video"},"2":{"id":"0070000200180001","name":"YouTube"},"3":{"id":"0387878700000102","name":"Apps Market"},"4":{"id":"0387878700000145","name":"Freeview Play"},"5":{"id":"0020002400180001","name":"Cinema"},"6":{"id":"0387878700000016","name":"VIERA Link"},"7":{"id":"0077777700160002","name":"Browser"},"8":{"id":"0020004700000001","name":"CHILI"},"9":{"id":"0020000600000001","name":"ARTE"},"10":{"id":"0020007100000001","name":"Meteonews TV"},"11":{"id":"0070000C00000001","name":"AccuWeather.com"},"12":{"id":"0076002307170001","name":"Digital Concert Hall"},"13":{"id":"0387878700000141","name":"Audio Link"},"14":{"id":"0387878700000013","name":"Recorded TV"},"15":{"id":"0387878700000140","name":"Notification Center"},"16":{"id":"0387878700150020","name":"Calendar"},"17":{"id":"0387878700000146","name":"Smart Speaker Settings"},"18":{"id":"0020013200000001","name":"BritBox UK"},"19":{"id":"0310006000000001","name":"XUMO: FREE Movies&TV"}},"hdmi":[{"id":"1","name":"Cable"},{"id":"2","name":"Fire-TV"},{"id":"3","name":"Blu-Ray"},{"id":"3","name":"Blu-ray"}],"TUNER":{"hidden":0}},"ipAddress":"192.168.0.50","specs":{"friendlyName":"Viera","manufacturer":"Panasonic","modelName":"Panasonic VIErA","modelNumber":"TX-49FX700B","requiresEncryption":true,"serialNumber":"4D454930-0200-1000-8001-80C75554415D"}}}}
  2. Details about your specific homebridge setup

    • hardware and arch => Raspberry Pi 3b
    • Operating System and its version => Raspbian GNU/Linux Buster (10)
    • NodeJS version => 14.15.4
    • Homebridge version => 1.1.7
    • specific vieramatic version being used => 2.0.24
    • Viera TV(s) model(s) being used (and connectivity type being used wired/wireless) => TX-49FX700B => Wireless
  3. anything else you may find relevant

anoldgreydog commented 3 years ago

Update

I manually edited vieramatic.json to remove the duplicate entry and it now appears on the "accessories" tab but hasn't appeared in the Home app (it's been about 5 minutes).

It looks like there may be some cleanup missing on uninstall. It's possible that I added hdmi 3 twice the first time I tried the plugin, but I went through a full uninstall (including config) and reinstall, so I know I didn't add it twice the second time.

AntonioMeireles commented 3 years ago

yup, the issue is that you duplicated the hdmi port id which has to be unique. i'll add a check to block that in my side soon. for now removing the hb bridge from the home.app, removing the accessories/vieramatic.json file, restarting homebridge (now with a fixed config without duplicated hdmi port ids) and re adding the hb bridge again to home.app again should be enough. Please do note that you ned to add both the bridge and TV itself to home.app.

hope this helps, if not just bug me :-)

thanks for your patience!

AntonioMeireles commented 3 years ago

@anoldgreydog

fwiw homebridge-vieramatic@2.0.25 that just got published has a fix that now avoids an hard crash when duplicated entries are found (just ignores them) while having error messages a bit more helpful to the end user.

anoldgreydog commented 3 years ago

Thanks for the help. The Home app is asking me for an 8 digit code to add the TV, but I can't find anything resembling that. Am I being dense or is there something else I need to do?

AntonioMeireles commented 3 years ago

that's the 'pin' defined in your homebridge.conf. or if not there in the homebridge boot logs ... search on them for something along ...

Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐
    │ 012-34-567 │
    └────────────┘

Starting to advertise 'homebridgeMobile 7732' using bonjour-hap backend!

hope this helps

anoldgreydog commented 3 years ago

Ah right, thanks. I hadn't connected the two.

anoldgreydog commented 3 years ago

Hi Antonio. Thanks for all the help; I finally got it connected, but I don't think it's going to be right for me.

I prefer to have my TV switched off at the socket, rather than leave it on standby (partly because I have a LED strip powered from the USB socket, and that stays on when the TV is on standby, partly because I don't like leaving things on standby if it's not necessary). If I cut the power, then the plugin stops working the next time the TV is switched on. I get errors like this:

[18/02/2021, 13:44:24] [PanasonicVieraTV] setInput 2 Error: Request failed with status code 500
at createError (/usr/local/lib/node_modules/homebridge-vieramatic/node_modules/axios/lib/core/createError.js:16:15)
at settle (/usr/local/lib/node_modules/homebridge-vieramatic/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-vieramatic/node_modules/axios/lib/adapters/http.js:260:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
config: {
url: 'http://192.168.0.50:55000/nrc/control_0',
method: 'post',

Even if I just turn it off at the back of the set, it fails when I switch back on.

It's annoying because it works really nicely when it's connected, but I don't want to have to restart the Homebridge server every time I turn the TV on.

Thanks again for the assistance in getting it going.

AntonioMeireles commented 3 years ago

@anoldgreydog

can you paste the full error log from where the snippet above come from ? the plugin should afaict recover gracefully from the TV being powered down.

Thanks!

anoldgreydog commented 3 years ago

@AntonioMeireles OK, thanks for getting back to me. Here's the log from when I restarted the server. I've removed some activity from TuyaWeb and SmartThings plugins, but it's otherwise complete.

I hope we can get this working fully - it has so much more capability than the official Panasonic Alexa skill (which is pretty useless, TBH). Plus I can use Shortcuts to do cool things...

homebridge.log.txt

AntonioMeireles commented 3 years ago

Ok. many thanks!. digging. will get back to you soon.

anoldgreydog commented 3 years ago

@AntonioMeireles If it's any help, I tried to be a bit more scientific about it.

  1. TV on
  2. restart Homebridge
  3. check that the plugin changes inputs from the Home app (it does)
  4. TV off, wait for tile to update in Home (shows TV off).
  5. TV back on, wait a couple of minutes for tile to update (shows TV on and the correct input)
  6. try changing inputs - fails.
  7. I've included the complete log from restarting, including Tuya and Smartthings (I didn't want to accidentally delete something important). Hope this helps

homebridge.log.txt

AntonioMeireles commented 3 years ago

Great job - huge THANKS!.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <s:Body>
        <s:Fault>
            <faultcode>s:Client</faultcode>
            <faultstring>UPnPError</faultstring>
            <detail>
                <UPnPError xmlns="urn:schemas-upnp-org:control-1-0">
                  <errorCode>612</errorCode>
                  <errorDescription>No such session</errorDescription>
                  </UPnPError>
             </detail>
      </s:Fault> 
     </s:Body>
</s:Envelope>

seems to be the culprit, as the TV gets OFF and then ON its' own session counters get reset on TVs side which messes with the plugin's ones. Need to spot a way to handle this smoothly. expect a test version soon with a tentative fix or workaround. Will be only after i release a version with full support for homebridge@1.3.0 which should be out very, very, soonish, probably later today.

Thanks again for your patience!

anoldgreydog commented 3 years ago

Good to know you've found a possible culprit. Take your time; I've lived without it for years, a few days isn't going to be a problem. Also, I was a software guy for 30 years, I know exactly what it's like trying to track down bugs.

AntonioMeireles commented 3 years ago

Hi @anoldgreydog,

i've just published homebridge-vieramatic@3.0.7-beta.1 which should have finally this fixed, while also not inducing any undesired side effects. Could you please give it a try and feedback ? [installation should be along sudo npm i -g homebridge-vieramatic@3.0.7-beta.1 albeit that's not a given and is your local setup dependant]

Thanks again for your patience and have a great weekend!

António

anoldgreydog commented 3 years ago

Thanks @AntonioMeireles. I will give it a go, but it may have to wait until tomorrow. I'll get back to you as soon as I've tried it out.

anoldgreydog commented 3 years ago

@AntonioMeireles It looks good. I've tried it by switching the TV off at the socket and then back on again, and it all looks to work properly. There's a message:

[28/02/2021, 10:29:53] [PanasonicVieraTV] A session mismatch was found, so the session counter was reset in order to move on.

which I assume is your fix.

I do still have an issue that, if I try to control it via Shortcuts, it will do everything except set the input back to HDMI 1. Probably a problem with shortcuts (HDMI1 is the first entry in the selector list, so maybe it's treating it differently) - I only raise it in case you've seen something similar and know a work-around. It's not a problem with the plugin, since it works fine if I make the selection from the Home app. I just wanted a Shortcut because it's a, you know, shortcut. 😎


I'm also seeing

[28/02/2021, 10:30:54] [homebridge-vieramatic] This plugin slows down Homebridge. The read handler for the characteristic 'Active' on the accessory 'Viera B455' was slow to respond! See https://git.io/JtMGR for more info.

Should I configure the plugin as an isolated bridge? It suggests that running it as an such can improve responsiveness and reliability.

--

Then I got another one (in red!) which said

 [28/02/2021, 10:41:56] [homebridge-vieramatic] This plugin slows down Homebridge. The read handler for the characteristic 'Active' on the accessory 'Viera B455' didn't respond at all!. Please check that you properly call the callback! See https://git.io/JtMGR for more info.

I suppose this could be related to switching it off and on at the wall socket - I got a 'not responding' warning inside the Home app. Probably an unfortunate timing thing, as I just tried it again, and it came up fine and updated itself nicely. Still, it's there if you want to have a look - it doesn't seem to do any lasting damage.

AntonioMeireles commented 3 years ago

@anoldgreydog

thanks for your quick feedback. some comments bellow:

All the best, and a great weekend!

P.S. FWIW unless critical issues arise i expect to get this out of beta later today or mid tomorrow for wider consumption.

anoldgreydog commented 3 years ago

@AntonioMeireles

Thanks for everything you've done, it's been great working with someone so responsive.

The issue with switching inputs is a Shortcuts problem, I'm pretty sure. I'm just asking it to switch to an input, so the one it's currently on is irrelevant. Also, it works fine if I do it directly in the Home app - long-press the tile, select the input and it sets it with no problem. If I set any other input by sending the request to the Home app from a shortcut, that works fine. It's only when I try to set HDMI1 by sending a request from Shortcuts that it fails. Even then, it's only an issue because that's the only input that doesn't get automatically selected by the device that's connected to it and it's a pain having to dig out the remote just to do that one specific job. I can live with doing via Home, rather than the shortcut.

Thanks again for all your help.

AntonioMeireles commented 3 years ago

@anoldgreydog

thanks for your update. regarding the original issue OK to close ? or you feel that's still room for improvements ?

thanks again for your patience!

anoldgreydog commented 3 years ago

@AntonioMeireles

It's fine as far as I'm concerned. I did a bit more poking and managed to fix the other problem. It now sets HDMI1 from a shortcut correctly. I don't what fixed it, but everything is now working as I expect, so feel free to close and many thanks for your efforts.

AntonioMeireles commented 3 years ago

@anoldgreydog

thanks me too

All the best,