normen / homebridge-bravia

Homebridge plugin for Sony Bravia TVs (AndroidTV based ones and possibly others)
139 stars 26 forks source link

Add custom ON/OFF direct URL command #142

Closed Sh0n closed 3 years ago

Sh0n commented 3 years ago

Hi ! I try to customize your plugin like this :

My goal is to add two new parameters called "onURL" and "offURL" which is direct URL commands. If one of this parameter is set, plugin call this url to turn ON (or OFF) TV instead of normal command.

For example, i want to call my personal api which turn ON my Apple TV for turn ON my TV.

I tried something on my repo, but i doesn't for the moment.

normen commented 3 years ago

Okay.. I'd recommend simply using CEC and turning on your TV automatically via HDMI though. Or making a scene that turns on both. At any instance this is not something I see fitting to this plugin. I'd suggest simply making a separate app for that. I guess your only real reason to try to do it this way is because this plugin can already communicate with the TV, so you could use some of the code, idk.

Anyway GL with your endeavours.

Cheers, Normen

Am 14.11.2020 02:18 schrieb Sh0n:

Hi ! I try to customize your plugin like this :

My goal is to add two new parameters called "onURL" and "offURL" which is direct URL commands. If one of this parameter is set, plugin call this url to turn ON (or OFF) TV instead of normal command.

For example, i want to call my personal api which turn ON my Apple TV for turn ON my TV.

I tried something on my repo, but i doesn't for the moment.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/normen/homebridge-bravia/issues/142

Sh0n commented 3 years ago

The advantage for me is to have one and only one device recognized as TV on my home application. Thereby, i can mange power, channel and other stuff with this one.

It's only for optimization and WAF upgrade :)

I think i'm not so far with my fork but i don't know why it won't work for the moment.

In setPowerState, i add this line if my new argument are set (onURL for example) : this.makeHttpRequest(onError, onSucces, new URL(this.onURL), null, false, true); (onURL is my direct http URL)

I add one last boolean argument in makeHttpRequest which indicate that i want use direct URL : function (errcallback, resultcallback, url, post_data, canTurnTvOn, directURL = false)

and last modification in this function : var post_options = directURL ? url : that.getPostOptions(url);

Other modifications are on config.schema to add onURL and offURL parameters.

Do you see something wrong ?

normen commented 3 years ago

No idea, for me what you intend to do and your changes don't fit together, I don't see the point of either and frankly I'm not really too inclined to debug your code.. Especially the code for the TV on check in homebridge-bravia is relatively complicated so you'd really be much better off if you simply listened to that switch in another homebridge plugin through automation.

Anyway good luck and have fun hacking at your home setup - it's fun 🙂

Am 14.11.2020 03:45 schrieb Sh0n:

The advantage for me is to have one and only one device recognized as TV on my home application. Thereby, i can mange power, channel and other stuff with this one.

It's only for optimization and WAF upgrade :)

I think i'm not so far with my fork but i don't know why it won't work for the moment.

In setPowerState, i add do this if my new argument are set (onURL for example) : this.makeHttpRequest(onError, onSucces, new URL(this.onURL), null, false, true); (onURL his my direct http URL)

I add one last boolean argument in makeHttpRequest which indicate that i want use direct URL : function (errcallback, resultcallback, url, post_data, canTurnTvOn, directURL = false)

and last modification in this function : var post_options = directURL ? url : that.getPostOptions(url);

Other modifications are on config.schema to add onURL and offURL parameters.

Do you see something wrong ?

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/normen/homebridge-bravia/issues/142#issuecomment-727194653