Execute Bookmarklets with JavaScript from ST Hub

I have an HDMI matrix that has a web interface.
With the web interface open (192.168.3.112), I can send the following JavaScript bookmarklet to change the output mapping of the matrix:

javascript:document.getElementById(“bac4”).selectedIndex=1;document.getElementById(“RecallBu”).click();

Is it possible to execute these steps through the ST hub?

Essentially I need to run the JavaScript snippet on a web page interface.

At the very least, is it possible to load a web page in the background with SmartThings Hub?

Hi, there! Let me see if I understand your Use Case.

  • You have an HDMI matrix connected to your ST Hub as a LAN device.
  • This device doesn’t appear in the API’s device list, though.
  • You’d like to have a Web Page (hosted locally) that sends a command to that device when you select the HDMI slot as in the default WebUI for the device.

Are the previous points correct?

I’m going to say no. You are talking about commands executed in the document constructed by a web browser.

What you need to know is what the result of selecting index 1 of ‘bac4’ and clicking on ‘RecallBu’ actually is. Presumably it will result in an HTTP request being sent to your matrix. If you know what that request is then you are in with a shout.

To put it another way, you need to know the API the web interface is exploiting. You don’t need to press that button, you need to act like that button.

1 Like

Hello nayelz,

  • The matrix is not technically “connected” to the hub, but it is on the same LAN as the hub.
  • No, it is not in the API list
  • The web page seems to be the only way that the hub might be able to control it. The matrix has TELNET, but as I understand it, ST hub does not support controlling devices through TELNET.

I understand what you are saying in principle but do not have enough technical expertise to find what I would need for this.
Here is the web interface screenshot:

Would you be able to point me in the right direction?
Here is the html code:

What that JS does is just recall a “mapping” from the matrix.
This is the matrix:

Many Thanks!

So it does look like I can control the device through the terminal using NetCat:

echo -n -e “\x0c\x4d\x41\x52\x44\x43\x48\xff\x03\x01\x01\xbf” | nc 192.168.3.102 9760
//This changes Out1 to In1

echo -n -e “\x0c\x4d\x41\x52\x44\x43\x48\xff\x03\x01\x02\xc0” | nc 192.168.3.102 9760
//This changes Out1 to In2

Is there a simple way to create a device handler on the hub to simulate each string of code as a separate button?