-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FTP Upload binding #3137
Merged
kaikreuzer
merged 38 commits into
openhab:master
from
paulianttila:NetworkCameraMotionDetectionBinding
May 9, 2018
Merged
FTP Upload binding #3137
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
1aa36ce
Initial commit for NetworkCameraMotionDetectionBinding
paulianttila 1617930
Added README.md
paulianttila e166c93
Added about.html
paulianttila 33be6fc
Removed language property file
paulianttila 24961c8
Renamed thing type from NetworkCamera to networkcamera
paulianttila ee16732
Updated Ftp server and mina libraries
paulianttila 5acb7e3
Fixed logging
paulianttila 7c6d4c3
Added FTP server logging instructions
paulianttila fa83406
Few minor fixes
paulianttila 7bf4303
Minor fixes
paulianttila 4c0f0ec
Minor fixes
paulianttila 7841816
Minor fixes
paulianttila 6721920
Fixed readme
paulianttila 070a22c
Improvements
paulianttila 6567b5e
Improvements
paulianttila 5d3e1a7
Renamed binding to networkcamera
paulianttila 14f604f
Updated headers
paulianttila 9c53c61
Added missing new line
paulianttila b8a93e1
Reformatted xml
paulianttila 999d9fd
Make Martin happy
paulianttila 8420875
Renamed directory
paulianttila e25f6c4
Code review and other fixes
paulianttila a52ba91
Use DS annotations
paulianttila f35024f
Removed motion channel
paulianttila 41626d2
Divided FTP server private classes to own classes
paulianttila 506ebb1
More fixes
paulianttila c932bdd
Modified callback function execution
paulianttila 98a1cb8
Added binding to build
paulianttila 8bd3452
Throw exception if FTP server start fails
paulianttila e63481e
Improved thing status handling when FTP server startup fails
paulianttila 5b9568c
Added support for custom channels
paulianttila 28f384d
Renamed binding to ftpupload
paulianttila aa7a6e6
Fixed thing type
paulianttila 4e534f1
Code review fixes
paulianttila 3db01a0
Typo fixes
paulianttila 98d6594
Code review fixes
paulianttila 8641dd8
Added binding to features
paulianttila 9e3ce04
Spaces to tabs
paulianttila File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="lib" path="lib/ftplet-api-1.1.0.jar"/> | ||
<classpathentry kind="lib" path="lib/ftpserver-core-1.1.0.jar"/> | ||
<classpathentry kind="lib" path="lib/mina-core-2.0.16.jar"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>org.openhab.binding.ftpupload</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ds.core.builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
22 changes: 22 additions & 0 deletions
22
addons/binding/org.openhab.binding.ftpupload/ESH-INF/binding/binding.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<binding:binding id="ftpupload" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0" | ||
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd"> | ||
|
||
<name>FTP Upload Binding</name> | ||
<description>This binding is for receiving files via FTP.</description> | ||
<author>Pauli Anttila</author> | ||
|
||
<config-description> | ||
<parameter name="port" type="integer" min="1" max="65335"> | ||
<label>TCP Port</label> | ||
<description>TCP port of the FTP server</description> | ||
<default>2121</default> | ||
</parameter> | ||
<parameter name="idleTimeout" type="integer" min="0" max="65335"> | ||
<label>Idle timeout</label> | ||
<description>The number of seconds before an inactive client is disconnected. If this value is set to 0, the idle time is disabled.</description> | ||
<default>60</default> | ||
</parameter> | ||
</config-description> | ||
</binding:binding> |
59 changes: 59 additions & 0 deletions
59
addons/binding/org.openhab.binding.ftpupload/ESH-INF/thing/thing-types.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<thing:thing-descriptions bindingId="ftpupload" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0" | ||
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd"> | ||
|
||
<thing-type id="imagereceiver" extensible="image-channel, image-received"> | ||
<label>Image Receiver</label> | ||
<description>Receive image files via FTP.</description> | ||
|
||
<channels> | ||
<channel id="image" typeId="image-channel" /> | ||
<channel id="image-received" typeId="image-received" /> | ||
</channels> | ||
|
||
<config-description> | ||
<parameter name="userName" type="text" required="true"> | ||
<label>User Name</label> | ||
<description>Username</description> | ||
</parameter> | ||
<parameter name="password" type="text" required="true"> | ||
<label>Password</label> | ||
<description>Password</description> | ||
<context>password</context> | ||
</parameter> | ||
</config-description> | ||
</thing-type> | ||
|
||
<channel-type id="image-channel"> | ||
<item-type>Image</item-type> | ||
<label>Image</label> | ||
<description>Image received via FTP</description> | ||
<state readOnly="true"></state> | ||
<config-description> | ||
<parameter name="filename" type="text" required="true"> | ||
<label>Filename</label> | ||
<description>Filename to match received files. Supports regular expression patterns.</description> | ||
<default>.*</default> | ||
</parameter> | ||
</config-description> | ||
</channel-type> | ||
<channel-type id="image-received"> | ||
<kind>trigger</kind> | ||
<label>Image file received trigger channel</label> | ||
<event> | ||
<options> | ||
<option value="IMAGE_RECEIVED">Image received</option> | ||
</options> | ||
</event> | ||
<config-description> | ||
<parameter name="filename" type="text" required="true"> | ||
<label>Filename</label> | ||
<description>Filename to match received files. Supports regular expression patterns.</description> | ||
<default>.*</default> | ||
</parameter> | ||
</config-description> | ||
</channel-type> | ||
|
||
</thing:thing-descriptions> |
29 changes: 29 additions & 0 deletions
29
addons/binding/org.openhab.binding.ftpupload/META-INF/MANIFEST.MF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ActivationPolicy: lazy | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: FTP Upload Binding | ||
Bundle-SymbolicName: org.openhab.binding.ftpupload;singleton:=true | ||
Bundle-Vendor: openHAB | ||
Bundle-Version: 2.3.0.qualifier | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8 | ||
Bundle-ClassPath: ., | ||
lib/ftplet-api-1.1.0.jar, | ||
lib/ftpserver-core-1.1.0.jar, | ||
lib/mina-core-2.0.16.jar | ||
Export-Package: | ||
org.openhab.binding.ftpupload, | ||
org.openhab.binding.ftpupload.handler | ||
Import-Package: | ||
org.apache.commons.lang, | ||
org.eclipse.jdt.annotation;resolution:=optional, | ||
org.eclipse.smarthome.config.core, | ||
org.eclipse.smarthome.core.library.types, | ||
org.eclipse.smarthome.core.thing, | ||
org.eclipse.smarthome.core.thing.binding, | ||
org.eclipse.smarthome.core.thing.binding.builder, | ||
org.eclipse.smarthome.core.thing.type, | ||
org.eclipse.smarthome.core.types, | ||
org.eclipse.smarthome.io.net.http, | ||
org.osgi.service.component, | ||
org.slf4j | ||
Service-Component: OSGI-INF/*.xml |
1 change: 1 addition & 0 deletions
1
addons/binding/org.openhab.binding.ftpupload/OSGI-INF/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
# FTP Upload Binding | ||
|
||
This binding can be used to receive image files from FTP clients. | ||
The binding acts as a FTP server. | ||
Images stored on the FTP server are not saved to the file system, therefore the binding shouldn't cause any problems on flash based openHAB installations. | ||
|
||
## Supported Things | ||
|
||
This binding supports Things of type ```ftpupload```. | ||
Every Thing is identified by FTP user name. | ||
Therefore, every thing should use unique user name to login FTP server. | ||
|
||
## Discovery | ||
|
||
Automatic discovery is not supported. | ||
|
||
## Binding Configuration | ||
|
||
The binding has the following configuration options: | ||
|
||
| Parameter | Name | Description | Required | Default value | | ||
|-------------|--------------|------------------------------------------------------------------------------------------------------------------------|----------|---------------| | ||
| port | TCP Port | TCP port of the FTP server | no | 2121 | | ||
| idleTimeout | Idle timeout | The number of seconds before an inactive client is disconnected. If this value is set to 0, the idle time is disabled. | no | 60 | | ||
|
||
## Channels | ||
|
||
This binding currently supports the following channels: | ||
|
||
| Channel Type ID | Item Type | Description | | ||
|-----------------|--------------|----------------------------------------------------------------------------------------| | ||
| image | Image | Image file received via FTP. | | ||
|
||
When an image file is uploaded to FTP server, the binding tries to find the channel whose filename matches the uploaded image filename. | ||
If no match is found, no channel is updated. | ||
The filename parameter supports regular expression patterns. | ||
See more details in the Things example. | ||
|
||
Image channel supports following options: | ||
|
||
| Parameter | Name | Description | Required | Default value | | ||
|-------------|--------------|--------------------------------------------------------------------------|----------|---------------| | ||
| filename | Filename | Filename to match received files. Supports regular expression patterns. | yes | .* | | ||
|
||
|
||
### Trigger Channels | ||
|
||
| Channel Type ID | Options | Description | | ||
|-----------------|------------------------|-----------------------------------------------------| | ||
| image-received | IMAGE_RECEIVED | Triggered when image file received from FTP client. | | ||
|
||
When an image file is uploaded to FTP server, the binding tries to find the trigger channel whose filename matches the upload image filename. | ||
If no match is found, no channel is updated. | ||
The filename parameter supports regular expression patterns. | ||
See more details in the Things example. | ||
|
||
Trigger channels supports following options: | ||
|
||
| Parameter | Name | Description | Required | Default value | | ||
|-------------|--------------|--------------------------------------------------------------------------|----------|---------------| | ||
| filename | Filename | Filename to match received files. Supports regular expression patterns. | yes | .* | | ||
|
||
## Full Example | ||
|
||
Things: | ||
|
||
``` | ||
Thing ftpupload:imagereceiver:images1 [ userName="test1", password="12345" ] { | ||
|
||
Thing ftpupload:imagereceiver:images2 [ userName="test2", password="12345" ] { | ||
Channels: | ||
Type image-channel : my_image1 "My Image channel 1" [ | ||
filename="test12[0-9]{2}.png" // match to filename test12xx.png, where xx can be numbers between 00-99 | ||
] | ||
Type image-channel : my_image2 "My Image channel 2" [ | ||
filename="test.jpg" | ||
] | ||
Trigger String : my_image_trigger1 [ | ||
filename="test12[0-9]{2}.png" | ||
] | ||
Trigger String : my_image_trigger2 [ | ||
filename="test.jpg" | ||
] | ||
} | ||
``` | ||
|
||
Items: | ||
|
||
``` | ||
Image Image1 { channel="ftpupload:imagereceiver:images1:image" } | ||
Image Image2 { channel="ftpupload:imagereceiver:images2:my_image1" } | ||
``` | ||
|
||
Rules: | ||
|
||
``` | ||
rule "example trigger rule 1" | ||
when | ||
Channel 'ftpupload:imagereceiver:images1:image-received' triggered IMAGE_RECEIVED | ||
then | ||
logInfo("Test","Image received") | ||
end | ||
|
||
rule "example trigger rule 2" | ||
when | ||
Channel 'ftpupload:imagereceiver:images2:my_image_trigger1' triggered IMAGE_RECEIVED | ||
then | ||
logInfo("Test","Image received") | ||
end | ||
|
||
``` | ||
|
||
Sitemap: | ||
|
||
``` | ||
Frame label="FTP images" { | ||
Image item=Image1 | ||
Image item=Image2 | ||
} | ||
``` | ||
|
||
## Use case example | ||
|
||
The binding can be used to receive images from network cameras that send images to a FTP server when motion or sound is detected. | ||
|
||
Things: | ||
|
||
``` | ||
Thing ftpupload:imagereceiver:garagecamera [ userName="garage", password="12345" ] | ||
``` | ||
|
||
Items: | ||
|
||
``` | ||
Image Garage_NetworkCamera_Motion_Image { channel="ftpupload:imagereceiver:garagecamera:image" } | ||
``` | ||
|
||
Rules: | ||
|
||
``` | ||
rule "example trigger rule" | ||
when | ||
Channel 'ftpupload:imagereceiver:garagecamera:image-received' triggered IMAGE_RECEIVED | ||
then | ||
logInfo("Test","Garage motion detected") | ||
end | ||
``` | ||
|
||
Sitemap: | ||
|
||
``` | ||
Frame label="Garage network camera" icon="camera" { | ||
Image item=Garage_NetworkCamera_Motion_Image | ||
} | ||
``` | ||
|
||
## Logging and Problem Solving | ||
|
||
For problem solving, if binding logging is not enough, Apache FTP server logging can also be enabled by the following command in the karaf console: | ||
|
||
``` | ||
log:set DEBUG org.apache.ftpserver | ||
``` | ||
|
||
and set back to default level: | ||
|
||
``` | ||
log:set DEFAULT org.apache.ftpserver | ||
``` | ||
|
||
If you meet any problems to receive images from the network cameras, you could test connection to binding with any FTP client. | ||
You can send image files via FTP client and thing channels should be updated accordingly. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> | ||
<title>About</title> | ||
</head> | ||
<body lang="EN-US"> | ||
<h2>About This Content</h2> | ||
|
||
<p>Nov 10, 2016</p> | ||
<h3>License</h3> | ||
|
||
<p>The openHAB community makes available all content in this plug-in ("Content"). Unless otherwise | ||
indicated below, the Content is provided to you under the terms and conditions of the | ||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available | ||
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. | ||
For purposes of the EPL, "Program" will mean the Content.</p> | ||
|
||
<p>If you did not receive this Content directly from the openHAB community, the Content is | ||
being redistributed by another party ("Redistributor") and different terms and conditions may | ||
apply to your use of any object code in the Content. Check the Redistributor's license that was | ||
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise | ||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content | ||
and such source code may be obtained at <a href="http://www.openhab.org/">openhab.org</a>.</p> | ||
|
||
|
||
<h3>Third Party Content</h3> | ||
<p>The Content includes items that have been sourced from third parties as set out below. If you | ||
did not receive this Content directly from the openHAB community, the following is provided | ||
for informational purposes only, and you should look to the Redistributor's license for | ||
terms and conditions of use.</p> | ||
<p><em> | ||
<strong>Apache MINA</strong> <br/><br/> | ||
<a href="http://mina.apache.org">Apache MINA</a> under | ||
<a href="http://www.apache.org/licenses/">Apache License</a>. | ||
</em></p> | ||
<p><em> | ||
<strong>Apache FtpServer</strong> <br/><br/> | ||
<a href="https://mina.apache.org/ftpserver-project/">Apache FtpServer</a> under | ||
<a href="http://www.apache.org/licenses/">Apache License</a>. | ||
</em></p> | ||
<p><em> | ||
<strong>Apache Ftplet</strong> <br/><br/> | ||
<a href="https://mina.apache.org/ftpserver-project/ftplet.html">Apache Ftplet</a> under | ||
<a href="http://www.apache.org/licenses/">Apache License</a>. | ||
</em></p> | ||
</body> | ||
</html> |
10 changes: 10 additions & 0 deletions
10
addons/binding/org.openhab.binding.ftpupload/build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
source.. = src/main/java/ | ||
output.. = target/classes | ||
bin.includes = META-INF/,\ | ||
.,\ | ||
OSGI-INF/,\ | ||
ESH-INF/,\ | ||
about.html,\ | ||
lib/ftplet-api-1.1.0.jar,\ | ||
lib/ftpserver-core-1.1.0.jar,\ | ||
lib/mina-core-2.0.16.jar |
Binary file added
BIN
+21.8 KB
addons/binding/org.openhab.binding.ftpupload/lib/ftplet-api-1.1.0.jar
Binary file not shown.
Binary file added
BIN
+295 KB
addons/binding/org.openhab.binding.ftpupload/lib/ftpserver-core-1.1.0.jar
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You include 3 jars, so it would be good to have also 3 entries here - to me it is not clear, where ftpled comes from (FTP Server or from MINA?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done