ollo69 / ha-samsungtv-smart

📺 Home Assistant SamsungTV Smart Component with simplified SmartThings API Support configurable from User Interface.
Apache License 2.0
441 stars 58 forks source link

Remote Control from Remote app on iPhone #51

Closed Teglgaard closed 1 year ago

Teglgaard commented 3 years ago

In the iPhone Remote App I can choose the Samsung TV after setting it up with ha-samsungtv-smart. But it does not send the commands to the tv from the iPhone Remote App. I would love to be able to use my iPhone as a remote just like i have used to do with HomeBridge instead. Alternatives could be to be able to remote control from inside Home Assistant, but it is still more convenient to use the iPhone Remote App.

And, btw great work!

ollo69 commented 3 years ago

Sorry but I do not understand what is your request. What is the iPhone Remote App?

Teglgaard commented 3 years ago

No worries. The iPhone remote app is an app built in to iOS at least in iOS 14 that can be used to control an apple tv or compatible tv. I thought it would make sense to have ha-samsungtv-smart to pick up on the remote control which currently only can be controlled to my knowledge through the SmartThings integration in Home Assistant. Together with this and the HomeKit integration the tv can be controlled by using the automation posted below. I thought it could be smart just to natively pick up the event from homekit and pass it on to the Samsung TV since the keys are the same across the Samsung tv lineup.

You can see my automation setup here:

alias: Call Samsung TV on HomeKit Remote key presses description: '' trigger:

ollo69 commented 3 years ago

Sorry but I have no idea on how to test / fix this. Should this work using homekit? Do you have some specific error to check?

Teglgaard commented 3 years ago

Hi again, with homekit installed as seen in the integrations below then you get the platform events "homekit_tv_remote_key_pressed" when using the iPhone Control Center Remote control for the TV.

Screen Shot 2021-01-07 at 20 43 24

Then all Samsung TVs respond to the same key clicks sent to it e.g. "KEY_UP" to click upwards on the tv or "KEY_HOME" to go to the Menu. So my suggestion was just to have the ability to pick up those types of events so everyone can enjoy using the iPhone Control Center Remote to control their Samsung TVs.

So to test this you just install the HomeKit Integration and listen to events "homekit_tv_remote_key_pressed" and then use the automation above to learn how to integrate it into your repo.

I hope it helps with this explanation.

pilot1981 commented 3 years ago

@ollo69 this i Apple remote on iPhone: ![Uploading 2C04DB97-4EE8-4A1D-90ED-AA66C9A5D0D0.jpeg…]()

pilot1981 commented 3 years ago

ED11CE3E-CA27-4C19-AA09-E2E17156F6C3

pilot1981 commented 3 years ago

No worries. The iPhone remote app is an app built in to iOS at least in iOS 14 that can be used to control an apple tv or compatible tv. I thought it would make sense to have ha-samsungtv-smart to pick up on the remote control which currently only can be controlled to my knowledge through the SmartThings integration in Home Assistant. Together with this and the HomeKit integration the tv can be controlled by using the automation posted below. I thought it could be smart just to natively pick up the event from homekit and pass it on to the Samsung TV since the keys are the same across the Samsung tv lineup.

You can see my automation setup here:

alias: Call Samsung TV on HomeKit Remote key presses description: '' trigger:

  • platform: event event_type: homekit_tv_remote_key_pressed event_data: {} condition: [] action:
  • service: media_player.play_media data_template: entity_id: '{{ trigger.event.data[''entity_id''] }}' media_content_type: send_key media_content_id: >- {% set key_map = {'arrow_right': 'KEY_RIGHT', 'arrow_down' : 'KEY_DOWN', 'arrow_left': 'KEY_LEFT', 'arrow_up': 'KEY_UP', 'select': 'KEY_ENTER', 'back': 'KEY_RETURN', 'information': 'KEY_HOME'} %} {{ key_map[trigger.event.data['key_name']] }} mode: single

I didn’t understand your automation: where I have to use it?

With it Apple remote works fine?

Teglgaard commented 3 years ago

Your library does not pass on commands to my samsung tv from iOS Remote as you posted a picture off above. Maybe it has changed but I had to make my own automation together with homekit to make it work instead of your library just listening for the commands as shown in my automation.

Teglgaard commented 3 years ago

So for me your library did not work with my samsung tv but maybe it is updated I have not tested without my own automation from iOS remote

pilot1981 commented 3 years ago

@Teglgaard this component don’t work in Apple remote control; where I can use your automation to fix it?

Teglgaard commented 3 years ago

I do not know how to built components so I do not know where it fits into your code. Running above code as an automation in home assistant solves the problem. My suggestion is just to have it natively in your library. For that I do not know how to code it.

pilot1981 commented 3 years ago

@Teglgaard

what I don't understand is where you used this code in HA:

platform: event event_type: homekit_tv_remote_key_pressed event_data: {} condition: [] action: service: media_player.play_media data_template: entity_id: '{{ trigger.event.data[''entity_id''] }}' media_content_type: send_key media_content_id: >- {% set key_map = {'arrow_right': 'KEY_RIGHT', 'arrow_down' : 'KEY_DOWN', 'arrow_left': 'KEY_LEFT', 'arrow_up': 'KEY_UP', 'select': 'KEY_ENTER', 'back': 'KEY_RETURN', 'information': 'KEY_HOME'} %} {{ key_map[trigger.event.data['key_name']] }} mode: single

I do not know how to built components so I do not know where it fits into your code. Running above code as an automation in home assistant solves the problem. My suggestion is just to have it natively in your library. For that I do not know how to code it.

pilot1981 commented 3 years ago

@Teglgaard how many item you have in homekit integration?

I have different item for HA bridge and Samsung TV... homekit

Teglgaard commented 3 years ago

Hi again, @pilot1981 I only have one device as seen below

Screen Shot 2021-03-15 at 18 11 46

The code you see is inputted into "Configuration"->"Automation"->"Add Automation" button Then edit the in yaml through the three dotted menu in top right corner and input: ` alias: Call Samsung TV on HomeKit Remote key presses description: '' trigger:

`

pilot1981 commented 3 years ago

Hi @Teglgaard, I tried to import this yaml code:

`

but HA GUI answer: message malformed

what is wrong?

Teglgaard commented 3 years ago

Hi again, it is malformed because it contains formatting that interferes with Github I have added it to the file below Code.txt

pilot1981 commented 3 years ago

ok, now I'm able to add it to HA: thanks @Teglgaard !

this is the code:

`alias: Call Samsung TV on HomeKit Remote key presses description: '' trigger:

You already tried to add this automation in:

integration->samsungtv->sasmungtv->automation

?

pilot1981 commented 3 years ago

@Teglgaard your automation acceptd fine from HA, but I'm not able to change channel using arrow up/down right/left.

please can you share also configuration.yaml? I think it depend from source_list/channel_list...

Teglgaard commented 3 years ago

Hi again, you can decide how it should work based on https://github.com/tavicu/homebridge-samsung-tizen/wiki/Commands

Then you just edit as you would like.

This is the entry in configuration.yaml for the tv `samsungtv_smart:

pilot1981 commented 3 years ago

Hi @Teglgaard, thanks for reply! so you don't add source list and channel list option in configuration.yaml?

pilot1981 commented 3 years ago

thanks @Teglgaard all very usefull! all works fine!

antonio1475 commented 2 years ago

@Teglgaard THANK. YOU.

It works very nicely. Coming from an LG TV that works with homekit, this was missing in the Samsung TV.

It has some "dead time" between taps, so you have to wait half a second before tapping again, but it's so much better than nothing.

It was pretty hard finding this information (Samsung TV, iOS Remote, with or without HA). I hope one day this is native in the integration like the LG WebOS integration.

Plus, I learned that the iOS app sends events to HA, so it can be customized. Thanks again

doudigit commented 2 years ago

@antonio1475 I’ve figured out a way on how to get rid of that delay, unfortunately it only works on android based tv or any other tv that has restApi that can send commands. Due to adb shell commands with android tv integration being slow to respond compared to native remote and my tv not having any restApi I’ve used an android keyboard with restApi that allows adb shell input key commands. Now the response speed of the control center remote is the same as native physical remote. Plus I’ve included a way to control play pause and volume up and down using the same principles. You can find it all here at Home assistant community link

antonio1475 commented 2 years ago

@doudigit I don't remember what the delay felt like when I wrote that, but it works super fast now.

Do you guys get volume control working. Mine worked for a while but not anymore. All the rest works through the automation above.

doudigit commented 2 years ago

@antonio1475 volume up and down, as well play/pause works and can be modified by using the custom media player integration in yaml in the link I’ve posted.

antonio1475 commented 2 years ago

Just to clarify, I'm not using what you posted regarding restAPI (my QN93A isn't Android TV, and I don't know if it supports restAPI or not - doen't really matter for me), but I'm using the Automation by Teglgaard above:

alias: 'Tele comedor: HomeKit Remote'
description: ''
trigger:
  - platform: event
    event_type: homekit_tv_remote_key_pressed
    event_data:
      entity_id: media_player.samsungtv_smart
condition: []
action:
  - service: media_player.play_media
    data_template:
      entity_id: '{{ trigger.event.data[''entity_id''] }}'
      media_content_type: send_key
      media_content_id: >-
        {% set key_map = {'arrow_right': 'KEY_RIGHT', 'arrow_down' : 'KEY_DOWN',
        'arrow_left': 'KEY_LEFT', 'arrow_up': 'KEY_UP',  'select': 'KEY_ENTER',
        'back': 'KEY_RETURN', 'information': 'KEY_HOME', 'volume_up':
        'KEY_VOLUP', 'volume_down': 'KEY_VOLUP'} %} {{
        key_map[trigger.event.data['key_name']] }}
mode: single

Even though I have volume in there, the Volume keys from iOS Remote App aren't transmitted to Home Assistant (listening to events homekit_tv_remote_key_pressed shows that).

However, I found another issue in this repo mentioning this, that took me to this one. As per the last comment, removing the TV from Homekit app and re-adding it (Ha automatically generated a new code), it all now works (volume + automation keys). Let's hope it lasts.

Cheers 😄

doudigit commented 2 years ago

@antonio1475 volume up Down and play pause can only be controlled when declared using a custom media player that you declare in config yaml. Everything is in that link what you need to do and just modify it to your use. Automation is for every other key tho besides these 4. As for issue when remote doesn’t work a simple reload of only tv bridge fixes it. Ever since I’ve declared and customized all the keys in automation and custom media player I’m not having those issues where remote keys stop responding

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 7 days with no activity.