as a workaround I created a new dummy item for the URL and then created a rule which does the string replacement. The basically does: Cam_Dome_Snapshot_Live.postUpdate( Cam_Dome_Snapshot_Live_Uri_Mjpeg_Http.state.toString.replaceAll("\"", "" ) )
But later I also got the problem with leading 0 where this doesn’t work anymore. So I was further searching for a solution and maybe found (script from here https://forum.iobroker.net/viewtopic.php?t=4101&start=20#p46159) some good one which maybe could also be applied to your solution. The idea is to have a php script which does the authentification inside so the url is somehow static.
<?php
// Configuration
$user = "display"; // Synology user
$pass = "somepassword"; // Password
$ip = "192.168.10.64";
$port = "5000";
$cameraID = $_GET["CamID"]; // ID for the camera
$cameraStream = $_GET["stream"];
// You can change the stream by adding ?stream=0/1/2 to the url. For example: www.yourdomain.com/snapshot.php?stream=2
// 0: Live stream | 1: Recording stream | 2: Mobile stream
// Default value is stream 0
if ($cameraStream == NULL) {
$cameraStream = "0";
}
// Authentification and get SID
$json = file_get_contents('http://'.$ip.':'.$port.'/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account='.$user.'&passwd='.$pass.'&session=SurveillanceStation&format=sid');
$obj = json_decode($json, true);
@$sid = $obj["data"]["sid"];
$Cam_Stream_URL = 'http://'.$ip.':'.$port.'/webapi/SurveillanceStation/videoStreaming.cgi?api=SYNO.SurveillanceStation.VideoStream&version=1&method=Stream&cameraId='.$cameraID.'&format=mjpeg&_sid='.$sid;
//set_time_limit(30);
ob_implicit_flush(1);
$fp = fopen($Cam_Stream_URL, "r");
foreach ($http_response_header as $header) {
header($header);
}
while($str = fgets($fp, 4096))
{
echo $str;
}
?>
Maybe it’s possible also for you to get the SID and deliver a static URL without the StrKey?
Nice idea! As you’re already there, you might just try it yourself. With following replacement in your rule you would convert the static snapshot URI (Surveillance_Snapshot_Uri_Static) into a new dummy item (Surveillance_Snapshot_Live_Uri_Static):
2018-11-04 11:41:38.276 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler SynoBridgeHandler of thing synologysurveillancestation:station:1630mqn415001 tried checking if channel homemode is linked although the handler was already disposed
Glad it worked!
Your warning I haven’t seen yet though. Is your HomeMode channel linked/enabled? If yes, is it functioning properly? Can you see anything wrong at all? When do you receive this message? Every X seconds/minutes, on every Binding/openHab start, on configuration change?
2018-11-22 09:48:32.707 [WARN ] [ome.core.thing.internal.ThingManager] - Initializing handler for thing ‘synologysurveillancestation:camera:42f5d3bc:8’ takes more than 5000ms.
2018-11-22 09:48:35.545 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.synologysurveillancestation.handler.SynoCameraHandler@4ec48’: null
java.lang.NullPointerException: null
at org.openhab.binding.synologysurveillancestation.handler.SynoCameraHandler.updatePatrols(SynoCameraHandler.java:339) [224:org.openhab.binding.synologysurveillancestation:2.4.0.a30]
at org.openhab.binding.synologysurveillancestation.handler.SynoCameraHandler.initialize(SynoCameraHandler.java:191) [224:org.openhab.binding.synologysurveillancestation:2.4.0.a30]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [101:org.eclipse.smarthome.core:0.10.0.oh230]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [101:org.eclipse.smarthome.core:0.10.0.oh230]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
What is your exact question? HomeMode can be used but is not mandatory for anything. Although there are some obscure warnings I couldn’t reproduce, it still should work as intended.
@dafdegiraf could it be that you have no patrols defined? Please try to run this URL (using your IP and your camera ID as shown in camera properties in the binding):
If you have any patrols defined, you should see their list. If not, you will get an error with code 400 (execution failed). In that case you have to disable the corresponding channel for the binding to work.
Actually it should… you’d need to unlink or delete altogether this “Run patrol” item, so it doesn’t there anymore. I would recommend using PaperUI, which is more user friendly in my opinion.
I was able to reproduce your issue: turning Run patrol on put the Thing offline, turning off brings it online back again.
In any case, the binding going down in this case is an obvious error and I thank you for pointing this out! I’ll try to make a hotfix today or this weekend.
@NCO@michelm_de@dafdegiraf
I’ve tried to address your issues, please check the latest release and its notes for more details.
Thanks for reporting, feedback is appreciated!
I have installed the latest release, but i still have the error for my PTZ camera.
My other camera’s are working fine.
I also observed that after installing the binding my openhab is very slow. I can’t even connect remotely to myopenhab.org, it gives me a gateway timeout…
Please ensure that you’re running the latest release only. You can check it in your Karaf by typing bundle:list | grep Syno. There should be but one line with Running state and version a31. Any other / older revisions are to be uninstalled.
In any case you should unlink the channels you’re not using. Even with the new release, linking Patrol channel with no patrols defined will spam your openhab.log with errors, which should not affect the binding functionality anymore though.
Installing and updating the binding could take some time (see 1 above) but running it should not affect the overall performance of openHAB. To keep the load low you should keep your camera Thing’s timeouts reasonable: 10 seconds for snapshots and 3 seconds for events should suffice.
Nothing happening in openHAB should affect the connection to myopenhab. If you’re encountering issues with it, please check the URL in a normal browser first. Sometimes myopenhab.org is just down or overloaded.
As you see, all I can do is to guess wildly. I ask you to provide some corresponding logs and some more information for me to pinpoint your issues.
If you’re also on GitHub I ask you to create an issue there. Otherwise you’re welcome to send me a PM. Let’s try to keep this forum tidy.