Closed HVR88 closed 2 years ago
Hi @HVR88, Thank you for providing info. I really appreciate when someone want's to help and try to do things better. I know the SmartThings api will offer us more functionality and less room for errors.
The biggest problem migrating to SmartThings is time. I have a full work job and don't have a lot of free time. And the time i have i want to spent it with my family :)
After i finish the Art Mode support for Frame TVs i will look over the SmartThings API. The problem is that i don't know to say if it will be implemented or how much time it will take.
Thanks!
I hear you. If this was last year, when I had a lot of time, I'd look at this and try to implement it and then issue a pull request. :) Right now I'm also generally working long hours and it's all I can do to spend a little bit of time just setting up Homekit and my devices. :)
Maybe if this issue is here as a reminder/notice, someone else may come along and contribute some changes in the meantime.
I have looked over the SmartThings API and play with it. I don't like it (sometimes it tells me that TV is off and can't send commands when it's on ...) but it will not be hard to implement the functionality to switch to an input.
After i finish with Frame TV implementation i will take a look.
Last night I also played with the https://github.com/jaruba/ha-samsungtv-tizen plugin (based on smartthing api, I believe) integrating HomeAssistant with HomeKit.
I solved the problem of updating the status ON / OFF I changed the update_method (from "ping" to "websocket"). I've seen that switching TV channels and inputs is actually more useful with API.
I guess it will take time, unfortunately I'm not a developer ...
Last night I also played with the https://github.com/jaruba/ha-samsungtv-tizen plugin (based on smartthing api, I believe) integrating HomeAssistant with HomeKit.
I have looked and i don't find their method very good as performance and reliable. They are sending a command to TV and wait for the answer. if the TV will not answer then means the websocket is down and that also means the TV is off.
But sometimes websocket takes longer to respond, if you add a timeout it may give you false results. Ping on the other hand, it responds right away and have nothing to do with the OS of the TV. If websocket was down right away when the TV entered sleep mode, yeah, i would thing it's a viable option. But websocket stay active even in sleep mode, so not much help over here :)
I have 4 Samsung TV and none of them returned an invalid response to ping.
Also ha-samsungtv-tizen "ping" method is not ping ... it's actually sending a http request to /api/v2/
. We do the same, but only if TV responds to ping and we also cache the request for 2 seconds so we don't stress the TV with requests.
Unfortunately what is working for you, it's not for others. And with my plugin i want to cover as much TV's i can and without advanced configs.
You can see why i want to do this by looking at this issue https://github.com/tavicu/homebridge-samsung-tizen/issues/323 where the message tells him to check the Wiki for more details but he opens an issue. I respond him with the link to Wiki where everything is explained in details (is say he's tv is not compatible and that Samsung removed the API) and he ask if it's going to be fixed :|
Well ... please explain to him what method it should choose to check the TV and which is the best :))
Clear as water.
You can see why i want to do this by looking at this issue #323 where the message tells him to check the Wiki for more details but he opens an issue. I respond him with the link to Wiki where everything is explained in details (is say he's tv is not compatible and that Samsung removed the API) and he ask if it's going to be fixed :|
I read #323 this morning 🤦🏻♂️ I thought: "it's hard to maintain a partnership like this community if people don't want to read and just pretend"
I read #323 this morning 🤦🏻♂️ I thought: "it's hard to maintain a partnership like this community if people don't want to read and just pretend"
Yup ... that's why I didn't do much in the last time. Cause all i've seen where issues like that! But some of you started to help me with info and that shows me you guys care. That's why i changed the way apps are opened, started implementing Frame Support and next look over the SmartThing API. Because you guys deserve it by being polite and do more than "i want that", "it's not working" :)
i will always help someone who is polite and do the minimum research before asking for something!
A small update: Today i played with smathings api! It's looking good :)
After i finish with Frame i will implement selecting an input with smartthings. I like that you can select Live TV :)
That's fantastic news. As I mentioned in another thread, today, your plugin is the most stable right now. I've tried a lot of projects that are supposed to communicate with Samsung TVs in the past month (not for Homekit) and all the others are broken in some way or another right now.
Yup ... that's why i started this plugin in the first time :D none of them was good :P
And that's why i don't want to implement things that "may" work ... i only do things that DO work for sure and stable :) The plugin is made for everybody, not just for those who knows how to code something :D
Eh, i will try to get more informations regarding the smarthings api and if any other thing beside selecting an input looks stable and nice to implement it, i will do it :D
Thanks for improving this amazing tool.
Any update on being able to select a Source Input?
Finally figured out how to add the apps as inputs but would love a Live TV & Apple TV box Source Input option.
Happy to beta test things and provide feedback if needed!
Side note: Just found that KEY_TV & KEY_HDMI seem to work well as Command options to switch between Live TV and my HDMI device.
Any idea if it would be possible to turn those options into buttons like the power button?
Hei @town3r , no news yet. I was very busy at my work and didn't had time to breath :D
But I expect things to start to calm down being the holiday period.
So the feature is on my priority list as soon as i will have some days off.
Very excited for this functionality to be added!
+1
Hi. Small update here. I'm very excited for this too :))
I will have some time this month and i will do my best to implement it asap.
Ok, released the first beta :)
I've added the option to set an input/switch to open a source using SmartThings API. Right now the input will not remain active. I still have to make some checks and see if this is possible because the SmartThings api when you are on an app it will return as active source the last input you were on.
For example if you were on HDMI1
and open YouTube
the endpoint will respond with the active source still as HDMI1
:)
Also, make sure you set your IDs ok because the plugin does not return any error now if it's not working. It will just ignore the command.
You will need the API Key for the SmartThings API and Device ID.
How to get the informations.
First make soure your TVs are added in SmartThings App
API Key
Device ID
My Devices
https://[...].api.smartthings.com/device/show/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX
Time to install the beta version:
Install Previous Version
v5.2.0-beta.0 - beta
and click Install
.
Install Previous Version
optionYou can install the plugin with npm install
command like this: npm install homebridge-samsung-tizen@beta
. If you have the plugin installed globally don't forget the -g
attribute. Like this: npm install homebridge-samsung-tizen@beta -g
Time to update the config.
Possible values for now: digitalTv
, USB
, HDMI1
, HDMI2
, HDMI3
, HDMI4
, HDMI5
, HDMI6
Example of config:
{
"platform": "SamsungTizen",
"devices": [
{
"name": "Bedroom TV",
"ip": "10.20.30.40",
"mac": "A0:B1:C2:D3:E4:F5",
"api_key": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
"device_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
"inputs": [
{
"type": "input",
"name": "Live TV",
"value": "digitalTv"
},
{
"type": "input",
"name": "Apple TV",
"value": "HDMI1"
}
],
"switches": [
{
"name": "Switch Live TV",
"input": "digitalTv"
}
]
}
]
}
If you have more devices under the same api_key you could set it as this:
{
"platform": "SamsungTizen",
"api_key": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
"devices": [
{
"name": "Bedroom TV",
"ip": "10.20.30.40",
"mac": "A0:B1:C2:D3:E4:F5",
"device_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
"inputs": [
...
],
"switches": [
...
]
},
{
"name": "Living ROom TV",
"ip": "10.20.30.40",
"mac": "A0:B1:C2:D3:E4:F5",
"device_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
"inputs": [
...
],
"switches": [
...
]
}
]
}
Hi @tavicu,
Tested today but have issues.
I'm running homebridge on a raspberrypi 3, installed v5.2.0-beta.0 from Config Ui X.
My config.json :
{
"platform": "SamsungTizen",
"app_list": true,
"devices": [
{
"name": "TV",
"ip": "10.20.30.40",
"mac": "A0:B1:C2:D3:E4:F5",
"api_key": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
"device_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX",
"keys": {
"ARROW_UP": "KEY_UP",
"ARROW_DOWN": "KEY_DOWN",
"ARROW_LEFT": "KEY_LEFT",
"ARROW_RIGHT": "KEY_RIGHT",
"SELECT": "KEY_ENTER",
"BACK": "KEY_RETURN",
"PLAY_PAUSE": "KEY_PLAY_BACK",
"INFORMATION": "KEY_INFO"
},
"inputs": [
{
"name": "Apple TV 4K",
"type": "input",
"value": "HDMI3"
},
{
"name": "Xbox One X",
"type": "input",
"value": "HDMI4"
},
{
"name": "TNT",
"type": "input",
"value": "digitalTv"
}
]
}
]
}
In Home app, I can't change inputs, it does nothing to the TV. In homebridge logs, I have this error message:
[07/10/2021, 15:45:29] [TV] Cannot read property 'send' of undefined
Note: I'm also running PiHole to block adds, but don't see something blocking related to homebridge/SmartThings API calls in its logs.
Please start in debug mode so we can trace that error! ‘homebridge -D’
sorry for that.
Here logs in debug mode:
[07/10/2021, 16:49:11] [TV] [DEBUG] {
method: 'ms.channel.emit',
params: { data: '', to: 'host', event: 'ed.installedApp.get' }
}
[07/10/2021, 16:49:11] [TV] WebSocket was closed before the connection was established
[07/10/2021, 16:49:11] [TV] [DEBUG] SocketOpenError: WebSocket was closed before the connection was established
at WebSocketSecure._check (/usr/lib/node_modules/homebridge-samsung-tizen/lib/methods/ws.js:109:19)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at WebSocketSecure._send (/usr/lib/node_modules/homebridge-samsung-tizen/lib/methods/ws.js:76:9)
at WebSocketSecure.getApplications (/usr/lib/node_modules/homebridge-samsung-tizen/lib/methods/ws.js:58:9)
On the previous message you showed me another error which indeed breaks the input switch: Cannot read property 'send' of undefined
This one with websocket just tells it cannot get installed applications. Which is not our problem now :)
Set app_list
to false
fixed the websocket exception :)
Changing inputs is working 👍
I have yet to try the beta, but lemme ask a rather ignorant question — will the smartthings api allow for a local control, or will it always rely on internet connection?
I have yet to try the beta, but lemme ask a rather ignorant question — will the smartthings api allow for a local control, or will it always rely on internet connection?
You will need internet cause the requests go to smartthings api, not the tv itself.
beta works very well tnks @tavicu. It's fantastic ... In the future it will be possible to select tv channels with smartthing api?
In the future it will be possible to select tv channels with smartthing api?
I didn't think of that but you can also do it now with a command input like this: Example for channel 21 KEY_2,KEY_1,KEY_ENTER
I didn't think of that but you can also do it now with a command input like this: Example for channel 21
KEY_2,KEY_1,KEY_ENTER
well, not bad ... I did a test setup like below, and it works great.
{
"name": "Canale 5",
"type": "command",
"value": "KEY_5,KEY_0,KEY_5,KEY_ENTER"
},
The only thing is that you can't do this if you are in an app (netflix or others) you should switch to digitalTV first, a shame. but it is already something better. 👍🏼
For some reason, none of the keys are working for me. Maybe I need to enable something for this to work? Everything else, on/off, inputs, etc works great! But left/right or numbers like KEY_1 don't do anything. Anyone else having this issue? Thank you so much for all of your work, it's much appreciated, and now allows me to control the TV through Alexa as well, via HomeBridge Alexa
For some reason, none of the keys are working for me. Maybe I need to enable something for this to work? Everything else, on/off, inputs, etc works great! But left/right or numbers like KEY_1 don't do anything. Anyone else having this issue?
please paste here the inputs part of the config :)
I've added it as a switch, instead of an input. Is this why? I've also done it through the Homebridge UI, instead of manual config, but here's the switches part of the config: "switches": [ { "name": "Comcast", "power": true, "input": "HDMI2" }, { "name": "Apple", "power": true, "input": "HDMI1" }, { "name": "Fox News", "power": true, "input": "HDMI2", "command": [ "KEY_1,KEY_1,KEY_1,KEY_0,KEY_ENTER" ] }
And here's the inputs section:
"inputs": [ { "type": "input", "name": "Comcast", "value": "HDMI2" }, { "type": "input", "name": "Apple TV", "value": "HDMI1" } ],
Hi there — Just a quick note to report that I jumped into the beta release as I wanted to test out using the Samsung SmartThings API to control my TV. I went ahead and installed it today and played around with the settings. A couple of observations to offer so far:
Overall I am very happy with how this works so far. Looking forward to the next release! Thank you for outputting such a stable and useful plug-in. 🙏🏽
Hi @ramm64, thank you for the feedback.
KEY_4, KEY_2, KEY_ENTER
so it should work anywhere regarding on what input/app you are :)As an update of the feature, November it's a very busy period for me so i didn't have time to do anything. I will resume working this month and i hope to release it at the middle of January :)
I also want to update the Wiki before this release so that will take some time
I finally had a chance to test this myself - life gets in the way.
Input switching seems to work very well and quickly, however there's a problem that I can't get around...
Using the device in a Homekit scene. If the scene must turn the TV ON and switch inputs, the input switch doesn't happen.
For example:
Plugin is configured with various inputs, including HDMI1 and HDMI2 I manually set my TV to HDMI1 and then turn it off - works great from the Home app Create a scene and include ONLY the TV - set the scene to put the TV ON and Input to HDMI2 Close/save the scene Trigger the scene - the TV will turn on with HDMI and never switch inputs to HDMI2
Using the device in a Homekit scene. If the scene must turn the TV ON and switch inputs, the input switch doesn't happen.
For example:
Plugin is configured with various inputs, including HDMI1 and HDMI2 I manually set my TV to HDMI1 and then turn it off - works great from the Home app Create a scene and include ONLY the TV - set the scene to put the TV ON and Input to HDMI2 Close/save the scene Trigger the scene - the TV will turn on with HDMI and never switch inputs to HDMI2
Hi. Yup, it's a good scenario. It's not working because the TV will not respond to any request for a few ms after it turned ON and the commands are sent without delay.
I will look into it but don't know if I have a solution for this.
Edit: It may be possible with a custom switch like this:
{"name": "On HDMI1", "power": true, "input": "HDMI1"}
This should first turn on the tv then add a delay of 1 second before running the command to change input.
Update. I have released the second beta (v5.2.0-beta.1) For installing and updating follow the steps from here: https://github.com/tavicu/homebridge-samsung-tizen/issues/321#issuecomment-935886172
What changed:
I will say the feature is 95% done.
I still have some things that i want to change before release (removing the feature to list installed applications for example) and i will also want to improve the Wiki section.
So unfortunately, even if this feature will be 100% done it will not be released until the documentation will be ready. (At least this is my position right now, it may change).
I believe the solution is that an input delay needs to be baked-in automatically when an input change follows a power state change. This is a common parameter in IR control.
This same issue has affected other Homekit plugins, such as Denon-TV that controls Denon and Marantz AVRs. In fact I just reported a regression of this here which has been fixed: https://github.com/grzegorz914/homebridge-denon-tv/issues/129#issuecomment-1034573872
I believe the solution is that an input delay needs to be baked-in automatically when an input change follows a power state change. This is a common parameter in IR control.
Setting an automation that turn the tv ON then change the input will not result in a single command to the plugin that i will know to interpret. It will be two commands.
Right now the only way i'm thinking is adding a delay to Power On but i don't want to do this since it will affect everybody. So introducing a problem for 100% of the users to resolve one small issue it's not ok :)
I will think and test a few things. First i must see after which time the TV will accept the Input switch after the TV turned on.
Take a look at the source for the plug-in in linked. There is no delay as far as I know on regular input changes. Only on power on sequencing. It might be necessary to add the delay to the power on action - that would benefit everyone because no command can immediately follow a power command workout the tv being ready to accept it.
On Feb 11, 2022, at 9:09 AM, Octavian Ruda @.***> wrote:
I believe the solution is that an input delay needs to be baked-in automatically when an input change follows a power state change. This is a common parameter in IR control.
Setting an automation that turn the tv ON then change the input will not result in a single command to the plugin that i will know to interpret. It will be two commands.
Right now the only way i'm thinking is adding a delay to Power On but i don't want to do this since it will affect everybody. So implementing a problem for 100% of the users to resolve one small issue it's not ok :)
I will think and test a few things. First i must see after which time the TV will accept the Input switch after the TV turned on.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.
Take a look at the source for the plug-in in linked. There is no delay as far as I know on regular input changes. Only on power on sequencing. It might be necessary to add the delay to the power on action - that would benefit everyone because no command can immediately follow a power command workout the tv being ready to accept it.
Adding delay to power on command will not solve the problem. I just tested it and Apple don't wait for Main Accessory to finish responding before sending the change input. It just sends both commands at the same time.
So I have to implement something in the change input action to wait before calling the API if the TV was just turned ON!
Edit: And more fun is that sometimes it runs the change input command and then the turn on ... Did i told you i hate HomeKit?
Ok, i have pushed a new version which adds a delay of 2.5 seconds before changing the input if the TV was just turned on.
But i don't like it because of two things:
race
method, this means that the command will respond in maximum 1.5 seconds even if it takes longer. This is resulting in not displaying any errors if the command failed and it took more than 1.5 seconds.I think the plug-in might be best served with the delay as a variable in the ui. This is what Logitech and other remote manufacturers have in place for their products to be able to deal with customers different systems.
If apples HomeKit was natively scriptable I’d make my own delay, but that’s unfortunately not possible. I’d have to move the tv control over to a different platform or the entire automation sequence.
On Feb 14, 2022, at 11:52 AM, Octavian Ruda @.***> wrote:
Ok, i have pushed a new version which adds a delay of 2.5 seconds before changing the input if the TV was just turned on.
But i don't like it because of two things:
Newer TVs takes about 2s to accept requests after turning on. One of my older TV (2019) takes 8 seconds! There will be a lot of issues on this topic. Since i add the delay i have implemented a race method, this means that the command will respond in maximum 1.5 seconds even if it takes longer. This is resulting in not displaying any errors if the command failed and it took more than 1.5 seconds. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.
If apples HomeKit was natively scriptable I’d make my own delay, but that’s unfortunately not possible.
Happy to be proven wrong, but I highly doubt scenes on other platforms are scriptable as well. For automations and button triggers, you can indeed program a delay natively in Home.app.
That being said, I hope @tavicu can make it for this specific reason highly configurable (my parent's 7-series features slower processor than my 8-series and it is from same year, so configurable delay would make sense regardless of model year as well)
All decent home automation platforms are fully scriptable. Indigo, Home Assistant, etc.
I’ve never seen any delay options in home.app. And nothing of any kind that is able to solve this basic requirement of turning on the tv to the correct input.
On Feb 14, 2022, at 12:21 PM, Jakub Heglas @.***> wrote:
If apples HomeKit was natively scriptable I’d make my own delay, but that’s unfortunately not possible.
Happy to be proven wrong, but I highly doubt scenes on other platforms are scriptable as well. For automations and button triggers, you can indeed program a delay natively in Home.app.
That being said, I hope @tavicu can make it for this specific reason highly configurable (my parent's 7-series features slower processor than my 8-series and it is from same year, so configurable delay would make sense regardless of model year as well)
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.
Already took in consideration and there is an option to set delay per input like this. The value is in ms. 1000 means 1 second
{
"type": "input",
"name": "Apple TV",
"value": "HDMI1",
"delay": 5000
}
@tavicu That is very elegant actually, thank you!
@HVR88 Just because you didn't see it doesn't mean it doesn't exist :) You can, for example, make a catch-all automation that executes on TV On, waits 2 seconds and then triggers the input change. Quite easily right in Home.app, that is.
In my opinion HomeKit is just plain dumb! It was in the first smart automation systems but they didn’t improve it by much! Just little by little every year!
SmartThings api for example, when you send a command you can send a list of commands, not just one! Let’s say turn on then change input!
All you have to do is to send the commands and the api will turn on the tv then wait until it can change the input.
My goal with this integration is to learn as much as i can regarding the SmartThings api and then start to switch functions to it step by step!
Unfortunately there are still some missing things for the older tvs. For example, you can’t turn on older tvs with smartthings api.
@jakubheglas You have to convert the automation to a shortcut - lots of problem reports about dealing with shortcuts on Homepod - and Homepod is almost exclusively what I use with Homekit. My reason to use Homekit at all is for whole-home Siri support as I already have a very capable automation system that handles most of my devices like Z-Wave switches.
This plugin was also my main reason for setting up Homebridge - nothing else that I tested on other automation systems worked well with my 2020 TV. Thanks @tavicu for adding this feature and so quickly. Homekit is definitely very much incomplete/half-baked. It's the beginning of an automation platform but it's like Apple have forgotten to do anything with it since introducing it. If it weren't for Homebridge getting all kinds of different devices into it, I'm not sure I'd be using it at all.
@tavicu With 5.2.0beta.4 is it necessary to set the "delay" property or do you include a default delay for all inputs? And can you confirm if the delay property only applies to input commands after power commands?
@tavicu With 5.2.0beta.4 is it necessary to set the "delay" property or do you include a default delay for all inputs? And can you confirm if the delay property only applies to input commands after power commands?
A default delay of 2.5 seconds it’s applied by default only after a power switch command was sent.
That option is just in case it doesn’t work at it should!
Hi @tavicu — Posting this here in case you have any insight. I’ve been using the beta plugin and it works well. However, one issue comes up related to the TV power state: I have an automation in the Home app to turn OFF some Hue lights if/when the Samsung TV turns OFF. Most of the time this works as expected, but many times the lights will turn OFF even though the TV continues to be ON. I can trace this issue to the automation itself, so somehow HomeKit thinks the TV has turned off (even though it’s still on) so my lights get turned off as well.
I set Homebridge to DEBUG mode but I see very few messages related to the plugin in the logs. I see the messages indicating that the lights have been switched off, but no messages from your plugin that would indicate the TV has powered off as a trigger to the automation being fired.
One message that I see in the log is this one:
[16/02/2022, 12:34:51] [My TV] [DEBUG] https://api.smartthings.com/v1/devices/MY DEVICE ID/status undefined
Does this ring a bell with you? Could this be the possible source of the issue? Any insight would be welcome. Thanks again for all your efforts with this plugin.
Add (additional) support for the SmartThings API, which will allow direct/instant query and setting of Input Source among other features not possible with the remote control API being used right now. It will solve a number of the shortcomings listed on the first page of the Wiki, including: checking current channel, volume, mute status, source selection.
I briefly mentioned this in another post, but I'm creating a dedicated feature request for it now after finding multiple code examples where this feature was added to previous integration that, like homebridge-samsung-tizen, were using the V2 API or legacy remote control APIs exclusively. In short: the developers were able to integrate SmartThings support without refactoring their whole projects. ;)
Similar integrations/drivers for other platforms, using v2 remote API, SmartThings API and legacy APIs:
Hubitat: https://github.com/DaveGut/HubitatActive/blob/master/SamsungTvRemote/Samsung%20TV%20Remote.pdf
Homey: https://github.com/balmli/com.samsung.smart
Home Assistant: https://github.com/jaruba/ha-samsungtv-tizen