Synology Diskstation & Cameras

Are you using a SMS url copied from the setup page of the SmartApp that looks similar to this?

https://graph.api.smartthings.com/api/token/badcaefga-safd-1323-1323-1asdfasde/smartapps/installations/afsdfjwf-dfasdfas-dfwe-tdsfds/DSNotify?user=user&password=pass&to=num&msg=Hello+World

If I use something different like the example in Surveillance Station, then I see the api id and get an error.

I did use the SMS url supplied. no go so far.

Hmm. Iā€™m not sure what is happening here. If you want to message me screenshots of the following screens in Surveillance Station, I can see if notice anything wrong:

  • Add or Edit SMS service provider
  • Notification page / SMS settings once the provider is set up

Having the same issue as @Food4thots - Surveillance Station wants an API ID for the SMS provider. This is with Surveillance Station 7.1-4056.

Thanks!

Also, getting ā€œFailed to save page: motionSetupā€ when trying to go through the set up.

Thanks!

Swanny, first off - THIS IS AWESOME WORK! Your device type is fantastic; way better than the other Foscam device types Iā€™ve tried. Using the Diskstation for motion detection seems to be a reliable system.

However, Iā€™m not getting any images with my PhotoBursts, and, Iā€™m not reliably getting photos from TAKE or Auto take events.

Hereā€™s some logging from one of my cameras:

7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:11 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:11 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:10 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:10 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:09 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:09 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:08 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:08 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:08 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:33:08 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:20 AM: trace image stored = Backyard_e2521ba84127429ca40be2dcd7653223.jpg
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:11 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:11 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:10 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:10 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:10 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:10 AM: trace take picture
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:09 AM: trace sending GetSnapshot
7b2edfd5-90eb-4e77-a159-5fbd07942bf0 10:29:09 AM: trace take picture

And from the PhotoBurst smart app:

0ce98515-b6ab-4147-865f-1f62516fd44f 10:29:08 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 10:01:16 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 9:53:06 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 9:30:02 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 9:28:01 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 9:24:19 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 9:20:05 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 9:10:03 AM: debug motion: active, Someoneā€™s In The Backyard
0ce98515-b6ab-4147-865f-1f62516fd44f 9:02:00 AM: debug motion: active, Someoneā€™s In The Backyard

Finally, i frequently am getting corrupt (tops and bottom of pictures are flipped, scanlines, etc) photos from the TAKE action.

@kje @Food4thots @DjAnu I am not sure why the new Surveillance Station 7.1-4056 is showing the API ID where the previous versions didnā€™t. I am using the same version and I am not seeing the same issue, but I had set up the notifications in the old version. I think they may have a bug in this version of the software that will require a fix. @DjAnu did let me know that downgrading to 7.0.3665 did remove the API ID box and it should work. You could try that if you want or we can wait to see if a new version of the software fixes the issue. Sorry I

@kje Can you go into the IDE to the App Settings for the Diskstation (Connect) SmartApp and see if you have OAuth turned on? If itā€™s not turned on, it may be causing your failed to save page issue.

@Prindle19 As far as your image issue goes, I have seen periodically where the image capability does not work 100% and Iā€™ve seen a small percentage of the images where there is an image format issue. For the photo bursts, are you using the ā€œPhoto Burst When v2ā€¦ā€ SmartApp on my github? I think thatā€™s the only code that may be compatible with these device types. If you are, I would suggest trying a different (maybe smaller) resolution on your camera as a test case. The images go through the hub to Amazon web services and itā€™s not really easy to understand or debug whatā€™s happening in that process from the developer standpoint.

Swanny,

Having a new issue. I removed the cameras from my hub v1 and moved them to hub v2. 4 cameras. One works fine and happens to be a camera that doesnā€™t move. The other 3 wonā€™t take pictures. The other commands work.
I get the following error when i issue the take command.

661b66c5-1cfa-4d22-8c76-9f6cf11fcf56 8:39:41 AM: error java.lang.NullPointerException: Cannot execute null+null @ line 219
661b66c5-1cfa-4d22-8c76-9f6cf11fcf56 8:39:41 AM: trace take picture

Line 219 is sendevent

// handle commands
def take() {
log.trace "take picture"
def lastNum = device.currentState(ā€œtakeImageā€)?.integerValue
sendEvent(name: ā€œtakeImageā€, value: ā€œ${lastNum+1}ā€)
def cameraId = getCameraID()
def hubAction = queueDiskstationCommand_Child(ā€œSYNO.SurveillanceStation.Cameraā€, ā€œGetSnapshotā€, ā€œcameraId=${cameraId}ā€, 1)
hubAction
}

Any help would be appreciated.

Thanks.

So this looks like it is related to camera type. If i use the actual ptz camera type in my case Foscam FI8918W it fails. If I change it to a none ptz model FI8904 than it works. I lose the ptz controls but it will take pictures.

I originally thought it was a child camera issue because when i tried to delete each camera I got an error on the last one that the child could not be found. I changed all 4 camera names and tried again but got the same null error. I than tried changing the type and that worked.

Looking through the logs and code now to see if I can find the error.

Not sure if this is related to something I did or just an issue maybe with the hub updates making us lose some functions. I have tried this on both a hub v1 and v2 and I get the same error. Another factor can be the updated Surveillance Station Software. Now running 7.1 -4058

@swanny First, thank you for this wonderful batch of code! I previously had it running flawlessly in my rather unconventional Synology setup with two D-Link cameras.

As of late, Iā€™ve had everything working great except I was no longer getting motion detection functionality in SmartThings. Iā€™m guessing it tied into either a SmartThings backend update or a Synology Surveillance Station package auto-update.
Just tonight I got motion detection working again by uninstalling Diskstation (Connect) from my hub and reinstalling it. I used the same SMS configuration on Surveillance Station but noticed upon reinstalling the SmartApp that it generated a new URL; as soon as I pasted the new URL in and saved, the test SMS and motion detection functionality (for my first camera) were working again! I noticed a particular difference in the URL was the inclusion of the port (:443) in the address, and Iā€™m wondering if inserting that detail into the original SMS config would have fixed my original issue without the need to uninstall/reinstall.
My second camera however is a D-Link DCS-5010L with PTZ capability. All attempts to Take Picture with this camera since reinstalling tonight get the exact same log error pmanno6 provided in his 11/10/15 post. This cameraā€™s page in SmartThings has also permanently shown Motion since reinstall and is not resetting to No Motion. I pressed the Refresh button and it turned blue and hasnā€™t reset back to grey/white (Iā€™d had this happen before my uninstall also). Every time I press Refresh, I get the following log error:
java.lang.ArrayIndexOutOfBoundsException: Negative array index [-1] too large for array size 0 @ line 1026

I havenā€™t studied your code in depth yet, but my guess based on pmanno6 and my experiences is that something has gotten out of whack with the implementation of (some) PTZ cameras. I would greatly appreciate any thoughts or suggestions you have for me, and let me know if thereā€™s anything else I can provide to help you out.

Just installed this.

I have Surveillance Station 7.1-4058 and have the dialog box for API that kje shows in his screenshot. I just put in ST and it seemed to work ok.

When i do the SMS test, I get a failure. Not sure if that is important?

I did get 2 cameras setup, but when i go to them in SmarthThings, I donā€™t see a live image feed from them, are you supposed to? They are a D-link DCS-7010L and a DCS-932L. I can take an image on the DCS-932L and it will show up in ST. When i try to take an image on the 7010L its formatted pretty weird. It shows the right 2/3 of the image on the left side of the image, then has a vertical split 2/3 of the way from the left where the left 1/3 of the image shows up.

Still, this seems to be a pretty impressive integration and happy that youā€™ve been working on it and happy that the community is showing interest.

BTW: The synology platform is VERY nice and if any of you out there are looking for a good NAS, it is very worth looking at. I have two of them, a 415play at home and a 414+ at work. Both run surveillance station and provide time machine backups. The one at work is a file server for my office and the one at home provides a backup for the work synology and runs Plex. Iā€™ve yanked drives from both of them to test the Raid recovery, both have done what they are supposed to do and rebuilt without data loss.

Sorry for the delay in responding. I was out of the country last week.

@pmanno6 @cmamatey In regards to your error taking images, I tried a new install on my hub v2 and I wasnā€™t able to reproduce your issue. Iā€™ve made a change to the DeviceType to see if I can correct the error. Can you try that out?

If it doesnā€™t work, can one of you guys try running through the SmartApp setup process again with the latest SmartApp and DeviceType? You donā€™t need to fully uninstall, just update the code and rerun the SmartApp setup.

@cmamatey I updated the SmartApp code to fix the refresh error for Negative array index. ST has been changing some things in the backend which probably caused the port to change. You shouldnā€™t need to uninstall and reinstall the app to fix that issue if you see it happen again. I think you can just run through the SmartApp setup process again.

@Arlo_Miller This integration does not support live viewing. ST has not made this capability available to developers yet. As for your split image, do you know what resolution that camera is set to? You could try changing the resolution and see if that fixes the issue.

I updated both the device and app with the latest code. Not getting any response from the commands. No movement, no pics. Same result on all 4.
Thanks again for looking at this.
Camera log.
5e7b47b9-7351-47de-b664-c4eb545375d1 12:49:03 PM: trace sending Move
5e7b47b9-7351-47de-b664-c4eb545375d1 12:49:03 PM: trace could not find device DNI = Drive
5e7b47b9-7351-47de-b664-c4eb545375d1 12:49:03 PM: trace move
5e7b47b9-7351-47de-b664-c4eb545375d1 12:45:09 PM: trace sending GetSnapshot
5e7b47b9-7351-47de-b664-c4eb545375d1 12:45:09 PM: trace could not find device DNI = Drive
5e7b47b9-7351-47de-b664-c4eb545375d1 12:45:08 PM: trace take picture

app log
cbab513f-c484-40e8-af8b-40406c01fe6a 12:49:03 PM: trace {ā€œerrorā€:{ā€œcodeā€:105},ā€œsuccessā€:false}
cbab513f-c484-40e8-af8b-40406c01fe6a 12:49:03 PM: trace DISKSTATION REPONSE TYPE: Content-Type: application/json; charset="UTF-8"
cbab513f-c484-40e8-af8b-40406c01fe6a 12:48:35 PM: trace Did not use

Swanny.

I reran the setup again and got better results. Looks to be working now. This is great stuff. Thanks!

5e7b47b9-7351-47de-b664-c4eb545375d1 2:02:51 PM: trace image stored = Drive_dae9aa0a2b3945ffbbddf860659f1fb7.jpg
5e7b47b9-7351-47de-b664-c4eb545375d1 2:02:45 PM: trace sending GetSnapshot
5e7b47b9-7351-47de-b664-c4eb545375d1 2:02:45 PM: trace take picture
5e7b47b9-7351-47de-b664-c4eb545375d1 2:02:38 PM: trace image stored = Drive_75480c8f400747999d126d03f31f2708.jpg
5e7b47b9-7351-47de-b664-c4eb545375d1 2:02:35 PM: trace sending GetSnapshot
5e7b47b9-7351-47de-b664-c4eb545375d1 2:02:35 PM: trace take picture
5e7b47b9-7351-47de-b664-c4eb545375d1 1:59:19 PM: trace sending GetSnapshot
5e7b47b9-7351-47de-b664-c4eb545375d1 1:59:19 PM: trace take picture
5e7b47b9-7351-47de-b664-c4eb545375d1 1:56:41 PM: trace image stored = Drive_9855e338ee2c4ab1a713610caa53c20f.jpg
5e7b47b9-7351-47de-b664-c4eb545375d1 1:56:35 PM: trace sending GetSnapshot
5e7b47b9-7351-47de-b664-c4eb545375d1 1:56:35 PM: trace take picture

@swanny I pasted in the latest code tonight, published ā€˜for meā€™, and both issues appear resolved. Didnā€™t even need to run the setup again. Thanks!

I only resorted to uninstall/reinstall earlier because nothing else was working for me. I mentioned the port number because in the old link I had previously configured, no port number was given; I think the inclusion of the port number was the solution to my lack of motion detection.
Anyone having issues with motion detection from their previous existing configurations, I suggest updating your code and making sure the SMS notification URL includes the port number :443

Iā€™m new to ST and I was able to port over the most recent code from this thread. ST saw both my cameras on the disk station and imported them fine. But Iā€™m getting the API ID issue that other people are seeing when trying to configure the motion detection. Iā€™m using the most up to date surveillance station 7.1. Iā€™m using hikvision IP cameras. One potential issue i thought of was the DS recording method, either from camera or the DS. I use the DS for triggering the motion so I donā€™t think thatā€™s my issue. Anyone have any insight?

I havenā€™t been able to reproduce the issue locally, so Iā€™m not sure how to fix it. However, my Surveillance Station was updated today to 7.1-4080. If you havenā€™t tried already, I would try again with that one in case a bug was fixed. You could also try entering a couple numbers in the API ID field and see if it will still send.

Still no luck after reinstalling, but I think I got it working or at least made the API ID field disappear. In the URL I replaced the + in ā€œHello+Worldā€ with a space.

Great. If it doesnā€™t bring up the field, hopefully you are ok. Are you seeing motion alerts now?

Just verified I am seeing the the motion in logs. Great app, thanks for the help!