Node-RED - after update cannot select any devices in command/device nodes [solved with v1.7.2 release]

I release a version to fix 401 issue when NR login is enabled
Even if it seems not related, can you try it @erktrek

During this time, I'll try a setup with nodejs 14
edit: no issue with nodejs 14.16.1 with npm 6.14.12 and NR 1.3.3

3 Likes

I've not been having any issues with HE nodes, and I've been doing a lot of tinkering these last few days. No login to Node Red.

1 Like

@erktrek If you still have issue after 1.7.1

Go to this url: http://<host>:1880/hubitat/js/common.js
You should have an explicit error message for the reason why you get 404

Also, can you give me the output of this command

ls -l /<NR install>/node_modules/node-red-contrib-hubitat/nodes/static/*

To be sure that file permissions are ok (you should have only common.js file)

1 Like

No issues here on 1.7.0:

Node-red 1.3.3
node 12.22.1
no node-red login

1 Like

Not that it matters, but node v15 isn't qualified/tested on node-red. Just an FYI - if it works, it works.

https://nodered.org/docs/faq/node-versions

( and now you all know why I'm running old node v12. :wink: )

1 Like

I know what the issue is!!!!!!!!

In my settings.js file I have this:

   httpAdminRoot: '/admin',

When I access my Node-RED UI I go to:

http://<host>:1880/admin

So this

http://<host>:1880/hubitat/js/common.js

yields this:

Cannot GET /hubitat/js/common.js

BUT if I do THIS:

http://<host>:1880/admin/hubitat/js/common.js

Then I get info back..

/* eslint-disable no-unused-vars */
/* eslint-disable no-param-reassign */
function cleanHubitatSelectMenu(menuId, defaultText) {
  const selectMenu = $(`#${menuId}`);
  selectMenu.find('option').remove().end();
  const option = $('<option>', { value: '', text: defaultText });
  selectMenu.append(option);
  selectMenu.val('').trigger('change');
}

function resetHubitatSelectMenu(menuId, defaultText) {
  const selectMenu = $(`#${menuId}`);
  selectMenu.find('option').remove().end();
  const defaultOption = $('<option>', { value: '', text: defaultText });
  selectMenu.append(defaultOption);
  return selectMenu;
}

function paramsFromServer(server) {
  return {
    usetls: server.usetls,
    host: server.host,
    port: server.port,
    appId: server.appId,
    token: server.credentials.token,
  };
}

function cleanHubitatDevices() {
  cleanHubitatSelectMenu('node-input-deviceId', 'Choose device...');
}

function listHubitatDevices(server, deviceId) {
  const selectMenu = resetHubitatSelectMenu('node-input-deviceId', 'Choose device...');
  $.getJSON('hubitat/devices', paramsFromServer(server), (res) => {
    res.forEach((item) => {
      const selected = deviceId === item.id;
      const option = $('<option>', { value: item.id, text: item.label });
      selectMenu.append(option);
      if (selected) { selectMenu.val(item.id).trigger('change'); }
    });
    if (!deviceId) { selectMenu.val('').trigger('change'); }
  }).fail(() => cleanHubitatDevices());
}

function loadCredentials(server) {
  return new Promise((resolve, reject) => {
    if (server.credentials) {
      resolve();
    } else {
      $.getJSON(`credentials/hubitat-config/${server.id}`, (data) => {
        server.credentials = data;
        server.credentials._ = $.extend(true, {}, data);
        resolve();
      }).fail(() => reject());
    }
  });
}
4 Likes

Nice !! :+1:

It's not simple/quick to fix (to handle this parameter), so I'll make some tests and will try to release something tomorrow

1 Like

Its all good - the earlier version still works great for me so I'm okay for a bit. If you need me to do any further testing etc let me know!

1 Like

Well I was wrong, it's was really simple/quick to fix :laughing:
1.7.2 released with the fix, enjoy :slight_smile:

2 Likes

webpage login works great.

Thanks for a great JOB.

2 Likes

Works great thank you!!!!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.