Samsung / SamsungAutomationStudio

Samsung Automation Studio is to provide development tools and execution environment that can easily configure application logic by connecting both Samsung service and 3rd party service. This project is to share the node for open source NodeRED developed by Samsung Automation Studio team to the community. If you are using nodered, you can easily install the node we provide. And you can use Samsung's IoT and AI-related services more easily, and you can have an extended experience in conjunction with your own services.
Apache License 2.0
56 stars 29 forks source link

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

Open tampiss opened 3 years ago

tampiss commented 3 years ago

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

shgood commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago
  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 commented 3 years ago

@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 commented 3 years ago

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

https://github.com/node-red/node-red/issues/2933

please, install node-red 1.3.2 or 1.3.3.

tampiss commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

Screenshot_2021

kudlaaaty commented 3 years ago

@shgood after upgrade to 1.1.7 this behaviour still exists

shgood commented 3 years ago

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 commented 3 years ago

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

shgood commented 3 years ago

@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 commented 3 years ago

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

There are some errors and wrnings: image

ghost commented 3 years ago

After 9 days not news?

shgood commented 3 years ago

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 commented 3 years ago

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

kudlaaaty commented 3 years ago

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

I've tried in different browsers but without success.

ghost commented 3 years ago

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

Screenshot_xxxxx

kudlaaaty commented 3 years ago

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

kudlaaaty commented 2 years ago

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

shgood commented 2 years ago

@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 commented 2 years ago

@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. https://github.com/Samsung/SamsungAutomationStudio/blob/63906763ab0ccdf1feb2fba4626773d85918795e/101-SmartThings.js#L38-L39

OR

try to change in the '101-SmartThings.html' file code https://github.com/Samsung/SamsungAutomationStudio/blob/63906763ab0ccdf1feb2fba4626773d85918795e/101-SmartThings.html#L765 to

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

kudlaaaty commented 2 years ago

@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 commented 2 years ago

@kudlaaaty

Hmm..

https://github.com/Samsung/SamsungAutomationStudio/blob/63906763ab0ccdf1feb2fba4626773d85918795e/101-SmartThings.html#L763-L777

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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@kudlaaaty , @RitaSghe

could you try this code?

https://github.com/Samsung/SamsungAutomationStudio/blob/63906763ab0ccdf1feb2fba4626773d85918795e/101-SmartThings.html#L763-L775

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.

kudlaaaty commented 2 years ago

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

ghost commented 2 years ago

@kudlaaaty

Try to restart ... :)

kudlaaaty commented 2 years ago

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

shgood commented 2 years ago

@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 commented 2 years ago

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

ghost commented 2 years ago

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 commented 2 years ago

Yes, I've restarted whole node-red.

AFAIK Rapsberry itself does not interact with ST API

ghost commented 2 years ago

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 commented 2 years ago

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