AdyRock / com.smartthings

Home app to integrate SmartThings
GNU General Public License v3.0
12 stars 7 forks source link

When trying to add devices i get an error #8

Closed B3rt closed 3 years ago

B3rt commented 3 years ago

Installed the app and wanted to add devices, when i press on + of add then the following error occurs: [unknown_error]

I installed the app on my Homey, added the dearer token i received on the samsung website in settings and then tried to add devices. In the smartthings app i have about 7 devices: 1x samsung soundbar 6x sysbot curtain motors which are support by smartthing (i can control them using the smartthings app)

I hoped i could add the cutains motor in Homey using this app, but sadly i got the error i reported.

In the log of the app the following is listed:

AdyRock commented 3 years ago

That error basically means the token is not correct. If possible copy and paste the token to make sure there are no errors.

If you make a change to the token then restart the app as it seems there might be an issue with setting it that I need to look into.

B3rt commented 3 years ago

key is 1000% correct. Tried even 2 different keys, i copied and paste it

AdyRock commented 3 years ago

You replied quickly ;-)

Try restarting the app as it seems there might be an issue with setting it that I need to look into.

B3rt commented 3 years ago

restarting the app did the trick!! It now loads devices

B3rt commented 3 years ago

it added the device.

But it sees the curtain as a dimmable light bulbs?. I can control it by 'dimming' the light to 60% and indeed the curtain motor opens to 60%

So it works, but is it possible to add them as what they are, curtain motor/controls instead of light bulbs or must i create a new issue for this?

The problem is now that they respond to light commands: turn off all lights will also control the curtain, that is unwanted ofcourse...

AdyRock commented 3 years ago

Could you send me the device log plus the Diagnostics log so I can see what is unique that I can pick up on? If the device log is empty then start the add device process as that is when it captures the information. For the Diagnostics Log you will need to enable it an then wait for it to populate.

B3rt commented 3 years ago

I added only for now the device called 'voorraam rechts' into Homey, in Homey it is a dimmable light.

This is the detected log: ` { "items": [ { "deviceId": "79907ad7-4d40-470b-b33c-69178af5d12c", "name": "c2c-shade", "label": "slaapkamer", "manufacturerName": "SmartThings", "presentationId": "SmartThings-smartthings-c2c-shade", "locationId": "8833e7eb-cc2a-406c-9539-7594fed83230", "roomId": "359ddc92-600d-4157-bee4-7d51a6231524", "components": [ { "id": "main", "capabilities": [ { "id": "windowShade", "version": 1 }, { "id": "switchLevel", "version": 1 }, { "id": "refresh", "version": 1 }, { "id": "healthCheck", "version": 1 } ], "categories": [ { "name": "Blind" } ] } ], "profile": { "id": "0ceffb3e-10d3-4123-bb42-2a92c93c6e25" }, "viper": { "manufacturerName": "WonderLabs Company", "modelName": "WoCurtain", "hwVersion": "WoCurtain-WoCurtain" }, "type": "VIPER", "restrictionTier": 0 }, { "deviceId": "83babe87-ad78-4056-aa7a-7e203c20f20e", "name": "[AV] Samsung Soundbar Q90R", "label": "[AV] Samsung Soundbar Q90R", "manufacturerName": "Samsung Electronics", "presentationId": "VD-NetworkAudio-001S", "locationId": "8833e7eb-cc2a-406c-9539-7594fed83230", "roomId": "359ddc92-600d-4157-bee4-7d51a6231524", "deviceTypeId": "4f431ad6-8ab8-4a90-a2e3-e87ac4992dd1", "deviceTypeName": "Samsung OCF Network Audio Player", "deviceNetworkType": "UNKNOWN", "components": [ { "id": "main", "label": "[AV] Samsung Soundbar Q90R", "capabilities": [ { "id": "switch", "version": 1 }, { "id": "refresh", "version": 1 }, { "id": "musicPlayer", "version": 1 }, { "id": "ocf", "version": 1 }, { "id": "audioVolume", "version": 1 }, { "id": "execute", "version": 1 }, { "id": "mediaPlaybackShuffle", "version": 1 }, { "id": "audioTrackData", "version": 1 }, { "id": "mediaInputSource", "version": 1 }, { "id": "mediaTrackControl", "version": 1 }, { "id": "audioTrackAddressing", "version": 1 }, { "id": "audioMute", "version": 1 }, { "id": "mediaPlayback", "version": 1 }, { "id": "mediaPlaybackRepeat", "version": 1 } ], "categories": [ { "name": "Other" } ] } ], "dth": { "deviceTypeId": "4f431ad6-8ab8-4a90-a2e3-e87ac4992dd1", "deviceTypeName": "Samsung OCF Network Audio Player", "deviceNetworkType": "UNKNOWN", "completedSetup": false, "networkSecurityLevel": "UNKNOWN", "executingLocally": false }, "type": "DTH", "restrictionTier": 0 }, { "deviceId": "c742fd23-45f1-49b0-98ed-b323a2045feb", "name": "c2c-shade", "label": "keukenraam", "manufacturerName": "SmartThings", "presentationId": "SmartThings-smartthings-c2c-shade", "locationId": "8833e7eb-cc2a-406c-9539-7594fed83230", "roomId": "359ddc92-600d-4157-bee4-7d51a6231524", "components": [ { "id": "main", "capabilities": [ { "id": "windowShade", "version": 1 }, { "id": "switchLevel", "version": 1 }, { "id": "refresh", "version": 1 }, { "id": "healthCheck", "version": 1 } ], "categories": [ { "name": "Blind" } ] } ], "profile": { "id": "0ceffb3e-10d3-4123-bb42-2a92c93c6e25" }, "viper": { "manufacturerName": "WonderLabs Company", "modelName": "WoCurtain", "hwVersion": "WoCurtain-WoCurtain" }, "type": "VIPER", "restrictionTier": 0 }, { "deviceId": "e54fcbb2-99c1-421e-86f5-c7e28f78af2a", "name": "c2c-shade", "label": "terras deur", "manufacturerName": "SmartThings", "presentationId": "SmartThings-smartthings-c2c-shade", "locationId": "8833e7eb-cc2a-406c-9539-7594fed83230", "roomId": "359ddc92-600d-4157-bee4-7d51a6231524", "components": [ { "id": "main", "capabilities": [ { "id": "windowShade", "version": 1 }, { "id": "switchLevel", "version": 1 }, { "id": "refresh", "version": 1 }, { "id": "healthCheck", "version": 1 } ], "categories": [ { "name": "Blind" } ] } ], "profile": { "id": "0ceffb3e-10d3-4123-bb42-2a92c93c6e25" }, "viper": { "manufacturerName": "WonderLabs Company", "modelName": "WoCurtain", "hwVersion": "WoCurtain-WoCurtain" }, "type": "VIPER", "restrictionTier": 0 }, { "deviceId": "04b23049-ff88-47a2-a2bd-9ae54976376f", "name": "c2c-shade", "label": "achterraam", "manufacturerName": "SmartThings", "presentationId": "SmartThings-smartthings-c2c-shade", "locationId": "8833e7eb-cc2a-406c-9539-7594fed83230", "roomId": "359ddc92-600d-4157-bee4-7d51a6231524", "components": [ { "id": "main", "capabilities": [ { "id": "windowShade", "version": 1 }, { "id": "switchLevel", "version": 1 }, { "id": "refresh", "version": 1 }, { "id": "healthCheck", "version": 1 } ], "categories": [ { "name": "Blind" } ] } ], "profile": { "id": "0ceffb3e-10d3-4123-bb42-2a92c93c6e25" }, "viper": { "manufacturerName": "WonderLabs Company", "modelName": "WoCurtain", "hwVersion": "WoCurtain-WoCurtain" }, "type": "VIPER", "restrictionTier": 0 }, { "deviceId": "99500cd9-9ece-4c5b-b452-57727bf8672d", "name": "c2c-shade", "label": "voorraam links", "manufacturerName": "SmartThings", "presentationId": "SmartThings-smartthings-c2c-shade", "locationId": "8833e7eb-cc2a-406c-9539-7594fed83230", "roomId": "359ddc92-600d-4157-bee4-7d51a6231524", "components": [ { "id": "main", "capabilities": [ { "id": "windowShade", "version": 1 }, { "id": "switchLevel", "version": 1 }, { "id": "refresh", "version": 1 }, { "id": "healthCheck", "version": 1 } ], "categories": [ { "name": "Blind" } ] } ], "profile": { "id": "0ceffb3e-10d3-4123-bb42-2a92c93c6e25" }, "viper": { "manufacturerName": "WonderLabs Company", "modelName": "WoCurtain", "hwVersion": "WoCurtain-WoCurtain" }, "type": "VIPER", "restrictionTier": 0 }, { "deviceId": "11d3d0b1-cc4b-43a1-a542-5ee3af8da099", "name": "c2c-shade", "label": "voorraam rechts", "manufacturerName": "SmartThings", "presentationId": "SmartThings-smartthings-c2c-shade", "locationId": "8833e7eb-cc2a-406c-9539-7594fed83230", "roomId": "359ddc92-600d-4157-bee4-7d51a6231524", "components": [ { "id": "main", "capabilities": [ { "id": "windowShade", "version": 1 }, { "id": "switchLevel", "version": 1 }, { "id": "refresh", "version": 1 }, { "id": "healthCheck", "version": 1 } ], "categories": [ { "name": "Blind" } ] } ], "profile": { "id": "0ceffb3e-10d3-4123-bb42-2a92c93c6e25" }, "viper": { "manufacturerName": "WonderLabs Company", "modelName": "WoCurtain", "hwVersion": "WoCurtain-WoCurtain" }, "type": "VIPER", "restrictionTier": 0 } ], "_links": {} }

This is the log which refreshes every 5 seconds:

Please add also an option to select more then 1 device to add, currently you can only select 1 device in the list.

Thx!

AdyRock commented 3 years ago

Ok that looks promising. Could you copy the following: devices/11d3d0b1-cc4b-43a1-a542-5ee3af8da099/components/main/capabilities/windowShade/status

Into the Send Command tab (just below 'For Debug Only' text) and press send, then send me the output. That should show the current state of that capability so I can see the format.

B3rt commented 3 years ago

when i enter command and press 'send' in the send command tab i get an popup: error: [object:object]

AdyRock commented 3 years ago

OK, no problem. I have found a workaround to repurpose the 'switchLevel' when 'windowShade' is detected. So, version 0.0.17 is now in the HCS and should pick up your devices as window covers. I have also got to the bottom of the saving issue with the Bearer Token so a restart is no longer required. And I have also re-enabled the multiple select option when adding devices. I have run it in my simulator but that only checks the basics so let me know if there are any issues.

B3rt commented 3 years ago

Yes i seems to be working! I updated the app and i now can multi select devices and indeed they are now listed as curtains in Homey!

I do have an other request for the app regarding these curtains. Is it possible to add the following IF cards:

I would like to use IF in a flow, so when curtainA is open (=0%) or closed (=100%) THEN ....... (do something) Or use the values to check if the curtain is really open/closed or not etc

Thx again!

ps: will this app be released in the future in the athom store as well?

AdyRock commented 3 years ago

You can do that with the logic variable card and select the tag for the blind position.

I'm not sure if I will submit it to Athom as it is a very open system so I worry there will be lots of special requests. Maybe after I have trickled features in for a while I might reconsider. I'm also trying to get the subscriptions working so that devices notify Homey straight away rather than polling, but Samsung make that very difficult, so I haven't succeeded yet.

Also I have 6 other apps in the Athom store a 3 others in HCS plus a full time job so that keep me very busy.

B3rt commented 3 years ago

Thx, but the problem is that the 0 value is not saved or visible in the logica cards, these are empty when the curtain is 0% (open), when closed (100%) the value is correct shown as value 1 in the logica tags Maybe this can be fixed then?

AdyRock commented 3 years ago

That's strange. The tags are there by default as I use the standard Homey capability. If the curtains are partially open do you see a decimal value, e.g 0.5 if they are half way? I will double check the code to make sure 0 is handled correctly. Can you also confirm from the log if the values from ST are 0 to 100 or 0 to 1?

B3rt commented 3 years ago

It is '100', not 1 but in the logic tags it is displayed as '1' but when 0 the value is empty When i set the curtain to 1% then the tag value is 0.01 this is how the log shows it: "level": { "value": 100, "unit": "%", }"

Sadly the values are not updated when they are NOT changed by Homey. So if you open the curtains using the samsung smartthing app or the original app of the the curtain then the value is not changed in homey. Only when you control the curtain using Homey then the position tag is updated.

AdyRock commented 3 years ago

That's good as I divide the value by 100 and just wanted to confirm that was correct. I need to get a data emulator working so I can test what is happening.

AdyRock commented 3 years ago

I can't see why the tag should be empty for a zero value or why Homey is not updating when a curtains is moved outside of Homey. Could you enable the logging, move the curtains to fully open with SmartThings, wait for at least 5 seconds after they have stopped, move the cover to fully closed with SmartThings, wait at least 5 seconds after they have stopped and then send me the full log. Please don't trim or optimise it in any way. I can then run that data through my new emulator so my app thinks it has received that data and see what path it takes through the code.

B3rt commented 3 years ago

Sorry for the late response. It seems the position values are not the actual live positions but the position where you want the motor to be. So when you change the slider or press open (or close) in the app the value immediately changes into the value according of your choice, a few moments later the motor actually starts to move to the position set...

I hoped that the values where the actual (live) positions of the motor on the rail so you could use them for some logic. For example, if you manually close the curtain by pulling on the curtain the motor starts running and closes it for you. The logic values do not know this, so according to the logic value the curtain is still open but it is actually closed.

About the 0 and empty value, when you print the value 0 in a log it is 0, but when i look into the home app logic values there is no value. maybe it is a 'string' vs an integer problem?

AdyRock commented 3 years ago

The app polls for new values every x seconds, where x is the time defined in the app configuration page. So the values will never be truly live. If SmartThings knows the curtains position has changed then Homey will know within the polling time. The tags are updated at the same time. The values that come back for the position are not in quotes so they are treated as numbers.

B3rt commented 3 years ago

Thx, that is not the case.... The values are not the actual position, but the SET values.

So SET value to 50 means move to the motor to position 50 and not what i was expecting/hoping: The motor is currently at value/position 50.

I know you cannot change this, you handle what is retrieved from smartthing, the problem lay at smartthing, i think they do not retrieve the actual position from the switchbot cloud (switchbot is the brand of the curtain motor) or the switchbot cloud doesn't report the actual position back to smartthings.

I have no idea if i can see or change something in smarttings itself to get the actual position as wel, the original switchbot app does have this information.

But thx alot for adding the curtains, this helped me an others a lot1

AdyRock commented 3 years ago

Ok, that makes sense if SmartThings is not updating. I'm not familiar with the Switchbot curtains. So I presume you mean that pulling the curtains so they move also updates the Switchbot app. How does that app connect to the curtains? How do they connect to SmartThings?

AdyRock commented 3 years ago

I have found an API for the hub and that looks like it can get the position. The limit is 1000 requests per day so it would only update about once per minute as you would need to save some requests for commands.

B3rt commented 3 years ago

once 1 minute is more then enough, how often do people close or open their curtains? haha

But what is this for an api, is it from smartthings or switchbot?

I know that the switchbot manufacturer also has an (open) API, so outside smartthing, the only thing is someone has to create a app for Homey using this api.....

There are a lot of request/demand for it (i am discussing the curtain rails the whole day in some facebook groups) from the Homey community, a lot of users want to order these motors when there was an actual 'native' app for it, they still doubt due to the lack of an actual app.

B3rt commented 3 years ago

How do they connect to SmartThings?

They use i think the official API: https://github.com/OpenWonderLabs/SwitchBotAPI https://github.com/OpenWonderLabs/python-host

See also the demand for an app in from Homey community: https://community.athom.com/t/homey-community-app-requests/2713/8

AdyRock commented 3 years ago

The API is for Switchbot. It requires their hub. The point about the limit is it could take a minute for the status to update after the curtains have been moved.

The link you provided is the one I was looking at.

AdyRock commented 3 years ago

I have ordered a SwitchBot curtain motor and a hub, should be with me tomorrow. So I will have a play and make an app. I will try to connect via BlueTooth first and then the hub.

B3rt commented 3 years ago

Serious, you ordered a switchbot... whoaaaa

I am very exiting about this :)

AdyRock commented 3 years ago

Yes, I have one set of curtains in the house that is not yet automated (in a spare bedroom) so I can put it to good use :-)

AdyRock commented 3 years ago

What Homey firmware version are you using? The app creation wizard now generates code for v5. I could manually make a v4 app but as this will be a brand new app I'm wondering if I should embrace v5?

B3rt commented 3 years ago

Still running as the last official v4 version I am reluctant to update to v5 due to it is still beta/experimental and do no want the risk that apps or flows suddenly do not work anymore... In past I updated to a beta what resulted in a loss of functionality because parts where not working properly yet, since then i try to avoid the beta version for Homey ;)

AdyRock commented 3 years ago

Well, the good news is, I can control the motor using Homey's Bluetooth. The bad news is I can't reliably get the current position. The motor sends the position upon discovery and by notifications. Unfortunately, Homey caches the discovery, so the position is stale, and Homey doesn't support notifications.

I will try via the hub tonight to see if that brings more joy.

B3rt commented 3 years ago

let me know...

Sadly the smartthing app stopped working today, i cannot control any curtain anymore. When i go to detect there is info listed, when enabling log i get log info (see below) but nothing is happening. I restarted the app but that does not change anything.

When i log into the smartting app itself it lists that all motors are offline, that is strange because i can control them using the switchbot app but also using the connection via IFTTT it works, so there is no network connection. The problem seems to be in smartthings, but no idea why or how to fix it.

AdyRock commented 3 years ago

It looks like an issue with SmartThings or Switchbot, as everything is being processed correctly there.

B3rt commented 3 years ago

i removed switchbot from smarttings and re-added it, now it is working again.

Hope there will be a switchbot app, this would be a nice thing, a direct connection and maybe also options like battery power status etc.

AdyRock commented 3 years ago

Progress with the Switchbot app so far: Bluetooth controls the curtains instantly and has battery information. Getting the current data is not good as Homey BLE doesn't support notifications and caches the discovery data which is the only other way to get it.

Hub integration is working but has a 2 to 4 second delay to move the curtains. There's no battery information provided and polling will be limited due to the 1000 API calls per day. So it could take up to a minute to refresh the position in Homey when an external method is used to move them.

B3rt commented 3 years ago

seems good news. The delay is not a big issue, using other methods (itfff or smarrthings) this delay is also present, Regarding the polling, as explained so often you do not close the curtains per day, it would be nice that they are polled after a few seconds when last moved. So for example, i use the app to open/close the curtain, after 10/X seconds or so the position is polled so it can be used in Homey.

If you have a beta app i would glad to test it if it is possible :)

AdyRock commented 3 years ago

I have made a repository for the Switchbot app https://github.com/AdyRock/com.switchbot/issues So we could move discussions about that to there. If you are happy to side load the app via the CLI then it would be good to see what you think.