ztalbot2000 / homebridge-cmd4

CMD4 Plugin for Homebridge - Supports ~All Accessory Types & now all Characteristics too
Apache License 2.0
145 stars 14 forks source link

Using the plug-in to control apple tv. #115

Open matcik890 opened 2 years ago

matcik890 commented 2 years ago

Good afternoon. I want to configure the apple tv control on/off, as well as monitor the status of the device, for this I installed in homebridge on raspberry pi atvremote pyatv through which I had the opportunity to control via SSH script

atvremote -s 192.168.1.34 --airplay-credentials [REDACTED] power_state

atvremote -s 192.168.1.34 --airplay-credentials [REDACTED] turn_on

atvremote -s 192.168.1.34 --airplay-credentials [REDACTED] turn_off How can I use this plugin and what should the "bash" script contain appletv.sh " which is available in this configuration which is given neither { "platform": "Cmd4", "name": "Cmd4", "accessories": [ { "type": "Switch", "name": "TV", "on": false, "state_cmd": "bash appletv.sh", "polling": [ { "on": false, "interval": 5, "timeout": 5000 } ], "interval": 5, "timeout": 5000 } ] }

ztalbot2000 commented 2 years ago

Hi,

Have a look at some of the examples shipped with Cmd4 under Extras/Cmd4Scripts/Examples. There are a couple of bash scripts there.

Ttyl, John

On Wed, Oct 20, 2021 at 6:55 PM matcik890 @.***> wrote:

Good afternoon. I want to configure the apple tv control on/off, as well as monitor the status of the device, for this I installed in homebridge on raspberry pi atvremote pyatv through which I had the opportunity to control via SSH script

atvremote -s 192.168.1.34 --airplay-credentials 5b25cb1f81113aad58cae4eba40051d6d10928ae0f59fe88dbf8b53750abe675 power_state

atvremote -s 192.168.1.34 --airplay-credentials 5b25cb1f81113aad58cae4eba40051d6d10928ae0f59fe88dbf8b53750abe675 turn_on

atvremote -s 192.168.1.34 --airplay-credentials 5b25cb1f81113aad58cae4eba40051d6d10928ae0f59fe88dbf8b53750abe675 turn_off How can I use this plugin and what should the "bash" script contain appletv.sh " which is available in this configuration which is given neither { "platform": "Cmd4", "name": "Cmd4", "accessories": [ { "type": "Switch", "name": "TV", "on": false, "state_cmd": "bash appletv.sh", "polling": [ { "on": false, "interval": 5, "timeout": 5000 } ], "interval": 5, "timeout": 5000 } ] }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/115, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3CKM7SQOQ67W4SGSLUH5CH7ANCNFSM5GMX3FBQ .

ztalbot2000 commented 2 years ago

Hi again.

There are also templates at: https://ztalbot2000.github.io/homebridge-cmd4

Ttyl, John

On Wed, Oct 20, 2021 at 6:55 PM matcik890 @.***> wrote:

Good afternoon. I want to configure the apple tv control on/off, as well as monitor the status of the device, for this I installed in homebridge on raspberry pi atvremote pyatv through which I had the opportunity to control via SSH script

atvremote -s 192.168.1.34 --airplay-credentials 5b25cb1f81113aad58cae4eba40051d6d10928ae0f59fe88dbf8b53750abe675 power_state

atvremote -s 192.168.1.34 --airplay-credentials 5b25cb1f81113aad58cae4eba40051d6d10928ae0f59fe88dbf8b53750abe675 turn_on

atvremote -s 192.168.1.34 --airplay-credentials 5b25cb1f81113aad58cae4eba40051d6d10928ae0f59fe88dbf8b53750abe675 turn_off How can I use this plugin and what should the "bash" script contain appletv.sh " which is available in this configuration which is given neither { "platform": "Cmd4", "name": "Cmd4", "accessories": [ { "type": "Switch", "name": "TV", "on": false, "state_cmd": "bash appletv.sh", "polling": [ { "on": false, "interval": 5, "timeout": 5000 } ], "interval": 5, "timeout": 5000 } ] }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/115, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX3CKM7SQOQ67W4SGSLUH5CH7ANCNFSM5GMX3FBQ .

matcik890 commented 2 years ago

Unfortunately, I don't really understand how you can use these commands in the form of scripts in the proposed typical templates.

mitch7391 commented 2 years ago

@matcik890 what is the response when you type 'power_state' command? That will be helpful to know in creating your script. I have also edited your first post to remove your Apple TV credentials (just in case it is not good you are sharing this).

Lastly, not to discourage you from using this plug-in; but is there any reason you are not using one of the many homebridge plug-ins that are designed for the Apple TV?

matcik890 commented 2 years ago

@matcik890 каков ответ, когда вы вводите команду "power_state"? Это будет полезно знать при создании вашего сценария. Я также отредактировал ваш первый пост, чтобы удалить ваши учетные данные Apple TV (на всякий случай, если вам нехорошо делиться этим).

Наконец, не хочу отговаривать вас от использования этого плагина; но есть ли какая-либо причина, по которой вы не используете один из многих подключаемых модулей homebridge, предназначенных для Apple TV?

Unfortunately, after updating to iOS and version 15, homebridge plugins stopped working. I have configured the configuration this way { "platform": "Cmd4", "name": "Cmd4", "interval": 5, "timeout": 4000, "stateChangeResponseTime": 3, "queueTypes": [ { "queue": "A", "queueType": "WoRm" } ], "accessories": [ { "type": "Switch", "displayName": "Apple TV Power", "on": "FALSE", "queue": "A", "polling": [ { "characteristic": "on" } ], "state_cmd": "bash /var/lib/homebridge/appletv_powerstate.sh" }, { "type": "Switch", "displayName": "Apple TV Play State", "on": "FALSE", "queue": "A", "polling": [ { "characteristic": "on" } ], "state_cmd": "bash /var/lib/homebridge/appletv_playstate.sh" } ] }

ztalbot2000 commented 2 years ago

Hi,

Cmd4 is just a tool to run a shell script. Put Cmd4 in debug mode as per the documentation and you will see exactly the command executed. You can also execute the same command from any terminal windows prompt. These are the first steps you should try when debugging and they are also in the documentation.

Ttyl, John

On Thu, Oct 28, 2021 at 8:35 PM matcik890 @.***> wrote:

I also created a file that runs the apple tv management scripts: appletv_powerstate.sh , but after disconnecting it behaves strangely and after a few seconds it turns on again, here is my example appletv_powerstate.txt https://github.com/ztalbot2000/homebridge-cmd4/files/7438051/appletv_powerstate.txt .

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/115#issuecomment-954320342, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCXZPWULZ7XOW6LRP6HTUJHT47ANCNFSM5GMX3FBQ .

mitch7391 commented 2 years ago

Definitely good advice from John here.

However @matcik890 you still did not answer my question of what is returned when you use the command for “power_state”. Does it return a “1”, a “true”, an “on”? If I know this I can put together a very basic script for you to use with that config.

Also more concerning is your comment that no Homebridge plugins are working after iOS 15. Do you mean literally every plug-in? Is Homebridge still running? I would submit an issue on the Homebridge GitHub page if I were you. Or you can start fault finding it by removing all your plugins and adding them back one at a time until you find which one is causing the problem; as I can bet it is one causing Homebridge to crash.

ztalbot2000 commented 2 years ago

Hi Mitch,

I was previously trying to help out someone who flagged an issue with Homebridge that since the recent upgrade, they too had everything, and I mean everything go unresponsive; even after rolling back! My suggestion to them was to roll back, stop Homebridge, delete the persist and accessories directories and then start Homebridge again. They refused afterwards to try 15 again as the process is tedious with a lot of accessories.

Ttyl, John

On Thu, Oct 28, 2021 at 11:19 PM Mitch Williams @.***> wrote:

Definitely good advice from John here.

However @matcik890 https://github.com/matcik890 you still did not answer my question of what is returned when you use the command for “power_state”. Does it return a “1”, a “true”, an “on”? If I know this I can put together a very basic script for you to use with that config.

Also more concerning is your comment that no Homebridge plugins are working after iOS 15. Do you mean literally every plug-in? Is Homebridge still running? I would submit an issue on the Homebridge GitHub page if I were you. Or you can start fault finding it by removing all your plugins and adding them back one at a time until you find which one is causing the problem; as I can bet it is one causing Homebridge to crash.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/ztalbot2000/homebridge-cmd4/issues/115#issuecomment-954398357, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSBCX2HAW3J4OI3Y2TZL5TUJIHEHANCNFSM5GMX3FBQ .

matcik890 commented 2 years ago

Определенно хороший совет от Джона здесь.

Однако @matcik890 вы все еще не ответили на мой вопрос о том, что возвращается при использовании команды “power_state”. Возвращает ли он “1”, “истинно”, “включено”? Если я это знаю, я могу составить очень простой сценарий, который вы будете использовать с этой конфигурацией.

Также больше беспокоит ваш комментарий о том, что плагины Homebridge не работают после iOS 15. Вы имеете в виду буквально каждый плагин? Хоумбридж все еще работает? На вашем месте я бы разместил выпуск на странице Homebridge GitHub. Или вы можете начать поиск неисправностей, удалив все свои плагины и добавляя их обратно по одному за раз, пока не найдете, какой из них вызывает проблему; как я могу поспорить, это тот, который вызывает сбой Homebridge.

Thank you for your help in this matter. It is not always possible to answer your question promptly. I am currently testing two scripts, the first script that should turn on and off the apple tv using the generated pyatv command, which is described here postlund/pyatv#1168, with which you can get the airplay_credentials command,

my ot looks like this

"5b25cb1f81113aad58cae4eba40051d6d10928ae0f59fe88dbf8b53750abe675:4843b4387976af4f25068a7eb7fb4ef71cb40ecb44bca96d060e174057cc4acc:33394246433942322d383333322d343435312d414242452d314230344138373146354338:30626137626665652d633832382d343334342d396531642d373036326434393838316236"

and by specifying the ip address of your device, the command should work through the script

and the second is playback or pause, for use in the form of automation.

matcik890 commented 2 years ago

apple tv.zip

matcik890 commented 2 years ago

I have formed several such scenarios that work perfectly through the SSH homebridge terminal. Who wants to make it work this way discuss this topic here

https://github.com/lukasroegner/homebridge-apple-tv-remote/issues/105

and it would be very useful if you helped ztalbot2000, because now with this plugin you can make apple tv work as needed.

matcik890 commented 2 years ago

12222223 1222233333223