Dropbox configuration with OH2

Could share your background knowledge? it seems that this already happend before and was actually fixed: https://github.com/openhab/openhab1-addons/issues/4588 . I cant reproduce the problem, its working fine on my side…

@eugenluft I will try to look into this as soon as I find the time.

1 Like

The way it should work is that if the user configures a personalAccessToken, it gets used instead of the old “official” OH app. It sounds like, in this case, the app is still being used instead. Users should make sure to update their configs to comment out the original appkey/appsecret settings.

Thanks for the info. Actually theres already a logic implemented to always use the personalAccessToken, if its provided. That was the fix for the opened issue mentioned above.

@eugenluft could you double check your config and comment out the appkey / appsecret lines?
For example, my dropbox.cfg looks like this:

############################# Dropbox configuration ###################################
#
# Authentication: either the personalAccessToken must be configured, or BOTH
# the AppKey and AppSecret must be configured. If all three are configured,
# the personalAccessToken will be used and the others will be ignored.

# The generated access token from the Dropbox app created by the user (required)
personalAccessToken=yourPersonalAccessToken

# the AppKey, AppSecret combination (both required)
#appkey=
#appsecret=

# If set to true, operates the Synchronizer in fake mode, which does not upload
# or download files to/from Dropbox.  This is meant as a test mode for the
# filter settings (optional; defaults to false)
fakemode=false

# The upload and download interval as a Cron Expression. See the Quartz
# Tutorial at http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06
# for more information (optional; defaults to '0 0/5 * * * ?', which means
# every 5 minutes)
uploadInterval=0 0 2 * * ?
#downloadInterval=

# Defines how files are synchronized with Dropbox. Valid SyncMode values are
# 'DROPBOX_TO_LOCAL', 'LOCAL_TO_DROPBOX', and 'BIDIRECTIONAL' (optional;
# defaults to 'LOCAL_TO_DROPBOX')
#syncmode=

# The base directory to synchronize with openHAB (optional; defaults to '.')
#contentdir=

# The dropbox base directory for uploading the contendir matches
dropboxdir=/openhab2

# Defines a comma separated list of regular expressions which matches the
# filenames to upload to Dropbox (optional; defaults to '/configurations/.*,
# /logs/.*, /etc/.*')
uploadfilter=(.*?)

# Defines a comma separated list of regular expressions which matches the
# filenames to download from Dropbox (optional; defaults to '/configurations/.*')
#downloadfilter=

if you still face issues, you could enable debug logging for the binding (openhabian way):

  1. enter command openhab-cli console with default password habopen
  2. enter command log:set DEBUG org.openhab.io.dropbox
  3. enter command logout
1 Like

@bennYx0x I don’t mean to hijack the thread but I have a question about the uploadfilter setting -
When I use your setting uploadfilter=(.*?) everything is uploaded to Dropbox as expected but I am trying to restrict the synced files to only a few folders.
I am running on windows and my folder structures is like this:

D:\OpenHAB2\items
D:\OpenHAB2\rules
D:\OpenHAB2\sounds

If I want to sync only the ‘items’ and ‘rules’ folders what would I enter as the value of the uploadfilter setting?
I have tried all sorts of things but have not got it to work.

Thanks

@bennYx0x
First of all thanks a lot for your fast replies.
Unfortunately i run in a new issue :frowning:

2018-03-31 23:01:23.315 [INFO ] [b.io.dropbox.internal.DropboxService] - Authentication parameters to be used:

     Personal access token = *MY PERSONAL TOKEN WITH FULL ACCESS TO DB*

2018-03-31 23:01:23.370 [DEBUG] [dropbox.internal.DropboxSynchronizer] - contentdir: /etc/openhab2/

2018-03-31 23:01:23.404 [DEBUG] [dropbox.internal.DropboxSynchronizer] - dropboxdir: /openhab2

2018-03-31 23:01:23.428 [DEBUG] [b.io.dropbox.internal.DropboxService] - Dropbox Uploadfilter: (.*?)

2018-03-31 23:01:23.454 [DEBUG] [b.io.dropbox.internal.DropboxService] - Dropbox I/O is properly configured. Activating synchronizer.

2018-03-31 23:01:23.500 [DEBUG] [b.io.dropbox.internal.DropboxService] - Found 1 synchronization jobs to delete from DefaultScheduler (keys=[Dropbox.Upload])

2018-03-31 23:01:23.535 [DEBUG] [b.io.dropbox.internal.DropboxService] - Authenticated. Scheduling jobs.

2018-03-31 23:01:23.557 [DEBUG] [b.io.dropbox.internal.DropboxService] - Scheduling LOCAL_TO_DROPBOX upload interval: 0 0/2 * * * ?

2018-03-31 23:01:23.605 [DEBUG] [b.io.dropbox.internal.DropboxService] - Scheduled synchronization job (direction=Upload) with cron expression '0 0/2 * * * ?'

2018-03-31 23:02:00.016 [ERROR] [org.quartz.core.JobRunShell         ] - Job Dropbox.Upload threw an unhandled Exception: 

java.lang.ClassCastException: com.dropbox.core.v2.DbxClientV2 cannot be cast to com.dropbox.core.v2.DbxClientV2

	at org.openhab.io.dropbox.internal.DropboxService$SynchronizationJob.execute(DropboxService.java:430) [224:org.openhab.io.dropbox:1.12.0.201803221546]

	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]

	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]

2018-03-31 23:02:00.058 [ERROR] [org.quartz.core.ErrorLogger         ] - Job (Dropbox.Upload threw an exception.

org.quartz.SchedulerException: Job threw an unhandled exception.

	at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]

	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]

Caused by: java.lang.ClassCastException: com.dropbox.core.v2.DbxClientV2 cannot be cast to com.dropbox.core.v2.DbxClientV2

	at org.openhab.io.dropbox.internal.DropboxService$SynchronizationJob.execute(DropboxService.java:430) ~[?:?]

	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ~[?:?]

	... 1 more

Hey,

you just have to restart openhab, that will fix the issue.

Cheers

1 Like

Unfortunately not :frowning:
I have tried following script to upload my conf to Dropbox:
GitHub DropBox Uploader
and this works very well with my personalAccessToken and a cronjob.

In the end i can live with this “work-around” but in the end it would be great to have your plugin working.

Do you have the original version still installed via paperui? Make sure the binding is removed everywhere, restart openhab and put the jar file again in the addons folder. Via quartz an object is put into cache and it seems you got an old object hanging there around.

@mcqwerty take a look into the dropbox binding documentation page, there you will find the default value for upload filter. The default value was made for some folders, therefore you should be able to adjust it for your needs.

Thanks for the reply, I have already tried all of the examples in the documentation including plenty of other variations and everything I could think of.

I am running on Windows.
I am trying to upload only the contents of the ‘items’ and ‘rules’ folders located here: 'D:\OpenHAB2\conf'

Based on the documentation, one of the things I have tried is: uploadfilter=/rules/.*, /items/.*

I then see this in the log:

01-Apr-2018 09:48:35.273 [DEBUG] [rg.openhab.io.dropbox.internal.DropboxSynchronizer] - contentdir: D:\OpenHAB2\conf
01-Apr-2018 09:48:35.274 [DEBUG] [rg.openhab.io.dropbox.internal.DropboxSynchronizer] - dropboxdir: /OpenHAB2
01-Apr-2018 09:48:35.274 [DEBUG] [org.openhab.io.dropbox.internal.DropboxService    ] - Dropbox Uploadfilter: rules/.*, /items/.*

followed by:

01-Apr-2018 09:49:06.233 [TRACE] [rg.openhab.io.dropbox.internal.DropboxSynchronizer] - Skipped file 'D:\OpenHAB2\conf\items' since it doesn't match the given filter arguments.
01-Apr-2018 09:49:06.234 [TRACE] [rg.openhab.io.dropbox.internal.DropboxSynchronizer] - Skipped file 'D:\OpenHAB2\conf\rules' since it doesn't match the given filter arguments.

Can anyone share a working version of their ‘uploadfilter’ settings where you have filtered the upload to subfolders of the ‘contentdir’ directory.

Thanks

The Addon makes me crazy…
After few restarts and re-installations of 1.12 i´m back with the origin error
2018-04-01 23:45:48.030 [DEBUG] [b.io.dropbox.internal.DropboxService] - Scheduled synchronization job (direction=Upload) with cron expression ‘0 0/2 * * * ?’

2018-04-01 23:46:00.063 [DEBUG] [dropbox.internal.DropboxSynchronizer] - Started synchronization from local to Dropbox ...

2018-04-01 23:46:02.286 [WARN ] [al.DropboxService$SynchronizationJob] - Synchronizing data with Dropbox threw an exception

com.dropbox.core.BadRequestException: Error in call to API function "files/list_folder": This app is currently disabled.

	at com.dropbox.core.DbxRequestUtil.unexpectedStatus(DbxRequestUtil.java:298) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:115) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:284) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:102) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:1416) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:1466) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at org.openhab.io.dropbox.internal.DropboxSynchronizer.syncLocalToDropbox(DropboxSynchronizer.java:219) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at org.openhab.io.dropbox.internal.DropboxService$SynchronizationJob.execute(DropboxService.java:446) [228:org.openhab.io.dropbox:1.12.0.201803221546]

	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]

	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [115:org.eclipse.smarthome.core.scheduler:0.10.0.b1]

Here the steps i did:

  1. Created a new full access APP in Dropbox

  2. Entered the privateToken in the dropbox.cfg file

  3. Check the log:

    2018-04-01 23:40:57.493 [INFO ] [b.io.dropbox.internal.DropboxService] - #########################################################################################

    2018-04-01 23:40:57.517 [INFO ] [b.io.dropbox.internal.DropboxService] - # Starting auth using personal access token

    2018-04-01 23:40:57.536 [INFO ] [b.io.dropbox.internal.DropboxService] - #########################################################################################

    2018-04-01 23:40:57.571 [DEBUG] [hab.io.dropbox.internal.DropboxUtils] - Created file ‘/var/lib/openhab2/dropbox/authfile.dbx’ with content ‘MYTOKEN’

    2018-04-01 23:40:57.612 [DEBUG] [b.io.dropbox.internal.DropboxService] - Found 1 synchronization jobs to delete from DefaultScheduler (keys=[Dropbox.Upload])

    2018-04-01 23:40:57.637 [DEBUG] [b.io.dropbox.internal.DropboxService] - Authenticated. Scheduling jobs.

  4. Same token works in the upload-script.