jaruba / ha-samsungtv-tizen

📺 HomeAssistant - For Samsung TVs 2016+, Includes SmartThings API and Channel List Support
Apache License 2.0
286 stars 64 forks source link

Key chaining for better volume control #108

Open LukeDefeo opened 3 years ago

LukeDefeo commented 3 years ago

Hello, thanks for this improved integration

Iim trying to program a smart switch to control volume of tv. When pressing and holding it should move volume or down fairly slowly and continuously.

I tried sending the volume up / down commands one by one but the tv is quite slow to respond to them (around 500ms to 1sec) and every 5 seconds or so it just stops processing commands.

Instead i thought i would try key chaining. I got it to work with the following

entity_id: media_player.samsung_tv_remote media_content_id: KEY_VOLDOWN,1000 media_content_type: send_key

However this holds the button down for 1 whole second and the volume moves really fast. In the docs https://github.com/jaruba/ha-samsungtv-tizen/blob/master/Key_chaining.md it says you can send keys indvidually with a custom delay.

Key codes can be chained with the "+" symbol, delays can also be set in milliseconds between the "+" symbols (default delay is 500ms), and if you wish to keep a key pressed you can set the desired time in milliseconds with the "," symbol.

I cannot for the life of me work out how to do this ive tried all sorts

KEY_VOLDOWN+100+KEY_VOLDOWN KEY_VOLDOWN+100KEY_VOLDOWN

etc.

Nothing works correctly. What am I doing wrong?

My TV is 2020 43" TU8000 Not sure if that matters

Thanks

LukeDefeo commented 3 years ago

nevermind it seems to be working now, the correct syntax is KEY_VOLDOWN+400+KEY_VOLDOWN+400+KEY_VOLDOWN+KEY_VOLDOWN+400+KEY_VOLDOWN

It does seem that the behaviour is a bit eratic like this. The timing is inconsistent and someimes not all the presses are actioned.

How is this implemented is the client decoding this and sending many commands?

Finally is there a way to adjust the repeat speed using the command syntax.

E,g KEY_VOLDOWN,1000,250

which would mean press key down for 1 second, repeating every 250 ms?

jaruba commented 3 years ago

The timing is inconsistent and someimes not all the presses are actioned.

This may be because of a commit I made at some point, I was actually expecting someone to come complain about it. Reverting that commit will probably make the key presses be sent with a larger delay between them, but I don't think there will be any missing keys anymore..

Finally is there a way to adjust the repeat speed using the command syntax.

I'm not sure i understand this question, u can tell it to keep a button pressed for 1 second with KEY_VOLDOWN,1000, but i don't know what you mean by "repeat every 250 ms".. if you want it to repeat, just do KEY_VOLDOWN,1000+250+KEY_VOLDOWN,1000? If it would be an infinite repeat, then how would you ever stop it?