Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to use / am I missing something? #15

Open
tampiss opened this issue Apr 19, 2021 · 39 comments · Fixed by #28 or #30
Open

[Question] How to use / am I missing something? #15

tampiss opened this issue Apr 19, 2021 · 39 comments · Fixed by #28 or #30
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@tampiss
Copy link

tampiss commented Apr 19, 2021

Hi, I have Raspi 4 with Node-RED installed. I have installed this plugin to enable me to connect to Smartthings cloud and obtain status of my Samsung Washer and Samsung Dryer. When I create a new flow, add My device node - fill in the token, I get the list of my devices. I unselect all and chose only 1 (for example Samsung Washer), then I deploy. After that, I add status or event node and sometimes I can choose the appropriate selects, but most of the time they are empty...

Any hints please?
Thank you, Martin

@dplaya-min dplaya-min added the question Further information is requested label Apr 20, 2021
@shgood
Copy link
Contributor

shgood commented Apr 21, 2021

Hi,

Could you let us know a more detailed situation?
i.g. when your device disappears / whether node-red was restarted or not

And It would be better if you could give us browser and node-red runtime logs.

Thank you!

@tampiss
Copy link
Author

tampiss commented Apr 21, 2021

@shgood well I actually saw the list of devices in Status or Event nodes once and I am unable to simulate it again. Since now, I always get an empty select boxes. I tried to uninstall the plugin, but that did not help. Please see attached files, to clarify my problem. For example, if I open the Command node, the list of devices exists. By the way, what is the best way for you to get you the node-red runtime log? How to access it please?

I am running node-red on Raspi 4, Homebridge image:
Node version is v14.16.1
NPM version 6.14.12
Node-RED 1.3.1
Your plugin 1.1.3

Browser/PC:
MacOS Big Sure 11.2.3
Safari 14.0.3 (tried dirrefent user agents for Chrome, Edge...)
Even tried Chrome app version 85.0.4183.83

Snímek obrazovky 2021-04-21 v 9 05 47

Snímek obrazovky 2021-04-21 v 9 07 02

Snímek obrazovky 2021-04-21 v 9 07 28

Snímek obrazovky 2021-04-21 v 9 07 55

@shgood
Copy link
Contributor

shgood commented Apr 22, 2021

  1. event-device node work with "automation" node only. So in your case, event-device node doesn't work.

  2. when you enter "F12" key on the chrome, you can see the chrome console log like below.
    이미지 033
    If there are log messages, share them here.

  3. could you share capabilities list of your devices?
    In the device list, you can get capabilities information like below.
    이미지 031
    Because there may be no capability available for status-node if only command-device node works.

@tampiss
Copy link
Author

tampiss commented Apr 22, 2021

@shgood Hi, bellow are the print-screens. Hope it helps. Martin

Snímek obrazovky 2021-04-22 v 8 08 13
Snímek obrazovky 2021-04-22 v 8 08 27
Snímek obrazovky 2021-04-22 v 8 07 34

ReferenceError: addTitle is not defined
at t..._create (red.min.js:16)
at t..._create (vendor.js:10)
at t..._createWidget (vendor.js:10)
at new t.. (vendor.js:10)
at HTMLOListElement. (vendor.js:10)
at Function.each (vendor.js:2)
at s.fn.init.each (vendor.js:2)
at s.fn.init.t.fn. [as editableList] (vendor.js:10)
at DeviceNodeEventHandler.THING.initContainer (:890:92)
at DeviceNodeEventHandler (:1179:15)

@shgood
Copy link
Contributor

shgood commented Apr 22, 2021

Hi,
I think It's related to node-red 1.3.1 issue

node-red/node-red#2933

please, install node-red 1.3.2 or 1.3.3.

@tampiss
Copy link
Author

tampiss commented Apr 22, 2021

@shgood YES!! 🙌 👏 👍 this fixed the issue.. May I ask one more question? Does it mean, I have to have each device on separate flow? Its not problem for me, but just asking. If I create flow, select My device node and select 2 devices, when I use Event/Status node, I only get active the first one and the rest is disabled. Thank you, Martin

@shgood
Copy link
Contributor

shgood commented Apr 22, 2021

No, you don't need to.

If a device is disabled on the select, that device is not an appropriate device used by Event/Status/Command node.

It means that there are some conditions.
i.g. Status node use device that has attributes property / Command node use device that has command property ...

And when you hover mouse over the disabled select option, you can see the reason why the device is disabled.

@tampiss
Copy link
Author

tampiss commented Apr 22, 2021

@shgood see my trouble. If I create flow, select My Device, then select 2 devices, deploy. Then I add Event node and only first device is selected. If I open the device select, all devices are disabled (see print-screen)... So I can only work with the one preselected..

Now, I have 2 flows, where in both I select different Device in My device node.. By adding Event node to each flow, I have correctly preselected device and I can work with it.. yet still all devices are disabled when I open the select.

Snímek obrazovky 2021-04-22 v 10 54 26
Snímek obrazovky 2021-04-22 v 10 55 06
Snímek obrazovky 2021-04-22 v 10 55 02

@shgood
Copy link
Contributor

shgood commented Apr 23, 2021

The current behavior seems to be a bug in a safari browser.
In a normal case, a disabled device cannot be selected.

But. as I said, event-device node work with "automation" node only.
In event-node, you can select the only device set in "device profile" node.
Because They are set in my-device node, those devices are disabled.

Please, use status-node instead of event-node to get device status.

@kudlaaaty
Copy link

Hi,
I have very simmilar problem. I'm using Samsung Automation Studio Palette (1.1.6) in Node Red (1.3.5) in Home Assistant (2021.6.5). When I initailly insert "My device" node, and put there a token devices are visible:
image

After that I can i.e. add command node and set some device property:

image

Afer deploy everything is working just fine, but when i left the Node Red and open it again, devices and other node properties of "My device" node are gone:

image

as well as in the "Command" node:

image

I've found this behaviour very similar to the case described in this topic, however I'm using version of Node Red above the 1.3.3. I've tried also different browsers (Chrome, Edge, FireFox) but witout any success. Any ideas what could gone wrong?

@ghost
Copy link

ghost commented Jun 30, 2021

I have the same problem ... (palette 1.1.6)

Screenshot_2021

@kudlaaaty
Copy link

@shgood after upgrade to 1.1.7 this behaviour still exists

@shgood shgood linked a pull request Jul 1, 2021 that will close this issue
@shgood shgood removed a link to a pull request Jul 1, 2021
@shgood shgood linked a pull request Jul 2, 2021 that will close this issue
@shgood shgood closed this as completed in #28 Jul 2, 2021
shgood added a commit that referenced this issue Jul 2, 2021
* fix : mydevice info api bug

* modify : package.json version

* modify : modify 'undefined' room name to 'Unknown'
shgood added a commit that referenced this issue Jul 2, 2021
* fix : mydevice info api bug

* modify : package.json version

* modify : modify 'undefined' room name to 'Unknown'
@shgood shgood reopened this Jul 2, 2021
@shgood
Copy link
Contributor

shgood commented Jul 2, 2021

Hi, @kudlaaaty , @RitaSghe.
Thank you for your comment.

1.1.9 version has been released today to fix SmartThings my-device bug.

Please, update and use the new version.
Thank you.

@kudlaaaty
Copy link

@shgood
Hi, I've just updated to 1.1.9 but this behaviour still exist.

@shgood
Copy link
Contributor

shgood commented Jul 2, 2021

@kudlaaaty

Afer deploy everything is working just fine, but when i left the Node Red and open it again, devices and other node properties of "My device" node are gone:

image

as well as in the "Command" node:

image

I've found this behaviour very similar to the case described in this topic, however I'm using version of Node Red above the 1.3.3. I've tried also different browsers (Chrome, Edge, FireFox) but witout any success. Any ideas what could gone wrong?

After re-open node-red, Your my-device node's properties all disappear ?? even a 'Personal Access Token'?

If there are console error messages, could you let me know that or your server error messages?
(press 'F12' to open chrome DevTools, you can find log message in the 'console' tab)

@kudlaaaty
Copy link

In "My device" node, PAT exists, but devices are gone:
image

There are some errors and wrnings:
image

@dplaya-min dplaya-min added the bug Something isn't working label Jul 2, 2021
@ghost
Copy link

ghost commented Jul 11, 2021

After 9 days not news?

shgood added a commit that referenced this issue Jul 12, 2021
* fix : mydevice info api bug #15 (#28)

* fix : mydevice info api bug

* modify : package.json version

* modify : modify 'undefined' room name to 'Unknown'

* fix : smartthings mydevice api call, node-red http-node-root (#30)

node-red httpNodeRoot 설정, my-device API 호출시 적용

* modify : package.json version 1.1.10
@shgood
Copy link
Contributor

shgood commented Jul 12, 2021

Hi,
sorry for the late reply.

404 error is occurring, I think that it is related to node-red's 'httpNodeApp' root setting.
so, I fix the SmartThings node to using 'httpNodeApp' root setting.

Please update version '1.1.10' and check.
Thank you

@ghost
Copy link

ghost commented Jul 12, 2021

After update to 1.1.10 the bug is fixed ......

@kudlaaaty
Copy link

@shgood
unfortunately after upgrade this bug still exist in my case...
image

I've tried in different browsers but without success.

@ghost
Copy link

ghost commented Jul 13, 2021

Sorry, I restart node red and now I have the bug again ........

Screenshot_xxxxx

@kudlaaaty
Copy link

kudlaaaty commented Jul 14, 2021

Any chances to get this bug rid off? Currently, because of this bug almost whole palette is unusable
@shgood ?

@kudlaaaty
Copy link

kudlaaaty commented Jul 21, 2021

@shgood after upgrade to 1.1.11 error still exists:
image
image

@shgood
Copy link
Contributor

shgood commented Jul 21, 2021

@RitaSghe

Are you using node-red 'adminAuth' option in 'setting.js'?
It seems like related to auth_token because occurring 401 error.

Regarding that, the 1.1.11 version was released.

Please update version '1.1.11' and check.
Thank you

@shgood
Copy link
Contributor

shgood commented Jul 21, 2021

@kudlaaaty

It seems that your node-red path and httpNodeRoot path are different.
I mean,
httpNodeRoot = '/endpoint' that is set node-red settings.js
node-red path =
image

I think that maybe your node-red is running on k8s.

so, modify the path to your node-red path in the '101-SmartThings.js' file code.

RED.httpNode.get('/_smartthings/capabilities', RED.auth.needsPermission("settings.read"), (req, res) => res.json(SmartThingsProfile.getCapabilities() || {}))
RED.httpNode.get('/_smartthings/mydevices', RED.auth.needsPermission("credentials.read"), (req, res) => {

OR

try to change in the '101-SmartThings.html' file code

const root = RED.settings.httpNodeRoot||'/';

to

const root = RED.settings.httpNodeRoot||'';

@kudlaaaty
Copy link

kudlaaaty commented Jul 21, 2021

@shgood
I've tried both options, however without success. Indeed this node-red is running on k8s.

I've found that the correct URL is:
https://xxxxxxxxx.duckdns.org/api/hassio_ingress/2WYIo6nZdNVGqcJBLblrmI1_B8pC9V2wVTyz8Jjj7ek/endpoint/_smartthings/mydevices

I've change the path as follows but still node wants to read directly from "endpoint/_smartthings/mydevices"
image

@shgood
Copy link
Contributor

shgood commented Jul 21, 2021

@kudlaaaty

Hmm..

function callMyDeviceApi(path){
return new Promise((resolve,reject)=>{
const root = RED.settings.httpNodeRoot||'/';
$.ajax({
beforeSend:function(jqXHR){
const auth_tokens = RED.settings.get("auth-tokens");
if (auth_tokens) {
jqXHR.setRequestHeader("Authorization", "Bearer " + auth_tokens.access_token);
}},
url:root+path,type:"GET",dataType:'json'}).then(resolve,reject);
})
}
this.loadRuntimeCapabilities=()=>callMyDeviceApi('_smartthings/capabilities');
this.loadMydeviceInfo=()=>callMyDeviceApi('_smartthings/mydevices');

Please try to change code like below (rollback '101-SmartThings.html')

//line 765
                const root = '{your node-red path}';

e.g.

const root = '/api/hassio_ingress/2WYIo6nZdNVGqcJBLblrmI1_B8pC9V2wVTyz8Jjj7ek/endpoint/'
// or const root = 'api/hassio_ingress/2WYIo6nZdNVGqcJBLblrmI1_B8pC9V2wVTyz8Jjj7ek/endpoint/'

@kudlaaaty
Copy link

kudlaaaty commented Jul 21, 2021

@shgood
make a change in const root to:

image

do the trick! Thanks!
however are there any chances to make it more "automatic" in feature releases?

@ghost
Copy link

ghost commented Jul 21, 2021

I have update version '1.1.11' and nothing has changed and yes, I use node-red 'adminAuth' option with admin and password ....
Now I I'll explain what I do ....

Double click on the List device node and I have this situation:

img01

So single click on the red check and I have this situation:

img02

Single click on button Cancel and Double click on the List device node again and I have this situation, the real correct list of devices:

img03

Now I click done and after Deploy.

Now Double click on the List device node and I have this situation:

img01

Nothing has changed ....

img04

@shgood
Copy link
Contributor

shgood commented Jul 22, 2021

@kudlaaaty , @RitaSghe

could you try this code?

function callMyDeviceApi(path){
return new Promise((resolve,reject)=>{
const root = RED.settings.httpNodeRoot||'/';
$.ajax({
beforeSend:function(jqXHR){
const auth_tokens = RED.settings.get("auth-tokens");
if (auth_tokens) {
jqXHR.setRequestHeader("Authorization", "Bearer " + auth_tokens.access_token);
}},
url:root+path,type:"GET",dataType:'json'}).then(resolve,reject);
})
}

change 'callMyDeviceApi' function to below code

        function callMyDeviceApi(path){
            return new Promise((resolve,reject)=>{
                let root = RED.settings.httpNodeRoot||'';
                root = root.trim().replace(/^\/*/,'');
                if(/[^\/]$/.test(root)){root+='/';}
                $.ajax({url:root+path,type:"GET",dataType:'json'}).then(resolve,reject);
            })
        }

If it works, I will modify the code.

@shgood shgood closed this as completed Jul 22, 2021
@shgood shgood reopened this Jul 22, 2021
@kudlaaaty
Copy link

@shgood
I've changed this function and it seems that it works!

@ghost
Copy link

ghost commented Jul 22, 2021

@kudlaaaty

Try to restart ... :)

@kudlaaaty
Copy link

@RitaSghe
I've already done restart twice and still working

@shgood
Copy link
Contributor

shgood commented Jul 22, 2021

@RitaSghe

'restart' means 'node-red server restart' or 'browser close and open'?
could you check '_smartthings/mydevices' response code in the 'network' tab? (e.g. 401 or 404)

And your raspberry can connect SmartThings API?
the node-red server needs to connect SmartThings API to work nodes.

@shgood
Copy link
Contributor

shgood commented Jul 22, 2021

@kudlaaaty
Thanks a lot.
I will modify the code like above in the new release.

@ghost
Copy link

ghost commented Jul 22, 2021

I mean restart node-red server ...
Error is 401

and I think raspberry is connected with SmartThings API because the node work fine, the problem for me is only the correct list of device ....

@kudlaaaty
Copy link

Yes, I've restarted whole node-red.

AFAIK Rapsberry itself does not interact with ST API

@ghost
Copy link

ghost commented Aug 5, 2021

This is my situation after update, Nothing has changed ....
I repeat, the node work fine, but I cannot see the device without before refresh the node like my previous post ....

img01

img02

@ghost
Copy link

ghost commented Aug 19, 2021

You can look the other way, but this don't fix the problem .....

Orchemi pushed a commit to D5MI/SamsungAutomationStudio that referenced this issue Oct 5, 2022
jg8008 pushed a commit that referenced this issue Oct 18, 2022
jongsu2 pushed a commit that referenced this issue Oct 5, 2023
모듈 이름 중복 체크 여러가지 테스트

Co-authored-by: 김성현 <[email protected]>
jongsu2 pushed a commit that referenced this issue Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
4 participants