tavicu / homebridge-samsung-tizen

Homebridge plugin for Samsung TV's with Tizen OS
MIT License
646 stars 88 forks source link

ios 12.2 #50

Closed ageorgios closed 5 years ago

ageorgios commented 5 years ago

Will you make it use the new TV accessory? https://www.macrumors.com/2019/01/24/apple-seeds-ios-12-2-beta-1-to-developers/

noltondyer commented 5 years ago

If you're on a Mac the file is located at /usr/local/lib/node_modules/homebridge_samsung_tizen/lib

Edit SamsungAccessory.js Line number 27, change "switch" to "television" Line number 28, change "On" to "Active"

That's as far as I've gotten. It does allow on and off control.

I can't get past this issue:

Initializing SamsungTizen platform... /usr/local/lib/node_modules/homebridge-samsung-tizen/lib/SamsungAccessory.js:27 this.service = new this.hap.Service.Television(this.name); ^

TypeError: this.hap.Service.Television is not a constructor at new SamsungAccessory (/usr/local/lib/node_modules/homebridge-samsung-tizen/lib/SamsungAccessory.js:27:31) at SamsungDevice.initAccessories (/usr/local/lib/node_modules/homebridge-samsung-tizen/lib/SamsungDevice.js:134:31) at new SamsungDevice (/usr/local/lib/node_modules/homebridge-samsung-tizen/lib/SamsungDevice.js:35:14) at SamsungPlatform.accessories (/usr/local/lib/node_modules/homebridge-samsung-tizen/lib/SamsungPlatform.js:36:22) at Server._loadPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:386:20) at Server._loadPlatforms (/usr/local/lib/node_modules/homebridge/lib/server.js:330:16) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:86:36) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:45:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:653:30)

kdschlosser commented 5 years ago

I have a question for ya.. would it make it easier if I compiled samsungctl into an executable and provided a REST API to interface with the TV's?? the executable could be run as a daemon. It could be made to be secure by exposing the REST API only to the loopback adapter. so it can only be accessed from a program running on the same box. It would be pretty easy for me to put together something like that.

tavicu commented 5 years ago

@noltondyer update homebridge to latest version

@kdschlosser hei. as i said before, samsungctl uses the same method for the api. The only difference is that i use secure websocket which require pairing. But in the new version i will give the possibility to disable the secure method for TV's that where not updated to the latest version.

kdschlosser commented 5 years ago

my fork of samsungctl has been upgraded a lot. it supports TVs from 2008 to current.. SSL websocket 2016+ with updated firmware non SSL websocket 2016+ without updated firmware encrypted websocket (H-2014 and J-2015) and legacy 2008 - 2013

automatic discovery of what connection method to use. automatic discovery of the mac address (power on for 2014+ TV's) UPNP support for all years and models. there is also a full tilt discovery process that will locate all TV's on the network without the need to enter an IP.

there are features like direct volume input, TV channel changing. right down to changing the OSD label for a source input. because of the large number of models and years support for different things may or may not be available. so I added a helper that can output json data of what is supported and what parameters are needed. the data types. min and max values.. choices for a parameter.. return values... this is a nice thing to have to be able to dynamically set a GUI control interface.. it will only contain the control elements that the TV supports,

it is pretty extensive. you should at the very least take a look at the code. it will help quite a bit.

JonoHaysom commented 5 years ago

I had some time today to play with the new Service.

@NielsLeenheer i tried your branch but i didn't manage to get the speaker volume and remote inputs to work. Did you manage to make them work? :)

@tavicu Will you be likely to push an update today? can't wait to try the features above and beyond the Tv icon and power controls.

tavicu commented 5 years ago

@tavicu Will you be likely to push an update today? can't wait to try the features above and beyond the Tv icon and power controls.

Nope since i want to rewrite the plugin almost from scratch. Probably the next week will be on a branch but in master will be released only when iOS 12.2 will go live.

Unfortunately from what i've seen until now the only feature that will be new is the input selector (and the icon of accessory).

NielsLeenheer commented 5 years ago

@NielsLeenheer i tried your branch but i didn't manage to get the speaker volume and remote inputs to work. Did you manage to make them work? :)

The speaker volume is hidden in the "Apple TV" widget in the control center. There is no visible on-screen cue, but if you use the volume buttons on the side of the phone, it will change the volume of the television.

About the input selector: when configured in the homebridge config file, it should populate a list that pops up when you press the "Input" button if you open the television tile in the Home app. I've had some issues that some of the inputs become tiles themselves, but that was fixed when I changed the order in which the services where registered by homebridge.

For me personally, I really like the widget in the control center and the ability to switch between controlling my AppleTV and the television itself. I see myself using that quite a lot. Volume control too.

The input switching is not convenient enough for me, because at this time it is hidden away in the home app. Which I use a lot, but having to switch back and forth is just a pain. But still, some people might find it useful.

JonoHaysom commented 5 years ago

@NielsLeenheer i tried your branch but i didn't manage to get the speaker volume and remote inputs to work. Did you manage to make them work? :)

how do I install your fork @NielsLeenheer ?

NielsLeenheer commented 5 years ago

I just copied over the SamsungAccessory.js file from the PR. That means when the official plugin is updated, my changes will be overwritten again. Also update homebridge to the latest version.

What in theory would work also is to remove the official homebridge-samsung-tizen npm package and reinstall like this: npm install -g NielsLeenheer/homebridge-samsung-tizen#television

But again, this is unsupported. Only a hacked together version that will be removed once the official plugin has iOS 12.2 support. Unless you really, really want to try it out, I suggest to wait until there is an update from the official plugin.

JonoHaysom commented 5 years ago

I just copied over the SamsungAccessory.js file from the PR. That means when the official plugin is updated, my changes will be overwritten again. Also update homebridge to the latest version.

Thanks, have now updated it and confirm volume etc is working :)

greensouth commented 5 years ago

Errr... maybe I'm a bit dumb, but can't make the source list appear in Home APP. It's empty, and I'm using your configuration for sources @NielsLeenheer

JonoHaysom commented 5 years ago

me either @greensouth. I've popped in the same config as above in @NielsLeenheer example but it doesn't show in the app. have restarted the home bridge instance too.

niklaswa commented 5 years ago

@greensouth @JonoHaysom Had this issue too. After removing the bridge from HomeKit, closing the app, rebooting the Apple TV and repairing it again, it worked. (I think not all steps are necessary)

greensouth commented 5 years ago

I just copied over the SamsungAccessory.js file from the PR. That means when the official plugin is updated, my changes will be overwritten again. Also update homebridge to the latest version.

Thanks, have now updated it and confirm volume etc is working :)

How did you make the volume thing?

JonoHaysom commented 5 years ago

This is my configuration for the sources:


{
    "platform": "SamsungTizen",
    "refresh": true,
    "devices": [{
        "name": "Television",
        "ip": "192.168.x.x",
        "mac": "XX:XX:XX:XX:XX:XX",
        "token": "12345678",
        "sources": [
                { "name": "YouTube", "app": "111299001912" },
                { "name": "Netflix", "app": "11101200001" },
                { "name": "Prime Video", "app": "3201512006785" },

@NielsLeenheer are you sure you're using sources? when I change "sources" to "switches" it works as button in the home app but still won't populate the pop up menu selector in the mobile "home app" TV screen. did you change this in the Fork and didn't update the tips above?

lastly, is there a way to change to HDMI 1,2 etc?

niklaswa commented 5 years ago

@JonoHaysom Try using

                { "name": "YouTube", "app": "111299001912" },
                { "name": "Netflix", "app": "11101200001" },
                { "name": "HDMI", "command": [ "KEY_HDMI" ] },
                { "name": "HDMI 1", "command": [ "KEY_HDMI1" ] },
                { "name": "HDMI 2", "command": [ "KEY_HDMI2"] }

and see, if it works for you. (on my K-Series it doesn't work..)

kdschlosser commented 5 years ago

I figured I would let ya'll know that I added getting the state of the "Art mode" for Frame TV's as well as turning it on and off.

command to set the state

{
    "method":"ms.channel.emit",
    "params":{
        "clientIp":"192.168.1.20",
        "data":"{
            \"id\":\"545fc0c1-bd9b-48f5-8444-02f9c519aaec\",
            \"value\":\"on\",
            \"request\":\"set_artmode_status\"
        }",
        "deviceName":"W1Bob25lXWlQaG9uZQ==",
        "event":"art_app_request",
        "to":"host"
    }
}

command to get the state

{
    "method":"",
    "params":{
        "clientIp":"192.168.1.20",
        "data":"{
            \"request\":\"get_artmode_status\",
            \"id\":\"30852acd-1b7d-4496-8bef-53e1178fa839\"
        }",
        "deviceName":"W1Bob25lXWlQaG9uZQ==",
        "event":"art_app_request",
        "to":"host"
    }
}

and the response for getting the state

{
    "method":"ms.channel.emit",
    "params":{
        "clientIp":"127.0.0.1",
        "data":"{
            \"id\":\"259320d8-f368-48a4-bf03-789f24a22c0f\",
            \"event\":\"artmode_status\",
            \"value\":\"off\",
            \"target_client_id\":\"84b12082-5f28-461e-8e81-b98ad1c1ffa\"
        }",
        "deviceName":"Smart Device",
        "event":"d2d_service_message",
        "to":"84b12082-5f28-461e-8e81-b98ad1c1ffa"
    }
}
JDogg016 commented 5 years ago

Is anyone going to merge this into a final version?

JonoHaysom commented 5 years ago

I think @tavicu is working on it @JDogg016. he is completely rewriting it.

tavicu commented 5 years ago

Next week i will publish the branch and ask for help to test it :)

Dean151 commented 5 years ago

Already have a setup to test that, using #54 poc. (although my tv UE49KU6510 doesn't send back a token, it's working okay!) I'm thrilled about testing your version as soon it gets released ;)

tavicu commented 5 years ago

I will try to release the branch this weekend. I had some problems with my router (too many connections) and had to replace it. i lost two days because of this trying to figure out why the WoL didn't work :))

JonoHaysom commented 5 years ago

can't wait!

wroblewski6 commented 5 years ago

i am waiting also for testing

tavicu commented 5 years ago

Hei! Is anyone having problem with wake on lan over WiFi? I'm on version 1262 and it stopped working. The TV is turning on over WiFi only the first time after a hard reset, then nothing.

It's working ok over wired cable.

jalexc commented 5 years ago

Hei! Is anyone having problem with wake on lan over WiFi? I'm on version 1262 and it stopped working. The TV is turning on over WiFi only the first time after a hard reset, then nothing.

It's working ok over wired cable.

It’s working fine here on version 1262 over Wi-Fi.

JonoHaysom commented 5 years ago

Hei! Is anyone having problem with wake on lan over WiFi? I'm on version 1262 and it stopped working. The TV is turning on over WiFi only the first time after a hard reset, then nothing.

It's working ok over wired cable.

working find here.

tavicu commented 5 years ago

Hey,

After hard working i have an early version of the plugin :) You can find it on this branch: https://github.com/tavicu/homebridge-samsung-tizen/tree/homekit-television

And here is an example of config:

{
    "platform": "SamsungTizen",
    "inputs": [
        {"name": "Netflix",  "type": "app",     "value": "11101200001"},
        {"name": "Xbox One", "type": "command", "value": "KEY_VOLUP"}
    ],            
    "devices": [
        {
            "name": "Bedroom TV",
            "ip": "10.20.30.40",
            "mac": "A0:B1:C2:D3:E4:F5",
            "switches": [
                {"name": "Mute", "mute": true}
            ]
        }
    ]
}

Everything you set on the root config it will also propagate to devices. If you want per device:

{
    "platform": "SamsungTizen",         
    "devices": [
        {
            "name": "Bedroom TV",
            "ip": "10.20.30.40",
            "mac": "A0:B1:C2:D3:E4:F5",
            "switches": [
                {"name": "Mute", "mute": true}
            ],
            "inputs": [
                {"name": "Netflix",  "type": "app",     "value": "11101200001"},
                {"name": "Xbox One", "type": "command", "value": "KEY_VOLUP"}
            ]      
        }
    ]
}
tavicu commented 5 years ago

There are some console.logs in files, if it bothers you can remove them :)

I'm still working to implement logging and debugging. But at is it right now it should work like the v2.

If you find any problem please post it in the PR https://github.com/tavicu/homebridge-samsung-tizen/pull/67, not on this topic.

I will not offer support for things like: how do i install it, i didn't update homebridge and it's crashing, i can't follow an example of config and it's crashing, and things like this :)

So please only post in PR if you found a bug! Otherwise i will remove the comment

Some new things.

Also remove the token from configuration. It will ask you to pair again the tv (so it must be on when you start homebridge) and once you click allow it will store the token on the server. No need to add it in config.

wroblewski6 commented 5 years ago

So I have to install again your plugin or install different plugin or only change the config file settings ??

Sorry I did not notice that you do not accept question about Instalation

tavicu commented 5 years ago

So I have to install again your plugin or install different plugin or only change the config file settings ??

npm install -g --unsafe-perm git://github.com/tavicu/homebridge-samsung-tizen.git#homekit-television

This should work. I cannot guarantee. (http://lmgtfy.com/?q=npm+install+from+branch)

niklaswa commented 5 years ago

@wroblewski6 You've to stop Homebridge and uninstall the previous version of the plugin with something like npm remove -g homebridge-samsung-tizen.

And installing the other branch works like this: npm -g --unsafe-perm install git+https://github.com/tavicu/homebridge-samsung-tizen#homekit-television

Then you have to change the config to the new structure mentioned above and you can start Homebridge again.

Edit: @tavicu Ah, you were faster 😄

tavicu commented 5 years ago

@wroblewski6 You've to stop Homebridge and uninstall the previous version of the plugin with something like npm remove -g homebridge-samsung-tizen.

Don't think you need to uninstall first :) npm will do everything.

And i will say only one time for people that don't know, you need to be on the latest version of homebridge and phone must be on iOS >= 12.2 (right now is in beta)

tavicu commented 5 years ago

make sure to update node to a newer version. minimum version is v10.0.0

If you are getting an error like this: .then(...).catch(...).finally is not a function it's because you have an older version

jeremybdk commented 5 years ago

Thanks working better with node v10.x :) It seems that the new Apple Tv Remote on iOS 12.2 Beta 3 also supports TVs. If you have the remote configured you can either control the Apple TV or the TV over homebridge/homekit. If wonder if it's possible to map the buttons of the new Apple Remote with the TV.

cdtlt4r

The dropdown on the top will let you access the remote for the TV. I should have taken this screenshot using wifi before leaving home :(

I'll update it tonight, but the remote can work on TVs :)

tavicu commented 5 years ago

It's already implemented and working but i didn't test it from the app. Only from the control center https://www.payetteforward.com/wp-content/uploads/2017/06/how-to-add-apple-tv-remote-to-control-center-iphone-1235x1080.jpg

I think it should work from the App Too. Don't know if Apple implemented two methods. i will take a look :)

wroblewski6 commented 5 years ago

After update to new node I can turn on off my TV I cen choose input HDMI1 ,2,3, or next HDMI with this commends ('HDMI', 'KEY_HDMI'), ('HDMI 1', 'KEY_HDMI1'), ('HDMI 2', 'KEY_HDMI2'), ('HDMI 3', 'KEY_HDMI3'), ('HDMI 4', 'KEY_HDMI4'), But I am not sure if this my configuration error but I can not see samsung remote in remote app like on this photo
img_2364

Here is my config

{ "platform": "SamsungTizen", "devices": [ { "name": "Bedroom TV", "ip": "192.168.1.102", "mac": "cc:6e:a4:bd:e3:7d", "switches": [ {"name": "Mute", "mute": true} ], "inputs": [ {"name": "Netflix", "type": "app", "value": "11101200001"}, {"name": "VU+", "type": "command", "value": "KEY_HDMI1"}, {"name": "AppleTV", "type": "command", "value": "KEY_HDMI2"}, {"name": "HDMI", "type": "command", "value": "KEY_HDMI"}, {"name": "Spotify", "type": "app", "value": "KEY_HDMI"} ] } ] }

tavicu commented 5 years ago

Try to remove cached accessories with this command: rm -rf ~/.homebridge/accessories/cachedAccessories

Also try a restart of your iOS device. There is no setting for this and it should work "out of the box" :)

jeremybdk commented 5 years ago

You should try to update your iOS device. It seems that it’s not the latest beta (Beta 3).

wroblewski6 commented 5 years ago

is seems that deleting my harmony hub settings from config helped and now I can see my samsung tv remote in apple remote app :D

wroblewski6 commented 5 years ago

Did I research correctly , there is no option to select HDMI 1,2,3,4 only change to next HDMI ??

tavicu commented 5 years ago

Yeah, unfortunately the great big company Samsung didn't give us the possibility to select a HDMI port ...

You must do a hack like in the previous messages.

{ "name": "Apple TV", "command": [ "KEY_SOURCE", "KEY_LEFT", "KEY_LEFT", "KEY_LEFT", "KEY_RIGHT", "KEY_RIGHT", "KEY_RIGHT", "KEY_ENTER" ] }

wroblewski6 commented 5 years ago

So I have to check this option . Is there option to make long press of some button, on my STB I need to long press to get back button to work ?? or is it possible to customize those 4 buttons in apple remote app of my TV ?? And one more question is it normal that when I use remote on apple remote app to control my samsung TV it is working but lag is apron 3 seconds when using my HDMI connected device with Samsung Smart remote ??

tavicu commented 5 years ago

Lag is because of your network. It may be a large lag especially if you are not on the same WiFi and you are making requests from remote (outside of network, cellular network).

There is not an option for long press, i want to implement it in the future.

What 4 buttons you are telling? You lost me here :D

tavicu commented 5 years ago

I have found out how KEY_HDMI works. If you press one time it will switch to first hdmi, pressing again will switch to hdmi 2 and so on.

The problem is that it will switch to HDMI that is active. So if your console is off it will not see the HDMI as available and will not power on the console.

So right now the best option is by sending a list of commands with the source like in the previous comment.

wroblewski6 commented 5 years ago

i have on lag if I use app like Netflix and use samsung menu but when I use my HDMI devices Apple TV/ VU+ stb which are controlled by Samsung Smart remote I have 3 seconds lag,

Long press would be great so nice that you are planing to implement.

I was talking about those 4 buttons

img_2364

tavicu commented 5 years ago

On the latest beta remote looks like this (https://imgur.com/a/iLnmstZ) and all available keys are set. Will see in a future beta if apple will allow us to use more options. Like numeric pad :)

tavicu commented 5 years ago

P.S. @NielsLeenheer you can also use command repeater. { "name": "Apple TV", "command": [ "KEY_SOURCE", "KEY_LEFT*3", "KEY_RIGHT*3", "KEY_ENTER" ] }

wroblewski6 commented 5 years ago

after update I have the same like yours ,

All im all homekit tv remote seems to be very useful and it would be great improvement for my Homekit setup so thanks to you. I would like to remind that new samsung tv will have airplay 2 support but Homekit will not be available on samsung so your plugin will fill this gap for longer time.

tavicu commented 5 years ago

Yeah, i have read that only 2019 and some 2018 TV's will get update for airplay 2. Will see when Samsung decide to show us something :d

I will probably push an update to have only the power switch without integration with remote control.