Skip to content

Commit

Permalink
Expose entire Maker API url
Browse files Browse the repository at this point in the history
  • Loading branch information
ripnet committed Feb 8, 2021
1 parent 40e09c0 commit 080857a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"Icon": "resources/img/hubitat_logo",
"URL": "https://github.com/ripnet/streamdeck-hubitat",
"PropertyInspectorPath": "pi/hubitat_pi.html",
"Version": "1.4",
"Version": "1.5",
"Category": "Hubitat",
"CategoryIcon": "resources/img/category",
"OS": [
Expand Down
7 changes: 5 additions & 2 deletions pi/hubitat_pi.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
<div class="sdpi-wrapper">
<div class="sdpi-heading">Global</div>
<div class="sdpi-item">
<div class="sdpi-item-label" type="field">Hostname</div>
<div class="sdpi-item-label" type="field">API URL</div>
<input type="text" class="sdpi-item-value global" id="hostname">
</div>
<details>
<summary>Example: http://192.168.1.2/apps/api/229</summary>
</details>
<div class="sdpi-item">
<div class="sdpi-item-label" type="field">Access Token</div>
<input type="text" class="sdpi-item-value global" id="access_token">
Expand Down Expand Up @@ -119,7 +122,7 @@


function getDevices() {
$.get("http://" + globalSettings.hostname + "/apps/api/229/devices/all?access_token=" + globalSettings.access_token, function(data) {
$.get(globalSettings.hostname + "/devices/all?access_token=" + globalSettings.access_token, function(data) {
devices = [];
data.forEach(function(device) {
if (device.capabilities.includes("Switch")) {
Expand Down
7 changes: 4 additions & 3 deletions plugin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@

const hubitat = {
start: function() {
hubitatWebsocket = new WebSocket("ws://" + globalSettings.hostname + "/eventsocket");
let url = new URL(globalSettings.hostname)
hubitatWebsocket = new WebSocket("ws://" + url.hostname + "/eventsocket");

hubitatWebsocket.onopen = function() { }

Expand Down Expand Up @@ -66,7 +67,7 @@
globalSettings.hasOwnProperty('access_token')
) {
const id = instances[context].settings.device;
$.get("http://" + globalSettings.hostname + "/apps/api/229/devices/" + id + "?access_token=" + globalSettings.access_token, function (data) {
$.get(globalSettings.hostname + "/devices/" + id + "?access_token=" + globalSettings.access_token, function (data) {
data.attributes.forEach(function (a) {
if (a.name === "switch") {

Expand All @@ -86,7 +87,7 @@
globalSettings.hasOwnProperty('access_token')
) {
const id = instances[context].settings.device;
$.get("http://" + globalSettings.hostname + "/apps/api/229/devices/" + id + "/" + state + "?access_token=" + globalSettings.access_token, function (data) {
$.get(globalSettings.hostname + "/devices/" + id + "/" + state + "?access_token=" + globalSettings.access_token, function (data) {
instances[context].state = state;
updateState(context);
});
Expand Down

0 comments on commit 080857a

Please sign in to comment.