├── .classpath
├── .gitignore
├── CHANGELOG.md
├── HEADER.txt
├── LICENSE-3RD-PARTY.txt
├── LICENSE.txt
├── README.md
├── doc
└── BMWi_4C_Gef_en.jpg
├── pom.xml
└── src
└── main
└── java
└── de
└── fh_zwickau
└── informatik
└── sensor
├── IZWayApi.java
├── IZWayApiCallbacks.java
├── IZWayApiWebSocketCallbacks.java
├── IZWayCallback.java
├── ZWayApiBase.java
├── ZWayApiHttp.java
├── ZWayApiWebSocket.java
├── ZWayConstants.java
└── model
├── devicehistory
├── DeviceHistory.java
├── DeviceHistoryData.java
├── DeviceHistoryList.java
└── DeviceHistoryListDeserializer.java
├── devices
├── Color.java
├── Device.java
├── DeviceCommand.java
├── DeviceList.java
├── DeviceListDeserializer.java
├── IDeviceCommands.java
├── Icons.java
├── IconsLevel.java
├── Metrics.java
└── types
│ ├── Battery.java
│ ├── Camera.java
│ ├── Doorlock.java
│ ├── SensorBinary.java
│ ├── SensorDiscrete.java
│ ├── SensorMultilevel.java
│ ├── SensorMultiline.java
│ ├── SwitchBinary.java
│ ├── SwitchControl.java
│ ├── SwitchMultilevel.java
│ ├── SwitchRGBW.java
│ ├── SwitchToggle.java
│ ├── Text.java
│ ├── Thermostat.java
│ └── ToggleButton.java
├── icons
├── Icon.java
├── IconList.java
└── IconListDeserializer.java
├── instances
├── Instance.java
├── InstanceList.java
├── InstanceListDeserializer.java
├── dummydevice
│ ├── DummyDevice.java
│ └── DummyDeviceParams.java
└── openhabconnector
│ ├── OpenHABConnector.java
│ ├── OpenHABConnectorParams.java
│ ├── OpenHABConnectorParamsCommonOptions.java
│ └── OpenHabConnectorZWayServer.java
├── locations
├── Location.java
├── LocationList.java
└── LocationListDeserializer.java
├── login
└── LoginForm.java
├── modules
├── Module.java
└── ModuleList.java
├── namespaces
├── Namespace.java
└── NamespaceList.java
├── notifications
├── Message.java
├── Notification.java
├── NotificationList.java
└── NotificationListDeserializer.java
├── profiles
├── Profile.java
├── ProfileList.java
└── ProfileListDeserializer.java
├── system
└── SystemInfo.java
└── zwaveapi
├── ZWaveDataElement.java
├── controller
├── ZWaveController.java
└── ZWaveControllerData.java
└── devices
├── ZWaveDevice.java
├── ZWaveDeviceData.java
├── ZWaveDeviceInstance.java
├── ZWaveDeviceInstanceCommandClass64.java
├── ZWaveDeviceInstanceCommandClass64Data.java
├── ZWaveDeviceInstanceCommandClass64DataMode.java
├── ZWaveDeviceInstanceCommandClasses.java
├── ZWaveDeviceInstanceData.java
└── ZWaveDeviceInstances.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | .settings
3 | .project
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](http://keepachangelog.com/)
5 | and this project adheres to [Semantic Versioning](http://semver.org/).
6 |
7 | ## [0.2.8] - 2017-05-01
8 | ### Added
9 | - Z-Way API function (getSystemInfo) to load current firmware version
10 |
11 | ## [0.2.7] - 2017-04-09
12 | ### Added
13 | - Sensor discrete device type
14 | - Sensor multiline device type
15 | - Z-Way API function (getDeviceAsJson) to load a device as JSON, for special devices
16 |
17 | ## [0.2.6] - 2017-04-02
18 | ### Added
19 | - Device history API for single device
20 |
21 | ## [0.2.5] - 2017-02-04
22 | ### Changed
23 | - Instance API, id parameter from string to integer
24 | - Device API, remove post device (not supported and add put device
25 |
26 | ### Added
27 | - Add dummy device instance model
28 | - Add GET (single instance), POST, DELETE for Instance API
29 | - Add GET (single device), PUT for Device API
30 |
31 | ## [0.2.4] - 2017-02-03
32 | ### Added
33 | - Add custom icons property to device model
34 |
35 | ## [0.2.3] - 2017-02-02
36 | ### Added
37 | - Camera device type
38 | - Text device type
39 | - Icon API, post custom icon and load list of icons
40 |
41 | ## [0.2.2] - 2017-01-30
42 | ### Changed
43 | - Notification id from integer to long (Z-Way version 27.01.2017 v2.3.0)
44 |
45 | ## [0.2.1] - 2017-01-27
46 | ### Added
47 | - Device history API
48 |
49 | ## [0.2.0] - 2017-01-16
50 | ### Added
51 | - Profile API
52 | - Add function for getting current profile
53 |
54 | ### Fixed
55 | - Handling of different notification types
56 |
57 | ## [0.1.9] - 2017-01-09
58 | ### Added
59 | - User image field to location
60 | - Notification API
61 | - Remote access, for example with find.z-wave.me as intermediary
62 |
63 | ### Changed
64 | - Add since parameter to notification API
65 |
66 | ### Fixed
67 | - Add getter and setter for device tags
68 |
69 | ## [0.1.8] - 2016-12-22
70 | ### Added
71 | - WebSocket support
72 |
73 | ## [0.1.7] - 2016-12-07
74 | ### Added
75 | - Support for command class ThermostatMode (ZWaveAPI)
76 |
77 | ## [0.1.6] - 2016-11-14
78 | ### Removed
79 | - Fields mode and modes from device model (have been removed in current version)
80 | - Commands setMode() and setTemp() from device model and ZWayApi (have been removed in current version)
81 |
82 | ### Fixed
83 | - Add command exact() to device type thermostat instead of setMode() and setTemp()
84 |
85 | ## [0.1.5] - 2016-10-07
86 | ### Added
87 | - Method to update controller data, for example to enable or disable secure inclusion
88 |
89 | ## [0.1.4] - 2016-10-05
90 | ### Added
91 | - ZWave controller API with controller information and inclusion/exclusion functions
92 |
93 | ## [0.1.3] - 2016-09-26
94 | ### Added
95 | - Minimal implementation of location API (only with id and title property)
96 | - Extend (physical) Z-Wave device model from ZWaveAPI
97 |
98 | ## [0.1.2] - 2016-09-25
99 | ### Fixed
100 | - Exception handling if the HTTP status differs from 200, which is important in case that the server is restarted (HTTP status 401)
101 | - Only the login function sets the instance in a non-valid state when an error occurs (callback with invalidate state true). All other functions inform only the caller.
102 | - Ignore device type *text* to suppress the warning
103 |
104 | ### Added
105 | - Logging information
106 |
107 | ## [0.1.1] - 2016-09-19
108 | ### Changed
109 | - Command implementation of device types:
110 | - Battery
111 | - SwitchControl
112 | - SwitchMultilevel
113 | - Device deserializer
114 |
115 | ### Added
116 | - Device type SwitchRGBW
117 | - Device type ToggleButton
118 | - All possible probe types and icons
119 | - All possible commands
120 | - Extend metrics by color, min and max element
121 |
122 | ### Removed
123 | - Device type SwitchMultilevelBlinds
124 |
125 | ## [0.1.0] - 2016-09-01
126 | ### Added
127 | - General project structure with interfaces, types, ... from Z-Way API
128 | - HTTP implementation of Z-Way API with following methods:
129 | - GET login
130 | - GET instances
131 | - PUT instance
132 | - GET devices
133 | - GET device command
134 | - GET Z-Wave device
135 |
--------------------------------------------------------------------------------
/HEADER.txt:
--------------------------------------------------------------------------------
1 | Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
2 |
3 | All rights reserved. This program and the accompanying materials
4 | are made available under the terms of the Eclipse Public License v1.0
5 | which accompanies this distribution, and is available at
6 | http://www.eclipse.org/legal/epl-v10.html
--------------------------------------------------------------------------------
/LICENSE-3RD-PARTY.txt:
--------------------------------------------------------------------------------
1 | Lists of 7 third-party dependencies.
2 | (The Apache Software License, Version 2.0) Gson (com.google.code.gson:gson:2.4 - https://github.com/google/gson)
3 | (Apache License, Version 2.0) Apache Commons Lang (org.apache.commons:commons-lang3:3.4 - http://commons.apache.org/proper/commons-lang/)
4 | (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Asynchronous HTTP Client (org.eclipse.jetty:jetty-client:9.3.11.v20160721 - http://www.eclipse.org/jetty)
5 | (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Http Utility (org.eclipse.jetty:jetty-http:9.3.11.v20160721 - http://www.eclipse.org/jetty)
6 | (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: IO Utility (org.eclipse.jetty:jetty-io:9.3.11.v20160721 - http://www.eclipse.org/jetty)
7 | (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Utilities (org.eclipse.jetty:jetty-util:9.3.11.v20160721 - http://www.eclipse.org/jetty)
8 | (MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.21 - http://www.slf4j.org)
9 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Eclipse Public License - v 1.0
2 |
3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
6 |
7 | 1. DEFINITIONS
8 |
9 | "Contribution" means:
10 |
11 | a) in the case of the initial Contributor, the initial code and documentation
12 | distributed under this Agreement, and
13 | b) in the case of each subsequent Contributor:
14 | i) changes to the Program, and
15 | ii) additions to the Program;
16 |
17 | where such changes and/or additions to the Program originate from and are
18 | distributed by that particular Contributor. A Contribution 'originates'
19 | from a Contributor if it was added to the Program by such Contributor
20 | itself or anyone acting on such Contributor's behalf. Contributions do not
21 | include additions to the Program which: (i) are separate modules of
22 | software distributed in conjunction with the Program under their own
23 | license agreement, and (ii) are not derivative works of the Program.
24 |
25 | "Contributor" means any person or entity that distributes the Program.
26 |
27 | "Licensed Patents" mean patent claims licensable by a Contributor which are
28 | necessarily infringed by the use or sale of its Contribution alone or when
29 | combined with the Program.
30 |
31 | "Program" means the Contributions distributed in accordance with this
32 | Agreement.
33 |
34 | "Recipient" means anyone who receives the Program under this Agreement,
35 | including all Contributors.
36 |
37 | 2. GRANT OF RIGHTS
38 | a) Subject to the terms of this Agreement, each Contributor hereby grants
39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to
40 | reproduce, prepare derivative works of, publicly display, publicly
41 | perform, distribute and sublicense the Contribution of such Contributor,
42 | if any, and such derivative works, in source code and object code form.
43 | b) Subject to the terms of this Agreement, each Contributor hereby grants
44 | Recipient a non-exclusive, worldwide, royalty-free patent license under
45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise
46 | transfer the Contribution of such Contributor, if any, in source code and
47 | object code form. This patent license shall apply to the combination of
48 | the Contribution and the Program if, at the time the Contribution is
49 | added by the Contributor, such addition of the Contribution causes such
50 | combination to be covered by the Licensed Patents. The patent license
51 | shall not apply to any other combinations which include the Contribution.
52 | No hardware per se is licensed hereunder.
53 | c) Recipient understands that although each Contributor grants the licenses
54 | to its Contributions set forth herein, no assurances are provided by any
55 | Contributor that the Program does not infringe the patent or other
56 | intellectual property rights of any other entity. Each Contributor
57 | disclaims any liability to Recipient for claims brought by any other
58 | entity based on infringement of intellectual property rights or
59 | otherwise. As a condition to exercising the rights and licenses granted
60 | hereunder, each Recipient hereby assumes sole responsibility to secure
61 | any other intellectual property rights needed, if any. For example, if a
62 | third party patent license is required to allow Recipient to distribute
63 | the Program, it is Recipient's responsibility to acquire that license
64 | before distributing the Program.
65 | d) Each Contributor represents that to its knowledge it has sufficient
66 | copyright rights in its Contribution, if any, to grant the copyright
67 | license set forth in this Agreement.
68 |
69 | 3. REQUIREMENTS
70 |
71 | A Contributor may choose to distribute the Program in object code form under
72 | its own license agreement, provided that:
73 |
74 | a) it complies with the terms and conditions of this Agreement; and
75 | b) its license agreement:
76 | i) effectively disclaims on behalf of all Contributors all warranties
77 | and conditions, express and implied, including warranties or
78 | conditions of title and non-infringement, and implied warranties or
79 | conditions of merchantability and fitness for a particular purpose;
80 | ii) effectively excludes on behalf of all Contributors all liability for
81 | damages, including direct, indirect, special, incidental and
82 | consequential damages, such as lost profits;
83 | iii) states that any provisions which differ from this Agreement are
84 | offered by that Contributor alone and not by any other party; and
85 | iv) states that source code for the Program is available from such
86 | Contributor, and informs licensees how to obtain it in a reasonable
87 | manner on or through a medium customarily used for software exchange.
88 |
89 | When the Program is made available in source code form:
90 |
91 | a) it must be made available under this Agreement; and
92 | b) a copy of this Agreement must be included with each copy of the Program.
93 | Contributors may not remove or alter any copyright notices contained
94 | within the Program.
95 |
96 | Each Contributor must identify itself as the originator of its Contribution,
97 | if
98 | any, in a manner that reasonably allows subsequent Recipients to identify the
99 | originator of the Contribution.
100 |
101 | 4. COMMERCIAL DISTRIBUTION
102 |
103 | Commercial distributors of software may accept certain responsibilities with
104 | respect to end users, business partners and the like. While this license is
105 | intended to facilitate the commercial use of the Program, the Contributor who
106 | includes the Program in a commercial product offering should do so in a manner
107 | which does not create potential liability for other Contributors. Therefore,
108 | if a Contributor includes the Program in a commercial product offering, such
109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
110 | every other Contributor ("Indemnified Contributor") against any losses,
111 | damages and costs (collectively "Losses") arising from claims, lawsuits and
112 | other legal actions brought by a third party against the Indemnified
113 | Contributor to the extent caused by the acts or omissions of such Commercial
114 | Contributor in connection with its distribution of the Program in a commercial
115 | product offering. The obligations in this section do not apply to any claims
116 | or Losses relating to any actual or alleged intellectual property
117 | infringement. In order to qualify, an Indemnified Contributor must:
118 | a) promptly notify the Commercial Contributor in writing of such claim, and
119 | b) allow the Commercial Contributor to control, and cooperate with the
120 | Commercial Contributor in, the defense and any related settlement
121 | negotiations. The Indemnified Contributor may participate in any such claim at
122 | its own expense.
123 |
124 | For example, a Contributor might include the Program in a commercial product
125 | offering, Product X. That Contributor is then a Commercial Contributor. If
126 | that Commercial Contributor then makes performance claims, or offers
127 | warranties related to Product X, those performance claims and warranties are
128 | such Commercial Contributor's responsibility alone. Under this section, the
129 | Commercial Contributor would have to defend claims against the other
130 | Contributors related to those performance claims and warranties, and if a
131 | court requires any other Contributor to pay any damages as a result, the
132 | Commercial Contributor must pay those damages.
133 |
134 | 5. NO WARRANTY
135 |
136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN
137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each
140 | Recipient is solely responsible for determining the appropriateness of using
141 | and distributing the Program and assumes all risks associated with its
142 | exercise of rights under this Agreement , including but not limited to the
143 | risks and costs of program errors, compliance with applicable laws, damage to
144 | or loss of data, programs or equipment, and unavailability or interruption of
145 | operations.
146 |
147 | 6. DISCLAIMER OF LIABILITY
148 |
149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION
152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
156 | OF SUCH DAMAGES.
157 |
158 | 7. GENERAL
159 |
160 | If any provision of this Agreement is invalid or unenforceable under
161 | applicable law, it shall not affect the validity or enforceability of the
162 | remainder of the terms of this Agreement, and without further action by the
163 | parties hereto, such provision shall be reformed to the minimum extent
164 | necessary to make such provision valid and enforceable.
165 |
166 | If Recipient institutes patent litigation against any entity (including a
167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself
168 | (excluding combinations of the Program with other software or hardware)
169 | infringes such Recipient's patent(s), then such Recipient's rights granted
170 | under Section 2(b) shall terminate as of the date such litigation is filed.
171 |
172 | All Recipient's rights under this Agreement shall terminate if it fails to
173 | comply with any of the material terms or conditions of this Agreement and does
174 | not cure such failure in a reasonable period of time after becoming aware of
175 | such noncompliance. If all Recipient's rights under this Agreement terminate,
176 | Recipient agrees to cease use and distribution of the Program as soon as
177 | reasonably practicable. However, Recipient's obligations under this Agreement
178 | and any licenses granted by Recipient relating to the Program shall continue
179 | and survive.
180 |
181 | Everyone is permitted to copy and distribute copies of this Agreement, but in
182 | order to avoid inconsistency the Agreement is copyrighted and may only be
183 | modified in the following manner. The Agreement Steward reserves the right to
184 | publish new versions (including revisions) of this Agreement from time to
185 | time. No one other than the Agreement Steward has the right to modify this
186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The
187 | Eclipse Foundation may assign the responsibility to serve as the Agreement
188 | Steward to a suitable separate entity. Each new version of the Agreement will
189 | be given a distinguishing version number. The Program (including
190 | Contributions) may always be distributed subject to the version of the
191 | Agreement under which it was received. In addition, after a new version of the
192 | Agreement is published, Contributor may elect to distribute the Program
193 | (including its Contributions) under the new version. Except as expressly
194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
195 | licenses to the intellectual property of any Contributor under this Agreement,
196 | whether expressly, by implication, estoppel or otherwise. All rights in the
197 | Program not expressly granted under this Agreement are reserved.
198 |
199 | This Agreement is governed by the laws of the State of New York and the
200 | intellectual property laws of the United States of America. No party to this
201 | Agreement will bring a legal action under this Agreement more than one year
202 | after the cause of action arose. Each party waives its rights to a jury trial in
203 | any resulting litigation.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Z-Way library for Java
2 |
3 | This project provides a Z-Way library for Java. The offical API description is available under http://docs.zwayhomeautomation.apiary.io/#. Currently there is only one implementation which uses HTTP with a subset of API functions (other implementations are planned, such as MQTT or WebSockets). Available functions:
4 |
5 | - GET login
6 | - GET instances
7 | - PUT instance
8 | - POST instance
9 | - DELETE instance
10 | - GET notifications
11 | - GET profiles
12 | - GET devices
13 | - GET device
14 | - GET device as JSON
15 | - PUT device
16 | - GET device command
17 | - GET locations (only with id, title and image property)
18 | - GET device history
19 | - GET icons
20 | - POST icon
21 | - GET system/info
22 | - GET Z-Wave device (device model not complete)
23 | - other methods throw an `UnsupportedOperationException`
24 |
25 | ## Installation
26 |
27 | - Install Maven if not already installed
28 | - Clone project and navigate with console to the root folder of the project
29 | - Build JAR file: `mvn package`
30 | - Add the resulting file (`target/zway-lib-*.*.*-SNAPSHOT.jar`) into your project
31 | - All dependencies: Gson, Apache Commons Lang, Jetty and SLF4J must be resolved (see [Dependencies](#dependencies) for detail)
32 |
33 | ## Usage
34 |
35 | - Add library to your project ([Installation](#installation))
36 | - Choose a implementation for your project (currently there is only a HTTP implementation available `ZWayApiHttp`)
37 | - Create a instance of API: `IZWayApi mZWayApi = new ZWayApiHttp(ipAddress, port, protocol, username, password, remoteId, useRemoteService, caller);`
38 | - IP address: Z-Way server address
39 | - port: Z-Way server port (default: 8083)
40 | - protocol: http/https
41 | - username (default: admin)
42 | - password (default: admin)
43 | - remote id
44 | - use remote service: true/false enables another login implementation
45 | - caller must implement the `IZWayApiCallbacks` interface to receive asynchronous callbacks
46 |
47 | ### GET login
48 | - `mZWayApi.getLogin()` returns the session id or null (which is stored internaly for further requests)
49 |
50 | ### GET devices
51 |
52 | - Synchronous: ```mZWayApi.getDevices()``` returns the device list or null
53 | - Asynchronous:
54 |
55 | ```getDevices(new IZWayCallback() {
56 | @Override
57 | public void onSuccess(DeviceList deviceList) {
58 | }
59 | });```
60 | - `DeviceList` provides different ways to access the devices. Only devices which don't represent physical devices or only devices which do represent physical devices.
61 | - `getDevices()` returns a list with virtual devices which don't represent physical devices in Z-Wave network
62 | - `getDevicesGroupByNodeId()` returns a map (node id, device list) of virtual devices associated with a physical device
63 |
64 | ### Command Class ThermostatMode
65 | - Load Z-Wave device: `api.getZWaveDevice(42)`
66 | - Get current thermostat mode: `device.getInstances().get0().getCommandClass().get64().getData().getMode().getValue()`
67 | - Get possible modes: `device.getInstances().get0().getCommandClass().get64().getThermostatModes()`
68 | - Set thermostat mode: `api.getZWaveDeviceThermostatModeSet(42, 1)`
69 |
70 | ## Supported device types
71 |
72 | - Battery
73 | - Doorlock
74 | - SensorBinary
75 | - SensorMultilevel
76 | - SwitchBinary
77 | - SwitchControl
78 | - SwitchMultilevel
79 | - SwitchRGBW
80 | - SwitchToggle
81 | - Thermostat
82 | - ToggleButton
83 | - Text
84 | - Camera
85 | - SensorDiscrete
86 | - SensorMultiline
87 |
88 | ## Dependencies
89 |
90 | - Gson (com.google.code.gson:gson:2.4 - https://github.com/google/gson)
91 | - Apache Commons Lang (org.apache.commons:commons-lang3:3.4 - http://commons.apache.org/proper/commons-lang/)
92 | - Jetty :: Asynchronous HTTP Client (org.eclipse.jetty:jetty-client:9.3.11.v20160721 - http://www.eclipse.org/jetty)
93 | - Jetty :: Http Utility (org.eclipse.jetty:jetty-http:9.3.11.v20160721 - http://www.eclipse.org/jetty)
94 | - Jetty :: IO Utility (org.eclipse.jetty:jetty-io:9.3.11.v20160721 - http://www.eclipse.org/jetty)
95 | - Jetty :: Utilities (org.eclipse.jetty:jetty-util:9.3.11.v20160721 - http://www.eclipse.org/jetty)
96 | - Jetty :: WebSocket :: API (org.eclipse.jetty.websocket:websocket-api:9.3.12.v20160915 - http://www.eclipse.org/jetty)
97 | - Jetty :: WebSocket :: Client (org.eclipse.jetty.websocket:websocket-client:9.3.12.v20160915 - http://www.eclipse.org/jetty)
98 | - Jetty :: WebSocket :: Common (org.eclipse.jetty.websocket:websocket-common:9.3.12.v20160915 - http://www.eclipse.org/jetty)
99 | - SLF4J API Module (org.slf4j:slf4j-api:1.7.21 - http://www.slf4j.org)
100 |
101 | ## Contributing
102 |
103 | 1. Fork it!
104 | 2. Create your feature branch: `git checkout -b my-new-feature`
105 | 3. Commit your changes: `git commit -am 'Add some feature'`
106 | 4. Push to the branch: `git push origin my-new-feature`
107 | 5. Submit a pull request :D
108 |
109 | ## License
110 |
111 | Copyright (C) 2016 by [Software-Systementwicklung Zwickau](http://www.software-systementwicklung.de/) Research Group
112 |
113 | All rights reserved. This program and the accompanying materials
114 | are made available under the terms of the Eclipse Public License v1.0
115 | which accompanies this distribution, and is available at
116 | http://www.eclipse.org/legal/epl-v10.html
117 |
118 | This project uses 3rd party tools. You can find the list of 3rd party tools including their authors and licenses [here](LICENSE-3RD-PARTY.txt).
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/doc/BMWi_4C_Gef_en.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pathec/ZWay-library-for-Java/72de272cabb245b69eef0b3dd77d78ea1fcbc4c1/doc/BMWi_4C_Gef_en.jpg
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | 4.0.0
5 |
6 | de.fh_zwickau.informatik.sensor
7 | zway-lib
8 | jar
9 | 0.2.9-SNAPSHOT
10 |
11 | Z-Way Library for Java
12 | http://sensor.fh-zwickau.de
13 |
14 |
15 |
16 | org.apache.commons
17 | commons-lang3
18 | 3.7
19 |
20 |
21 |
22 | com.google.code.gson
23 | gson
24 | 2.8.2
25 |
26 |
27 |
28 | org.eclipse.jetty
29 | jetty-client
30 | 9.4.8.v20171121
31 |
32 |
33 |
34 | org.slf4j
35 | slf4j-api
36 | 1.7.25
37 |
38 |
39 |
40 | org.eclipse.jetty.websocket
41 | websocket-api
42 | 9.4.8.v20171121
43 |
44 |
45 |
46 | org.eclipse.jetty.websocket
47 | websocket-client
48 | 9.4.8.v20171121
49 |
50 |
51 |
52 | org.eclipse.jetty.websocket
53 | websocket-common
54 | 9.4.8.v20171121
55 |
56 |
57 |
58 | org.eclipse.jetty
59 | jetty-io
60 | 9.4.8.v20171121
61 |
62 |
63 |
64 | org.eclipse.jetty
65 | jetty-util
66 | 9.4.8.v20171121
67 |
68 |
69 |
70 |
71 | zway-lib-${project.version}
72 |
73 |
74 | org.apache.maven.plugins
75 | maven-compiler-plugin
76 | 2.3.2
77 |
78 | 1.7
79 | 1.7
80 |
81 |
82 |
83 |
84 | com.google.code.maven-license-plugin
85 | maven-license-plugin
86 | 1.4.0
87 |
88 |
89 |
90 | .git/**
91 | **/README
92 | **/README.md
93 | HEADER.txt
94 | LICENSE.txt
95 | LICENSE-3RD-PARTY.txt
96 | target/**
97 | doc/**
98 |
99 |
100 |
101 |
102 |
103 | check
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/IZWayApiCallbacks.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devicehistory.DeviceHistory;
12 | import de.fh_zwickau.informatik.sensor.model.devicehistory.DeviceHistoryList;
13 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
14 | import de.fh_zwickau.informatik.sensor.model.devices.DeviceList;
15 | import de.fh_zwickau.informatik.sensor.model.instances.Instance;
16 | import de.fh_zwickau.informatik.sensor.model.instances.InstanceList;
17 | import de.fh_zwickau.informatik.sensor.model.locations.Location;
18 | import de.fh_zwickau.informatik.sensor.model.locations.LocationList;
19 | import de.fh_zwickau.informatik.sensor.model.modules.ModuleList;
20 | import de.fh_zwickau.informatik.sensor.model.namespaces.NamespaceList;
21 | import de.fh_zwickau.informatik.sensor.model.notifications.Notification;
22 | import de.fh_zwickau.informatik.sensor.model.notifications.NotificationList;
23 | import de.fh_zwickau.informatik.sensor.model.profiles.Profile;
24 | import de.fh_zwickau.informatik.sensor.model.profiles.ProfileList;
25 | import de.fh_zwickau.informatik.sensor.model.zwaveapi.controller.ZWaveController;
26 | import de.fh_zwickau.informatik.sensor.model.zwaveapi.devices.ZWaveDevice;
27 |
28 | /**
29 | * The {@link IZWayApiCallbacks} defines a all possible callbacks of ZAutomation API. See also:
30 | * http://docs.zwayhomeautomation.apiary.io/#
31 | *
32 | * @author Patrick Hecker - Initial contribution
33 | */
34 | public interface IZWayApiCallbacks {
35 | // Platform Availability
36 |
37 | /**
38 | * @param status
39 | */
40 | void getStatusResponse(String status);
41 |
42 | // Platform Restart
43 |
44 | /**
45 | * @param status
46 | */
47 | void getRestartResponse(Boolean status);
48 |
49 | // Login
50 |
51 | /**
52 | * @param sessionId
53 | */
54 | void getLoginResponse(String sessionId);
55 |
56 | // Namespaces
57 |
58 | /**
59 | * @param namespaces
60 | */
61 | void getNamespacesResponse(NamespaceList namespaces);
62 |
63 | // Instances and Modules
64 |
65 | /**
66 | * @param moduleList
67 | */
68 | void getModulesResponse(ModuleList moduleList);
69 |
70 | /**
71 | * @param instanceList
72 | */
73 | void getInstancesResponse(InstanceList instanceList);
74 |
75 | /**
76 | * @param instance
77 | */
78 | void postInstanceResponse(Instance instance);
79 |
80 | /**
81 | * @param instance
82 | */
83 | void getInstanceResponse(Instance instance);
84 |
85 | /**
86 | * @param instance
87 | */
88 | void putInstanceResponse(Instance instance);
89 |
90 | /**
91 | * @param status
92 | */
93 | void deleteInstanceResponse(boolean status);
94 |
95 | // Devices
96 |
97 | /**
98 | * @param deviceList
99 | */
100 | void getDevicesResponse(DeviceList deviceList);
101 |
102 | /**
103 | * @param device
104 | */
105 | void putDeviceResponse(Device device);
106 |
107 | /**
108 | * @param device
109 | */
110 | void getDeviceResponse(Device device);
111 |
112 | /**
113 | * @param message
114 | */
115 | void getDeviceCommandResponse(String message);
116 |
117 | // Locations
118 |
119 | /**
120 | * @param locationList
121 | */
122 | void getLocationsResponse(LocationList locationList);
123 |
124 | /**
125 | * @param location
126 | */
127 | void postLocationResponse(Location location);
128 |
129 | /**
130 | * @param location
131 | */
132 | void getLocationResponse(Location location);
133 |
134 | /**
135 | * @param location
136 | */
137 | void putLocationResponse(Location location);
138 |
139 | /**
140 | * @param status
141 | */
142 | void deleteLocationResponse(boolean status);
143 |
144 | // Profiles
145 |
146 | /**
147 | * @param profileList
148 | */
149 | void getProfilesResponse(ProfileList profileList);
150 |
151 | /**
152 | * @param profile
153 | */
154 | void postProfileResponse(Profile profile);
155 |
156 | /**
157 | * @param profile
158 | */
159 | void getProfileResponse(Profile profile);
160 |
161 | /**
162 | * @param profile
163 | */
164 | void putProfileResponse(Profile profile);
165 |
166 | /**
167 | * @param status
168 | */
169 | void deleteProfileResponse(boolean status);
170 |
171 | // Notifications
172 |
173 | /**
174 | * @param notificationList
175 | */
176 | void getNotificationsResponse(NotificationList notificationList);
177 |
178 | /**
179 | * @param notification
180 | */
181 | void getNotificationResponse(Notification notification);
182 |
183 | /**
184 | * @param notification
185 | */
186 | void putNotificationResponse(Notification notification);
187 |
188 | // Device History
189 |
190 | /**
191 | * @param deviceHistoryList
192 | */
193 | void getDeviceHistoriesResponse(DeviceHistoryList deviceHistoryList);
194 |
195 | /**
196 | * @param deviceHistory
197 | */
198 | void getDeviceHistoryResponse(DeviceHistory deviceHistory);
199 |
200 | // ZWaveAPI Callbacks
201 |
202 | /**
203 | * @param zwaveDevice
204 | */
205 | void getZWaveDeviceResponse(ZWaveDevice zwaveDevice);
206 |
207 | /**
208 | * @param zwaveController
209 | */
210 | void getZWaveControllerResponse(ZWaveController zwaveController);
211 |
212 | // Other
213 |
214 | /**
215 | * This function is called when an internal error occurred.
216 | *
217 | * @param message
218 | * @param invalidateState message indicates a fault in the system or Z-Way server
219 | */
220 | void apiError(String message, boolean invalidateState);
221 |
222 | /**
223 | * This function is called when a server response status isn't 200.
224 | *
225 | * @param httpStatus
226 | * @param message
227 | * @param invalidateState message indicates a fault in the system or Z-Way server
228 | */
229 | void httpStatusError(int httpStatus, String message, boolean invalidateState);
230 |
231 | /**
232 | * This function is called when authentication error occurred.
233 | */
234 | void authenticationError();
235 |
236 | /**
237 | * This function is called when receiving data not in the correct format.
238 | *
239 | * @param message
240 | * @param invalidApiState message indicates a fault in the system or Z-Way server
241 | */
242 | void responseFormatError(String message, boolean invalidApiState);
243 |
244 | /**
245 | * This function provides internal messages.
246 | *
247 | * @param code
248 | * @param message
249 | */
250 | void message(int code, String message);
251 | }
252 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/IZWayApiWebSocketCallbacks.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor;
10 |
11 | /**
12 | * The {@link IZWayApiWebSocketCallbacks} defines a all possible callbacks of WebSocket API. See also:
13 | * http://docs.zwayhomeautomation.apiary.io/#
14 | *
15 | * @author Patrick Hecker - Initial contribution
16 | */
17 | public interface IZWayApiWebSocketCallbacks {
18 | void onConnect();
19 |
20 | void onClose();
21 |
22 | void onError(Throwable throwable);
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/IZWayCallback.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor;
10 |
11 | /**
12 | * The {@link IZWayCallback} defines a generic interface for all functions of ZAutomation API. See also:
13 | * http://docs.zwayhomeautomation.apiary.io/#
14 | *
15 | * @author Patrick Hecker - Initial contribution
16 | */
17 | public interface IZWayCallback {
18 | void onSuccess(T response);
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/ZWayApiWebSocket.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor;
10 |
11 | import java.net.HttpCookie;
12 | import java.net.URI;
13 | import java.util.ArrayList;
14 | import java.util.List;
15 | import java.util.concurrent.CountDownLatch;
16 | import java.util.concurrent.TimeUnit;
17 |
18 | import org.eclipse.jetty.util.ssl.SslContextFactory;
19 | import org.eclipse.jetty.websocket.api.Session;
20 | import org.eclipse.jetty.websocket.api.WebSocketListener;
21 | import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
22 | import org.eclipse.jetty.websocket.client.WebSocketClient;
23 | import org.slf4j.Logger;
24 | import org.slf4j.LoggerFactory;
25 |
26 | import com.google.gson.Gson;
27 | import com.google.gson.JsonObject;
28 | import com.google.gson.JsonParseException;
29 |
30 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
31 | import de.fh_zwickau.informatik.sensor.model.devices.DeviceListDeserializer;
32 |
33 | /**
34 | * The {@link ZWayApiWebSocket} implements the ZAutomation API. See also:
35 | * http://docs.zwayhomeautomation.apiary.io/#
36 | *
37 | * @author Patrick Hecker - Initial contribution
38 | */
39 | public class ZWayApiWebSocket extends ZWayApiBase {
40 |
41 | private Logger logger = LoggerFactory.getLogger(this.getClass());
42 | private WebSocketClient mClient;
43 | private ZWayWebSocket mSocket;
44 | private IZWayApiWebSocketCallbacks mWebSocketListener;
45 |
46 | public ZWayApiWebSocket(String ipAddress, Integer port, String protocol, String username, String password,
47 | Integer remoteId, Boolean useRemoteService, IZWayApiCallbacks caller,
48 | IZWayApiWebSocketCallbacks webSocketListener) {
49 | super(ipAddress, port, protocol, username, password, remoteId, useRemoteService, caller);
50 |
51 | mWebSocketListener = webSocketListener;
52 |
53 | mSocket = new ZWayWebSocket();
54 | }
55 |
56 | public void connect() {
57 | if (mUseRemoteService) {
58 | // TODO - WebSockets not available for remote service
59 | mCaller.apiError("WebSockets not available for remote service.", true);
60 | return;
61 | }
62 |
63 | // Connect to Z-Way via HTTP to get the required cookies
64 | String protocol = mProtocol.equals("ws") ? "http" : "https";
65 | IZWayApi zwayAPIHTTP = new ZWayApiHttp(mIpAddress, mPort, protocol, mUsername, mPassword, mRemoteId,
66 | mUseRemoteService, mCaller);
67 | if (zwayAPIHTTP.getLogin() == null) {
68 | logger.warn("Authentication failed!");
69 | return;
70 | }
71 |
72 | if (mProtocol.equals("ws")) {
73 | logger.info("Create WebSocket client");
74 | mClient = new WebSocketClient();
75 | } else if (mProtocol.equals("wss")) {
76 | logger.info("Create WebSocket client with SSL");
77 | mClient = new WebSocketClient(new SslContextFactory());
78 | }
79 |
80 | try {
81 | mClient.start();
82 |
83 | URI destUri = new URI(getTopLevelUrl());
84 |
85 | ClientUpgradeRequest request = new ClientUpgradeRequest();
86 |
87 | List cookies = new ArrayList();
88 | cookies.add(new HttpCookie("ZWAYSession", zwayAPIHTTP.getZWaySessionId()));
89 | if (mUseRemoteService) {
90 | cookies.add(new HttpCookie("ZBW_SESSID", zwayAPIHTTP.getZWayRemoteSessionId()));
91 | }
92 |
93 | request.setCookies(cookies);
94 | mClient.connect(mSocket, destUri, request);
95 | } catch (Exception e) {
96 | mCaller.apiError("Z-Way WebSocket connect: " + e.getMessage(), true);
97 | }
98 | }
99 |
100 | public void disconnect() {
101 | try {
102 | mSocket.awaitClose(5, TimeUnit.SECONDS);
103 |
104 | mClient.stop();
105 | } catch (Exception e) {
106 | logger.error("Z-Way WebSocket disconnect: {}", e.getMessage());
107 | mCaller.apiError("Z-Way WebSocket disconnect: " + e.getMessage(), true);
108 | }
109 | }
110 |
111 | private void onMessage(String message) {
112 | // Request performed successfully: load response body
113 | // Expected response format: { "type": "...", "data": {...} }
114 | logger.info("Z-Way WebSocket message: {}", message);
115 |
116 | try {
117 | Gson gson = new Gson();
118 | String type = gson.fromJson(message, JsonObject.class).get("type").getAsString();
119 | logger.info("Z-Way WebSocket message type: {}", type);
120 |
121 | if (type.equals("devices.level_update")) { // TODO only a example
122 | String deviceAsString = gson.fromJson(message, JsonObject.class).get("data").getAsString();
123 | Device device = new DeviceListDeserializer()
124 | .deserializeDevice(gson.fromJson(deviceAsString, JsonObject.class).getAsJsonObject(), this);
125 | if (device != null) {
126 | mCaller.getDeviceResponse(device);
127 | }
128 | }
129 | } catch (JsonParseException e) {
130 | logger.warn("Z-Way WebSocket unexpected response format: {}", e.getMessage());
131 | mCaller.responseFormatError("Z-Way WebSocket unexpected response format: " + e.getMessage(), false);
132 | }
133 | }
134 |
135 | public class ZWayWebSocket implements WebSocketListener {
136 | private final CountDownLatch closeLatch = new CountDownLatch(1);
137 |
138 | public boolean awaitClose(int duration, TimeUnit unit) throws InterruptedException {
139 | return this.closeLatch.await(duration, unit);
140 | }
141 |
142 | @Override
143 | public void onWebSocketClose(int statusCode, String reason) {
144 | mWebSocketListener.onClose();
145 | logger.info("Z-Way WebSocket closed: {}", statusCode);
146 | }
147 |
148 | @Override
149 | public void onWebSocketConnect(Session session) {
150 | mWebSocketListener.onConnect();
151 | logger.info("Z-Way WebSocket connected: {}", session);
152 | }
153 |
154 | @Override
155 | public void onWebSocketError(Throwable error) {
156 | mWebSocketListener.onError(error);
157 | logger.info("Z-Way WebSocket error: {} - {}", error.getClass().getName(), error.getMessage());
158 | }
159 |
160 | @Override
161 | public void onWebSocketBinary(byte[] arg0, int arg1, int arg2) {
162 | logger.info("Z-Way WebSocket binary");
163 | }
164 |
165 | @Override
166 | public void onWebSocketText(String message) {
167 | logger.info("Z-Way WebSocket message received: {}", message);
168 | onMessage(message);
169 | }
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/ZWayConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor;
10 |
11 | /**
12 | * The {@link ZWayConstants} class defines ZAutomation constants. See also:
13 | * http://docs.zwayhomeautomation.apiary.io/#
14 | *
15 | * @author Patrick Hecker - Initial contribution
16 | */
17 | public class ZWayConstants {
18 | public static final String PATH_LOGIN = "login";
19 | public static final String PATH_STATUS = "status";
20 | public static final String PATH_NAMESPACES = "namespaces";
21 | public static final String PATH_MODULES = "modules";
22 | public static final String PATH_INSTANCES = "instances";
23 | public static final String PATH_DEVICES = "devices";
24 | public static final String PATH_DEVICES_COMMAND = "devices/{deviceId}/command/{command}";
25 | public static final String PATH_LOCATIONS = "locations";
26 | public static final String PATH_PROFILES = "profiles";
27 | public static final String PATH_NOTIFICATIONS = "notifications";
28 | public static final String PATH_DEVICE_HISTORY = "history";
29 | public static final String PATH_ICONS = "icons";
30 | public static final String PATH_SYSTEM_INFO = "system/info";
31 |
32 | public static final String REMOTE_PATH_LOGIN = "zboxweb";
33 |
34 | public static final String ZWAVE_PATH_DEVICES = "devices[{nodeId}]";
35 | public static final String ZWAVE_PATH_CONTROLLER = "controller";
36 | public static final String ZWAVE_PATH_INCLUSION = "controller.AddNodeToNetwork({flag})";
37 | public static final String ZWAVE_PATH_EXCLUSION = "controller.RemoveNodeFromNetwork({flag})";
38 | public static final String ZWAVE_PATH_CONTROLLER_DATA = "controller.data";
39 |
40 | public static final String ZWAVE_PATH_DEVICES_CC_THERMOSTAT_SET = "devices[{nodeId}].ThermostatMode.Set({mode})";
41 |
42 | public static final String ICON_NONE = "";
43 | public static final String ICON_SWITCH = "switch";
44 | public static final String ICON_MULTILEVEL = "multilevel";
45 | public static final String ICON_SMOKE = "smoke";
46 | public static final String ICON_CO = "co";
47 | public static final String ICON_COOLING = "cooling";
48 | public static final String ICON_DOOR = "door";
49 | public static final String ICON_MOTION = "motion";
50 | public static final String ICON_FLOOD = "flood";
51 | public static final String ICON_TEMPERATURE = "temperature";
52 | public static final String ICON_LUMINOSITY = "luminosity";
53 | public static final String ICON_ENERGY = "energy";
54 | public static final String ICON_HUMIDITY = "humidity";
55 | public static final String ICON_BATTERY = "battery";
56 | public static final String ICON_THERMOSTAT = "thermostat";
57 | public static final String ICON_FAN = "fan";
58 | public static final String ICON_METER = "meter";
59 | public static final String ICON_BLINDS = "blinds";
60 | public static final String ICON_TAMPER = "tamper";
61 | public static final String ICON_BAROMETER = "barometer";
62 | public static final String ICON_ULTRAVIOLET = "ultraviolet";
63 | public static final String ICON_ALARM = "alarm";
64 | public static final String ICON_GESTURE = "gesture";
65 |
66 | public static final String PROBE_TYPE_TEMPERATURE = "temperature";
67 | public static final String PROBE_TYPE_LUMINOSITY = "luminosity";
68 | public static final String PROBE_TYPE_HUMIDITY = "humidity";
69 | public static final String PROBE_TYPE_ULTRAVIOLET = "ultraviolet";
70 | public static final String PROBE_TYPE_GENERAL_PURPOSE = "general_purpose";
71 | public static final String PROBE_TYPE_ENERGY = "energy";
72 | public static final String PROBE_TYPE_MOTOR = "motor";
73 | public static final String PROBE_TYPE_MULTILEVEL = "multilevel";
74 | public static final String PROBE_TYPE_SMOKE = "smoke";
75 | public static final String PROBE_TYPE_CO = "co";
76 | public static final String PROBE_TYPE_FLOOD = "flood";
77 | public static final String PROBE_TYPE_COOLING = "cooling";
78 | public static final String PROBE_TYPE_TAMPER = "tamper";
79 | public static final String PROBE_TYPE_DOOR_WINDOW = "door-window";
80 | public static final String PROBE_TYPE_MOTION = "motion";
81 | public static final String PROBE_TYPE_BAROMETER = "barometer";
82 |
83 | public static final String PROBE_TYPE_METER_ELECTRIC_KILOWATT_PER_HOUR = "meterElectric_kilowatt_per_hour";
84 | public static final String PROBE_TYPE_METER_ELECTRIC_WATT = "meterElectric_watt";
85 | public static final String PROBE_TYPE_METER_ELECTRIC_PULSE_COUNT = "meterElectric_pulse_count";
86 | public static final String PROBE_TYPE_METER_ELECTRIC_VOLTAGE = "meterElectric_voltage";
87 | public static final String PROBE_TYPE_METER_ELECTRIC_AMPERE = "meterElectric_ampere";
88 | public static final String PROBE_TYPE_METER_ELECTRIC_POWER_FACTOR = "meterElectric_power_factor";
89 |
90 | public static final String PROBE_TYPE_BATTERY = "Battery"; // attention! uppercase
91 |
92 | public static final String PROBE_TYPE_ALARM_DOOR = "alarm_door";
93 | public static final String PROBE_TYPE_ALARM_SMOKE = "alarm_smoke";
94 | public static final String PROBE_TYPE_ALARM_CO = "alarm_co";
95 | public static final String PROBE_TYPE_ALARM_COO = "alarm_coo";
96 | public static final String PROBE_TYPE_ALARM_HEAT = "alarm_heat";
97 | public static final String PROBE_TYPE_ALARM_FLOOD = "alarm_flood";
98 | public static final String PROBE_TYPE_ALARM_BURGLAR = "alarm_burglar";
99 | public static final String PROBE_TYPE_ALARM_POWER = "alarm_power";
100 | public static final String PROBE_TYPE_ALARM_SYSTEM = "alarm_system";
101 | public static final String PROBE_TYPE_ALARM_EMERGENCY = "alarm_emergency";
102 | public static final String PROBE_TYPE_ALARM_CLOCK = "alarm_clock";
103 |
104 | // probe types for deprecated command class AlarmSensor
105 |
106 | public static final String PROBE_TYPE_ALARM_SENSOR_GENERAL_PURPOSE = "alarmSensor_door";
107 | public static final String PROBE_TYPE_ALARM_SENSOR_SMOKE = "alarmSensor_smoke";
108 | public static final String PROBE_TYPE_ALARM_SENSOR_CO = "alarmSensor_co";
109 | public static final String PROBE_TYPE_ALARM_SENSOR_COO = "alarmSensor_coo";
110 | public static final String PROBE_TYPE_ALARM_SENSOR_HEAT = "alarmSensor_heat";
111 | public static final String PROBE_TYPE_ALARM_SENSOR_FLOOD = "alarmSensor_flood";
112 | public static final String PROBE_TYPE_ALARM_SENSOR_DOOR = "alarmSensor_door";
113 | public static final String PROBE_TYPE_ALARM_SENSOR_BURGLAR = "alarmSensor_burglar";
114 | public static final String PROBE_TYPE_ALARM_SENSOR_POWER = "alarmSensor_power";
115 | public static final String PROBE_TYPE_ALARM_SENSOR_SYSTEM = "alarmSensor_system";
116 | public static final String PROBE_TYPE_ALARM_SENSOR_EMERGENCY = "alarmSensor_emergency";
117 | public static final String PROBE_TYPE_ALARM_SENSOR_CLOCK = "alarmSensor_clock";
118 |
119 | // end - probe types for deprecated command class AlarmSensor
120 |
121 | public static final String PROBE_TYPE_SWITCH_COLOR_RGB = "switchColor_rgb";
122 | public static final String PROBE_TYPE_SWITCH_COLOR_SOFT_WHITE = "switchColor_soft_white";
123 | public static final String PROBE_TYPE_SWITCH_COLOR_COLD_WHITE = "switchColor_cold_white";
124 | public static final String PROBE_TYPE_SWITCH_COLOR_RED = "switchColor_red";
125 | public static final String PROBE_TYPE_SWITCH_COLOR_GREEN = "switchColor_green";
126 | public static final String PROBE_TYPE_SWITCH_COLOR_BLUE = "switchColor_blue";
127 |
128 | public static final String PROBE_TYPE_THERMOSTAT_MODE = "thermostat_mode";
129 | public static final String PROBE_TYPE_THERMOSTAT_SET_POINT = "thermostat_set_point";
130 |
131 | public static final String PROBE_TITLE_BATTERY = "Battery";
132 | public static final String PROBE_TITLE_GENERAL_PURPOSE = "General purpose";
133 | public static final String PROBE_TITLE_TEMPERATURE = "Temperature";
134 | public static final String PROBE_TITLE_LUMINISCENCE = "Luminiscence";
135 | public static final String PROBE_TITLE_HUMIDITY = "Humidity";
136 | public static final String PROBE_TITLE_ULTRAVIOLET = "Ultraviolet";
137 | public static final String PROBE_TITLE_POWER = "Power";
138 | public static final String PROBE_TITLE_ELECTRIC = "Electric"; // attention! scaleTitles: W, kWh
139 | public static final String PROBE_TITLE_CO2_LEVEL = "CO2 Level";
140 | public static final String PROBE_TITLE_CONTROL = "Control";
141 |
142 | public static final String DEVICE_TYPE_BATTERY = "battery";
143 | public static final String DEVICE_TYPE_DOORLOCK = "doorlock";
144 | public static final String DEVICE_TYPE_THERMOSTAT = "thermostat";
145 | public static final String DEVICE_TYPE_SWITCH_BINARY = "switchBinary";
146 | public static final String DEVICE_TYPE_SWITCH_MULTILEVEL = "switchMultilevel";
147 | public static final String DEVICE_TYPE_SENSOR_BINARY = "sensorBinary";
148 | public static final String DEVICE_TYPE_SENSOR_MULTILEVEL = "sensorMultilevel";
149 | public static final String DEVICE_TYPE_SWITCH_TOGGLE = "switchToggle";
150 | public static final String DEVICE_TYPE_SWITCH_CONTROL = "switchControl";
151 | public static final String DEVICE_TYPE_TOGGLE_BUTTON = "toggleButton";
152 | public static final String DEVICE_TYPE_SWITCH_RGBW = "switchRGBW";
153 | public static final String DEVICE_TYPE_TEXT = "text";
154 | public static final String DEVICE_TYPE_CAMERA = "camera";
155 | public static final String DEVICE_TYPE_SENSOR_MULTILINE = "sensorMultiline";
156 | public static final String DEVICE_TYPE_SENSOR_DISCRETE = "sensorDiscrete";
157 |
158 | public static final String NOTIFICATION_TYPE_DEVICE_INFO = "device-info";
159 | }
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devicehistory/DeviceHistory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devicehistory;
10 |
11 | import java.util.ArrayList;
12 |
13 | import org.apache.commons.lang3.builder.ToStringBuilder;
14 |
15 | import com.google.gson.annotations.SerializedName;
16 |
17 | /**
18 | * The {@link DeviceHistory} represents a history. See also:
19 | * http://docs.zwayhomeautomation.apiary.io/#
20 | *
21 | * @author Patrick Hecker - Initial contribution
22 | */
23 | public class DeviceHistory {
24 | @SerializedName("id")
25 | private String mDeviceId;
26 | @SerializedName("dT")
27 | private String mDeviceType;
28 | @SerializedName("mH")
29 | private ArrayList mHistoryData;
30 |
31 | public DeviceHistory() {
32 | mDeviceId = "";
33 | mDeviceType = "";
34 | mHistoryData = new ArrayList();
35 | }
36 |
37 | public String getDeviceId() {
38 | if (mDeviceId == null) {
39 | mDeviceId = "";
40 | }
41 | return mDeviceId;
42 | }
43 |
44 | public void setDeviceId(String deviceId) {
45 | this.mDeviceId = deviceId;
46 | }
47 |
48 | public String getDeviceType() {
49 | if (mDeviceType == null) {
50 | mDeviceType = "";
51 | }
52 | return mDeviceType;
53 | }
54 |
55 | public void setDeviceType(String deviceType) {
56 | this.mDeviceType = deviceType;
57 | }
58 |
59 | public ArrayList getHistoryData() {
60 | if (mHistoryData == null) {
61 | mHistoryData = new ArrayList();
62 | }
63 | return mHistoryData;
64 | }
65 |
66 | public void setHistoryData(ArrayList historyData) {
67 | this.mHistoryData = historyData;
68 | }
69 |
70 | /*
71 | * (non-Javadoc)
72 | *
73 | * @see java.lang.Object#toString()
74 | */
75 | @Override
76 | public String toString() {
77 | return new ToStringBuilder(this).append("deviceId", mDeviceId).append("deviceType", mDeviceType)
78 | .append("historyData", mHistoryData).toString();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devicehistory/DeviceHistoryData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devicehistory;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link DeviceHistoryData} represents one history data. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class DeviceHistoryData {
22 | @SerializedName("id")
23 | private Long mId;
24 | @SerializedName("l")
25 | private String mLevel;
26 |
27 | public DeviceHistoryData() {
28 | mId = -1l;
29 | mLevel = "";
30 | }
31 |
32 | public Long getId() {
33 | if (mId == null) {
34 | mId = -1l;
35 | }
36 | return mId;
37 | }
38 |
39 | public void setId(Long id) {
40 | this.mId = id;
41 | }
42 |
43 | public String getLevel() {
44 | if (mLevel == null) {
45 | mLevel = "";
46 | }
47 | return mLevel;
48 | }
49 |
50 | public void setLevel(String level) {
51 | this.mLevel = level;
52 | }
53 |
54 | /*
55 | * (non-Javadoc)
56 | *
57 | * @see java.lang.Object#toString()
58 | */
59 | @Override
60 | public String toString() {
61 | return new ToStringBuilder(this).append("id", mId).append("level", mLevel).toString();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devicehistory/DeviceHistoryList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devicehistory;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | /**
17 | * The {@link DeviceHistoryList} represents a device history list. See also:
18 | * http://docs.zwayhomeautomation.apiary.io/#
19 | *
20 | * @author Patrick Hecker - Initial contribution
21 | */
22 | public class DeviceHistoryList {
23 | private List mDeviceHistoryList;
24 |
25 | /**
26 | * Instantiate a device history list with default values.
27 | */
28 | public DeviceHistoryList() {
29 | mDeviceHistoryList = new ArrayList();
30 | }
31 |
32 | public void addDeviceHistory(DeviceHistory deviceHistory) {
33 | mDeviceHistoryList.add(deviceHistory);
34 | }
35 |
36 | public List getDeviceHistoryList() {
37 | return mDeviceHistoryList;
38 | }
39 |
40 | /**
41 | * Return the first occurrence of device history
42 | *
43 | * @param id ZAutomation device id
44 | * @return device history or null if not found
45 | */
46 | public DeviceHistory getDeviceHistoryByDeviceId(String deviceId) {
47 | for (DeviceHistory deviceHistory : mDeviceHistoryList) {
48 | if (deviceHistory.getDeviceId().equals(deviceId)) {
49 | return deviceHistory;
50 | }
51 | }
52 | return null;
53 | }
54 |
55 | /*
56 | * (non-Javadoc)
57 | *
58 | * @see java.lang.Object#toString()
59 | */
60 | @Override
61 | public String toString() {
62 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
63 | for (DeviceHistory deviceHistory : mDeviceHistoryList) {
64 | toStringBuilder.append(deviceHistory);
65 | }
66 |
67 | return new ToStringBuilder(this).append("deviceHistoryList", toStringBuilder.toString()).toString();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devicehistory/DeviceHistoryListDeserializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devicehistory;
10 |
11 | import com.google.gson.Gson;
12 | import com.google.gson.JsonArray;
13 | import com.google.gson.JsonElement;
14 |
15 | /**
16 | * The {@link DeviceHistoryListDeserializer} build a device history list based on JSON data. See
17 | * also: http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class DeviceHistoryListDeserializer {
22 | /**
23 | * @param deviceHistoriesAsJson device history list as JSON data
24 | * @return device history list
25 | */
26 | public DeviceHistoryList deserializeDeviceHistoryList(JsonArray deviceHistoriesAsJson) {
27 | DeviceHistoryList deviceHistoryList = new DeviceHistoryList();
28 |
29 | for (JsonElement deviceHistoryAsJson : deviceHistoriesAsJson) {
30 | DeviceHistory deviceHistory = deserializeDeviceHistory(deviceHistoryAsJson);
31 |
32 | if (deviceHistory != null) {
33 | deviceHistoryList.addDeviceHistory(deviceHistory);
34 | }
35 | }
36 |
37 | return deviceHistoryList;
38 | }
39 |
40 | /**
41 | * @param deviceHistoryAsJson a single device history as JSON data
42 | * @return deviceHistory
43 | */
44 | public DeviceHistory deserializeDeviceHistory(JsonElement deviceHistoryAsJson) {
45 | Gson gson = new Gson();
46 |
47 | DeviceHistory deviceHistory = gson.fromJson(deviceHistoryAsJson, DeviceHistory.class);
48 |
49 | return deviceHistory;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/Color.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link Color} represents the color field of metrics with the components: red, green and blue. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class Color {
22 | @SerializedName("r")
23 | private Integer mRed;
24 | @SerializedName("g")
25 | private Integer mGreen;
26 | @SerializedName("b")
27 | private Integer mBlue;
28 |
29 | /**
30 | * Instantiate a color object with default values.
31 | */
32 | public Color() {
33 | mRed = 0;
34 | mGreen = 0;
35 | mBlue = 0;
36 | }
37 |
38 | public Integer getRed() {
39 | if (mRed == null) {
40 | mRed = 0;
41 | }
42 | return mRed;
43 | }
44 |
45 | public void setRed(Integer red) {
46 | this.mRed = red;
47 | }
48 |
49 | public Integer getGreen() {
50 | if (mGreen == null) {
51 | mGreen = 0;
52 | }
53 | return mGreen;
54 | }
55 |
56 | public void setGreen(Integer green) {
57 | this.mGreen = green;
58 | }
59 |
60 | public Integer getBlue() {
61 | if (mBlue == null) {
62 | mBlue = 0;
63 | }
64 | return mBlue;
65 | }
66 |
67 | public void setBlue(Integer blue) {
68 | this.mBlue = blue;
69 | }
70 |
71 | /*
72 | * (non-Javadoc)
73 | *
74 | * @see java.lang.Object#toString()
75 | */
76 | @Override
77 | public String toString() {
78 | return new ToStringBuilder(this).append("red", mRed).append("green", mGreen).append("blue", mBlue).toString();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/DeviceCommand.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices;
10 |
11 | import java.util.Map;
12 | import java.util.Map.Entry;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | /**
17 | * The {@link DeviceCommand} represents a command for ZAutomation API. See also:
18 | * http://docs.zwayhomeautomation.apiary.io/#
19 | *
20 | * @author Patrick Hecker - Initial contribution
21 | */
22 | public class DeviceCommand {
23 | private String mDeviceId;
24 | private String mCommand;
25 | private Map mParams;
26 |
27 | /**
28 | * Instantiate a command.
29 | *
30 | * @param deviceId ZAutomation device id
31 | * @param command ZAutamation command name
32 | * @param params parameter map
33 | */
34 | public DeviceCommand(String deviceId, String command, Map params) {
35 | setDeviceId(deviceId);
36 | setCommand(command);
37 | mParams = params;
38 | }
39 |
40 | /**
41 | * Instantiate a command without parameter.
42 | *
43 | * @param deviceId ZAutomation device id
44 | * @param command ZAutamation command name
45 | */
46 | public DeviceCommand(String deviceId, String command) {
47 | setDeviceId(deviceId);
48 | setCommand(command);
49 | mParams = null;
50 | }
51 |
52 | public String getDeviceId() {
53 | return mDeviceId;
54 | }
55 |
56 | public void setDeviceId(String deviceId) {
57 | if (deviceId == null || deviceId.isEmpty()) {
58 | throw new IllegalArgumentException("device id is required");
59 | }
60 |
61 | mDeviceId = deviceId;
62 | }
63 |
64 | public String getCommand() {
65 | return mCommand;
66 | }
67 |
68 | public void setCommand(String command) {
69 | if (command == null || command.isEmpty()) {
70 | throw new IllegalArgumentException("command is required");
71 | }
72 |
73 | mCommand = command;
74 | }
75 |
76 | public Map getParams() {
77 | return mParams;
78 | }
79 |
80 | public void setParams(Map params) {
81 | mParams = params;
82 | }
83 |
84 | /*
85 | * (non-Javadoc)
86 | *
87 | * @see java.lang.Object#toString()
88 | */
89 | @Override
90 | public String toString() {
91 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
92 | if (mParams != null) {
93 | for (Entry entry : mParams.entrySet()) {
94 | toStringBuilder.append(entry.getKey(), entry.getValue());
95 | }
96 | }
97 |
98 | return new ToStringBuilder(this).append("deviceId", mDeviceId).append("command", mCommand)
99 | .append("params", toStringBuilder.toString()).toString();
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/DeviceList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices;
10 |
11 | import java.util.ArrayList;
12 | import java.util.HashMap;
13 | import java.util.List;
14 | import java.util.Map;
15 |
16 | import org.apache.commons.lang3.builder.ToStringBuilder;
17 |
18 | /**
19 | * The {@link DeviceList} represents a device list from ZAutomation API. See also:
20 | * http://docs.zwayhomeautomation.apiary.io/#
21 | *
22 | * @author Patrick Hecker - Initial contribution
23 | */
24 | public class DeviceList {
25 | private List mDevices;
26 |
27 | public DeviceList() {
28 | mDevices = new ArrayList();
29 | }
30 |
31 | public void addDevice(Device device) {
32 | mDevices.add(device);
33 | }
34 |
35 | /**
36 | * @return list of virtual devices
37 | */
38 | public List getDevices() {
39 | ArrayList virtualDevices = new ArrayList();
40 |
41 | for (Device device : mDevices) {
42 | Integer nodeId = device.getNodeId();
43 | if (nodeId == -1) {
44 | virtualDevices.add(device);
45 | }
46 | }
47 |
48 | return virtualDevices;
49 | }
50 |
51 | public List getAllDevices() {
52 | return mDevices;
53 | }
54 |
55 | /**
56 | * Return the first occurrence of device
57 | *
58 | * @param deviceId ZAutomation device id
59 | * @return virtual device
60 | */
61 | public Device getDeviceById(String deviceId) {
62 |
63 | for (Device device : mDevices) {
64 | if (device.getDeviceId().equals(deviceId)) {
65 | return device;
66 | }
67 | }
68 | return null;
69 | }
70 |
71 | /**
72 | * @return list of physical devices with associated virtual devices
73 | */
74 | public Map> getDevicesGroupByNodeId() {
75 | Map> physicalDevices = new HashMap>();
76 |
77 | for (Device device : mDevices) {
78 | Integer nodeId = device.getNodeId();
79 | if (nodeId != -1) {
80 | if (physicalDevices.containsKey(nodeId)) {
81 | physicalDevices.get(nodeId).add(device);
82 | } else {
83 | ArrayList devices = new ArrayList();
84 | devices.add(device);
85 |
86 | physicalDevices.put(nodeId, devices);
87 | }
88 | }
89 | }
90 |
91 | return physicalDevices;
92 | }
93 |
94 | /**
95 | * @param nodeId Z-Wave device node id
96 | * @return list of physical devices with associated virtual devices
97 | */
98 | public Map> getDevicesByNodeId(Integer nodeId) {
99 | Map> physicalDevice = new HashMap>();
100 |
101 | for (Device device : mDevices) {
102 | if (nodeId == device.getNodeId()) {
103 | if (physicalDevice.containsKey(nodeId)) {
104 | physicalDevice.get(nodeId).add(device);
105 | } else {
106 | ArrayList devices = new ArrayList();
107 | devices.add(device);
108 |
109 | physicalDevice.put(nodeId, devices);
110 | }
111 | }
112 | }
113 |
114 | return physicalDevice;
115 | }
116 |
117 | /*
118 | * (non-Javadoc)
119 | *
120 | * @see java.lang.Object#toString()
121 | */
122 | @Override
123 | public String toString() {
124 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
125 | for (Device device : mDevices) {
126 | toStringBuilder.append(device);
127 | }
128 |
129 | return new ToStringBuilder(this).append("deviceList", toStringBuilder.toString()).toString();
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/DeviceListDeserializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices;
10 |
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import com.google.gson.Gson;
15 | import com.google.gson.JsonArray;
16 | import com.google.gson.JsonElement;
17 |
18 | import de.fh_zwickau.informatik.sensor.ZWayConstants;
19 | import de.fh_zwickau.informatik.sensor.model.devices.types.Battery;
20 | import de.fh_zwickau.informatik.sensor.model.devices.types.Camera;
21 | import de.fh_zwickau.informatik.sensor.model.devices.types.Doorlock;
22 | import de.fh_zwickau.informatik.sensor.model.devices.types.SensorBinary;
23 | import de.fh_zwickau.informatik.sensor.model.devices.types.SensorDiscrete;
24 | import de.fh_zwickau.informatik.sensor.model.devices.types.SensorMultilevel;
25 | import de.fh_zwickau.informatik.sensor.model.devices.types.SensorMultiline;
26 | import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchBinary;
27 | import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchControl;
28 | import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchMultilevel;
29 | import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchRGBW;
30 | import de.fh_zwickau.informatik.sensor.model.devices.types.SwitchToggle;
31 | import de.fh_zwickau.informatik.sensor.model.devices.types.Text;
32 | import de.fh_zwickau.informatik.sensor.model.devices.types.Thermostat;
33 | import de.fh_zwickau.informatik.sensor.model.devices.types.ToggleButton;
34 |
35 | /**
36 | * The {@link DeviceListDeserializer} build a device list with known, concrete devices based on JSON data. See also:
37 | * http://docs.zwayhomeautomation.apiary.io/#
38 | *
39 | * @author Patrick Hecker - Initial contribution
40 | */
41 | public class DeviceListDeserializer {
42 |
43 | private Logger logger = LoggerFactory.getLogger(this.getClass());
44 |
45 | /**
46 | * @param devicesAsJson list list as JSON data
47 | * @param commandHandler Z-Way command handler
48 | * @return device list
49 | */
50 | public DeviceList deserializeDeviceList(JsonArray devicesAsJson, IDeviceCommands commandHandler) {
51 | DeviceList deviceList = new DeviceList();
52 |
53 | for (JsonElement deviceAsJson : devicesAsJson) {
54 | Device device = deserializeDevice(deviceAsJson, commandHandler);
55 |
56 | if (device != null) {
57 | deviceList.addDevice(device);
58 | }
59 | }
60 |
61 | return deviceList;
62 | }
63 |
64 | /**
65 | * @param deviceAsJson a single device as JSON data
66 | * @return device
67 | */
68 | public Device deserializeDevice(JsonElement deviceAsJson, IDeviceCommands commandHandler) {
69 | Gson gson = new Gson();
70 |
71 | if (deviceAsJson.getAsJsonObject().has("deviceType")) {
72 | String deviceType = deviceAsJson.getAsJsonObject().get("deviceType").getAsString();
73 | Device device = null;
74 | try {
75 | switch (deviceType) {
76 | case ZWayConstants.DEVICE_TYPE_BATTERY:
77 | device = gson.fromJson(deviceAsJson, Battery.class);
78 | break;
79 | case ZWayConstants.DEVICE_TYPE_DOORLOCK:
80 | device = gson.fromJson(deviceAsJson, Doorlock.class);
81 | break;
82 | case ZWayConstants.DEVICE_TYPE_THERMOSTAT:
83 | device = gson.fromJson(deviceAsJson, Thermostat.class);
84 | break;
85 | case ZWayConstants.DEVICE_TYPE_SWITCH_BINARY:
86 | device = gson.fromJson(deviceAsJson, SwitchBinary.class);
87 | break;
88 | case ZWayConstants.DEVICE_TYPE_SWITCH_MULTILEVEL:
89 | device = gson.fromJson(deviceAsJson, SwitchMultilevel.class);
90 | break;
91 | case ZWayConstants.DEVICE_TYPE_SENSOR_BINARY:
92 | device = gson.fromJson(deviceAsJson, SensorBinary.class);
93 | break;
94 | case ZWayConstants.DEVICE_TYPE_SENSOR_MULTILEVEL:
95 | device = gson.fromJson(deviceAsJson, SensorMultilevel.class);
96 | break;
97 | case ZWayConstants.DEVICE_TYPE_SWITCH_TOGGLE:
98 | device = gson.fromJson(deviceAsJson, SwitchToggle.class);
99 | break;
100 | case ZWayConstants.DEVICE_TYPE_SWITCH_RGBW:
101 | device = gson.fromJson(deviceAsJson, SwitchRGBW.class);
102 | break;
103 | case ZWayConstants.DEVICE_TYPE_SWITCH_CONTROL:
104 | device = gson.fromJson(deviceAsJson, SwitchControl.class);
105 | break;
106 | case ZWayConstants.DEVICE_TYPE_TOGGLE_BUTTON:
107 | device = gson.fromJson(deviceAsJson, ToggleButton.class);
108 | break;
109 | case ZWayConstants.DEVICE_TYPE_TEXT:
110 | device = gson.fromJson(deviceAsJson, Text.class);
111 | break;
112 | case ZWayConstants.DEVICE_TYPE_CAMERA:
113 | device = gson.fromJson(deviceAsJson, Camera.class);
114 | break;
115 | case ZWayConstants.DEVICE_TYPE_SENSOR_DISCRETE:
116 | device = gson.fromJson(deviceAsJson, SensorDiscrete.class);
117 | break;
118 | case ZWayConstants.DEVICE_TYPE_SENSOR_MULTILINE:
119 | device = gson.fromJson(deviceAsJson, SensorMultiline.class);
120 | break;
121 | default:
122 | logger.debug("Unknown device type: " + deviceType);
123 | break;
124 | }
125 |
126 | if (device != null) {
127 | device.setCommandHandler(commandHandler);
128 | }
129 | } catch (Exception e) {
130 | // Prevent to invalidate whole device list if only one device fails.
131 | logger.debug("Deserialize device fails: " + e.getMessage());
132 | device = null;
133 | }
134 |
135 | return device;
136 | } else {
137 | logger.debug("Device type not specified!");
138 | return null;
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/IDeviceCommands.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices;
10 |
11 | /**
12 | * The {@link IDeviceCommands} defines all possible commands from ZAutomation API. See also:
13 | * http://docs.zwayhomeautomation.apiary.io/#
14 | *
15 | * @author Patrick Hecker - Initial contribution
16 | */
17 | public interface IDeviceCommands {
18 | String on(Device device);
19 |
20 | String off(Device device);
21 |
22 | String update(Device device);
23 |
24 | String min(Device device);
25 |
26 | String max(Device device);
27 |
28 | String exact(Device device, String level);
29 |
30 | String exactSmooth(Device device, String level, Integer duration);
31 |
32 | String exact(Device device, Integer red, Integer green, Integer blue);
33 |
34 | String up(Device device);
35 |
36 | String down(Device device);
37 |
38 | String upMax(Device device);
39 |
40 | String startUp(Device device);
41 |
42 | String startDown(Device device);
43 |
44 | String stop(Device device);
45 |
46 | String open(Device device);
47 |
48 | String close(Device device);
49 |
50 | String increase(Device device);
51 |
52 | String decrease(Device device);
53 |
54 | String upstart(Device device);
55 |
56 | String upstop(Device device);
57 |
58 | String downstart(Device device);
59 |
60 | String downstop(Device device);
61 |
62 | // Camera (up, down, open, close already defined)
63 |
64 | String zoomIn(Device device);
65 |
66 | String zoomOut(Device device);
67 |
68 | String left(Device device);
69 |
70 | String right(Device device);
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/Icons.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link Icons} represents the custom icons property of devices. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class Icons {
22 | @SerializedName("default")
23 | private String mDefault;
24 | @SerializedName("level")
25 | private IconsLevel mIconsLevel;
26 |
27 | /**
28 | * Instantiate a icons object with default values.
29 | */
30 | public Icons() {
31 | mDefault = "";
32 | mIconsLevel = new IconsLevel();
33 | }
34 |
35 | public String getDefault() {
36 | if (mDefault == null) {
37 | mDefault = "";
38 | }
39 | return mDefault;
40 | }
41 |
42 | public void setDefault(String defaultIcon) {
43 | this.mDefault = defaultIcon;
44 | }
45 |
46 | public IconsLevel getIconsLevel() {
47 | if (mIconsLevel == null) {
48 | mIconsLevel = new IconsLevel();
49 | }
50 | return mIconsLevel;
51 | }
52 |
53 | public void setIconsLevel(IconsLevel iconsLevel) {
54 | this.mIconsLevel = iconsLevel;
55 | }
56 |
57 | /*
58 | * (non-Javadoc)
59 | *
60 | * @see java.lang.Object#toString()
61 | */
62 | @Override
63 | public String toString() {
64 | return new ToStringBuilder(this).append("default", mDefault).append("level", mIconsLevel).toString();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/IconsLevel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link IconsLevel} represents the custom icons property of devices for level specific icons. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class IconsLevel {
22 | @SerializedName("open")
23 | private String mOpen;
24 | @SerializedName("closed")
25 | private String mClosed;
26 | @SerializedName("down")
27 | private String mDown;
28 | @SerializedName("half")
29 | private String mHalf;
30 | @SerializedName("up")
31 | private String mUp;
32 | @SerializedName("on")
33 | private String mOn;
34 | @SerializedName("off")
35 | private String mOff;
36 |
37 | // Gesture
38 | @SerializedName("press")
39 | private String mPress;
40 | @SerializedName("hold")
41 | private String mHold;
42 | @SerializedName("release")
43 | private String mRelease;
44 | @SerializedName("swipe_up")
45 | private String mSwipeUp;
46 | @SerializedName("swipe_down")
47 | private String mSwipeDown;
48 | @SerializedName("swipe_left")
49 | private String mSwipeLeft;
50 | @SerializedName("swipe_right")
51 | private String mSwipeRight;
52 | @SerializedName("swipe_top_left_to_bottom_right")
53 | private String mSwipeTopLeftToBottomRight;
54 | @SerializedName("swipe_top_right_to_bottom_right")
55 | private String mSwipeTopRightToBottomLeft;
56 | @SerializedName("swipe_bottom_left_to_top_right")
57 | private String mSwipeBottomLeftToTopRight;
58 | @SerializedName("swipe_bottom_right_to_top_left")
59 | private String mSwipeBottomRightToTopLeft;
60 |
61 | /**
62 | * Instantiate a icons object for level specific icons with default values.
63 | */
64 | public IconsLevel() {
65 | mOpen = "";
66 | mClosed = "";
67 | mDown = "";
68 | mUp = "";
69 | mOn = "";
70 | mOff = "";
71 |
72 | mPress = "";
73 | mHold = "";
74 | mRelease = "";
75 | mSwipeUp = "";
76 | mSwipeDown = "";
77 | mSwipeLeft = "";
78 | mSwipeRight = "";
79 | mSwipeTopLeftToBottomRight = "";
80 | mSwipeTopRightToBottomLeft = "";
81 | mSwipeBottomLeftToTopRight = "";
82 | mSwipeBottomRightToTopLeft = "";
83 | }
84 |
85 | public String getOpen() {
86 | if (mOpen == null) {
87 | mOpen = "";
88 | }
89 | return mOpen;
90 | }
91 |
92 | public void setOpen(String open) {
93 | this.mOpen = open;
94 | }
95 |
96 | public String getClosed() {
97 | if (mClosed == null) {
98 | mClosed = "";
99 | }
100 | return mClosed;
101 | }
102 |
103 | public void setClosed(String closed) {
104 | this.mClosed = closed;
105 | }
106 |
107 | public String getDown() {
108 | if (mDown == null) {
109 | mDown = "";
110 | }
111 | return mDown;
112 | }
113 |
114 | public void setDown(String down) {
115 | this.mDown = down;
116 | }
117 |
118 | public String getHalf() {
119 | if (mHalf == null) {
120 | mHalf = "";
121 | }
122 | return mHalf;
123 | }
124 |
125 | public void setHalf(String half) {
126 | this.mHalf = half;
127 | }
128 |
129 | public String getUp() {
130 | if (mUp == null) {
131 | mUp = "";
132 | }
133 | return mUp;
134 | }
135 |
136 | public void setUp(String up) {
137 | this.mUp = up;
138 | }
139 |
140 | public String getOn() {
141 | if (mOn == null) {
142 | mOn = "";
143 | }
144 | return mOn;
145 | }
146 |
147 | public void setOn(String on) {
148 | this.mOn = on;
149 | }
150 |
151 | public String getOff() {
152 | if (mOff == null) {
153 | mOff = "";
154 | }
155 | return mOff;
156 | }
157 |
158 | public void setOff(String off) {
159 | this.mOff = off;
160 | }
161 |
162 | public String getPress() {
163 | if (mPress == null) {
164 | mPress = "";
165 | }
166 | return mPress;
167 | }
168 |
169 | public void setPress(String press) {
170 | this.mPress = press;
171 | }
172 |
173 | public String getHold() {
174 | if (mHold == null) {
175 | mHold = "";
176 | }
177 | return mHold;
178 | }
179 |
180 | public void setHold(String hold) {
181 | this.mHold = hold;
182 | }
183 |
184 | public String getRelease() {
185 | if (mRelease == null) {
186 | mRelease = "";
187 | }
188 | return mRelease;
189 | }
190 |
191 | public void setRelease(String release) {
192 | this.mRelease = release;
193 | }
194 |
195 | public String getSwipeUp() {
196 | if (mSwipeUp == null) {
197 | mSwipeUp = "";
198 | }
199 | return mSwipeUp;
200 | }
201 |
202 | public void setSwipeUp(String swipeUp) {
203 | this.mSwipeUp = swipeUp;
204 | }
205 |
206 | public String getSwipeDown() {
207 | if (mSwipeDown == null) {
208 | mSwipeDown = "";
209 | }
210 | return mSwipeDown;
211 | }
212 |
213 | public void setSwipeDown(String swipeDown) {
214 | this.mSwipeDown = swipeDown;
215 | }
216 |
217 | public String getSwipeLeft() {
218 | if (mSwipeLeft == null) {
219 | mSwipeLeft = "";
220 | }
221 | return mSwipeLeft;
222 | }
223 |
224 | public void setSwipeLeft(String swipeLeft) {
225 | this.mSwipeLeft = swipeLeft;
226 | }
227 |
228 | public String getSwipeRight() {
229 | if (mSwipeRight == null) {
230 | mSwipeRight = "";
231 | }
232 | return mSwipeRight;
233 | }
234 |
235 | public void setSwipeRight(String swipeRight) {
236 | this.mSwipeRight = swipeRight;
237 | }
238 |
239 | public String getSwipeTopLeftToBottomRight() {
240 | if (mSwipeTopLeftToBottomRight == null) {
241 | mSwipeTopLeftToBottomRight = "";
242 | }
243 | return mSwipeTopLeftToBottomRight;
244 | }
245 |
246 | public void setSwipeTopLeftToBottomRight(String swipeTopLeftToBottomRight) {
247 | this.mSwipeTopLeftToBottomRight = swipeTopLeftToBottomRight;
248 | }
249 |
250 | public String getSwipeTopRightToBottomLeft() {
251 | if (mSwipeTopRightToBottomLeft == null) {
252 | mSwipeTopRightToBottomLeft = "";
253 | }
254 | return mSwipeTopRightToBottomLeft;
255 | }
256 |
257 | public void setSwipeTopRightToBottomLeft(String swipeTopRightToBottomLeft) {
258 | this.mSwipeTopRightToBottomLeft = swipeTopRightToBottomLeft;
259 | }
260 |
261 | public String getSwipeBottomLeftToTopRight() {
262 | if (mSwipeBottomLeftToTopRight == null) {
263 | mSwipeBottomLeftToTopRight = "";
264 | }
265 | return mSwipeBottomLeftToTopRight;
266 | }
267 |
268 | public void setSwipeBottomLeftToTopRight(String swipeBottomLeftToTopRight) {
269 | this.mSwipeBottomLeftToTopRight = swipeBottomLeftToTopRight;
270 | }
271 |
272 | public String getSwipeBottomRightToTopLeft() {
273 | if (mSwipeBottomRightToTopLeft == null) {
274 | mSwipeBottomRightToTopLeft = "";
275 | }
276 | return mSwipeBottomRightToTopLeft;
277 | }
278 |
279 | public void setSwipeBottomRightToTopLeft(String swipeBottomRightToTopLeft) {
280 | this.mSwipeBottomRightToTopLeft = swipeBottomRightToTopLeft;
281 | }
282 |
283 | /*
284 | * (non-Javadoc)
285 | *
286 | * @see java.lang.Object#toString()
287 | */
288 | @Override
289 | public String toString() {
290 | return new ToStringBuilder(this).append("open", mOpen).append("closed", mClosed).append("down", mDown)
291 | .append("half", mHalf).append("up", mUp).append("on", mOn).append("off", mOff).append("press", mPress)
292 | .append("hold", mHold).append("release", mRelease).append("swipe_up", mSwipeUp)
293 | .append("swipe_down", mSwipeDown).append("swipe_left", mSwipeLeft).append("swipe_right", mSwipeRight)
294 | .append("swipe_top_left_to_bottom_right", mSwipeTopLeftToBottomRight)
295 | .append("swipe_top_right_to_bottom_right", mSwipeTopRightToBottomLeft)
296 | .append("swipe_bottom_left_to_top_right", mSwipeBottomLeftToTopRight)
297 | .append("swipe_bottom_right_to_top_left", mSwipeBottomRightToTopLeft).toString();
298 | }
299 | }
300 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/Battery.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link Battery} represents a battery from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class Battery extends Device {
20 |
21 | @Override
22 | public String update() {
23 | return mCommandHandler.update(this);
24 | }
25 |
26 | /*
27 | * (non-Javadoc)
28 | *
29 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
30 | */
31 | @Override
32 | public String toString() {
33 | return "Battery [ " + super.toString() + " ]";
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/Camera.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link Camera} represents a camera from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class Camera extends Device {
20 |
21 | @Override
22 | public String zoomIn() {
23 | if (getMetrics().getCameraHasZoomIn()) {
24 | return mCommandHandler.zoomIn(this);
25 | } else {
26 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
27 | }
28 | }
29 |
30 | @Override
31 | public String zoomOut() {
32 | if (getMetrics().getCameraHasZoomOut()) {
33 | return mCommandHandler.zoomOut(this);
34 | } else {
35 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
36 | }
37 | }
38 |
39 | @Override
40 | public String left() {
41 | if (getMetrics().getCameraHasLeft()) {
42 | return mCommandHandler.left(this);
43 | } else {
44 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
45 | }
46 | }
47 |
48 | @Override
49 | public String right() {
50 | if (getMetrics().getCameraHasRight()) {
51 | return mCommandHandler.right(this);
52 | } else {
53 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
54 | }
55 | }
56 |
57 | @Override
58 | public String up() {
59 | if (getMetrics().getCameraHasUp()) {
60 | return mCommandHandler.up(this);
61 | } else {
62 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
63 | }
64 | }
65 |
66 | @Override
67 | public String down() {
68 | if (getMetrics().getCameraHasDown()) {
69 | return mCommandHandler.down(this);
70 | } else {
71 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
72 | }
73 | }
74 |
75 | @Override
76 | public String open() {
77 | if (getMetrics().getCameraHasOpen()) {
78 | return mCommandHandler.open(this);
79 | } else {
80 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
81 | }
82 | }
83 |
84 | @Override
85 | public String close() {
86 | if (getMetrics().getCameraHasClose()) {
87 | return mCommandHandler.close(this);
88 | } else {
89 | throw new UnsupportedOperationException("Operation not supported by device type " + getDeviceType());
90 | }
91 | }
92 |
93 | /*
94 | * (non-Javadoc)
95 | *
96 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
97 | */
98 | @Override
99 | public String toString() {
100 | return "Camera [ " + super.toString() + " ]";
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/Doorlock.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link Doorlock} represents a doorlock from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class Doorlock extends Device {
20 | @Override
21 | public String open() {
22 | return mCommandHandler.open(this);
23 | }
24 |
25 | @Override
26 | public String close() {
27 | return mCommandHandler.close(this);
28 | }
29 |
30 | /*
31 | * (non-Javadoc)
32 | *
33 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
34 | */
35 | @Override
36 | public String toString() {
37 | return "Doorlock [ " + super.toString() + " ]";
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SensorBinary.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SensorBinary} represents a sensor binary from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SensorBinary extends Device {
20 | @Override
21 | public String update() {
22 | return mCommandHandler.update(this);
23 | }
24 |
25 | /*
26 | * (non-Javadoc)
27 | *
28 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
29 | */
30 | @Override
31 | public String toString() {
32 | return "SensorBinary [ " + super.toString() + " ]";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SensorDiscrete.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SensorDiscrete} represents a sensor discrete from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SensorDiscrete extends Device {
20 | @Override
21 | public String update() {
22 | return mCommandHandler.update(this);
23 | }
24 |
25 | /*
26 | * (non-Javadoc)
27 | *
28 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
29 | */
30 | @Override
31 | public String toString() {
32 | return "SensorDiscrete [ " + super.toString() + " ]";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SensorMultilevel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SensorMultilevel} represents a sensor multilevel from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SensorMultilevel extends Device {
20 | @Override
21 | public String update() {
22 | return mCommandHandler.update(this);
23 | }
24 |
25 | /*
26 | * (non-Javadoc)
27 | *
28 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
29 | */
30 | @Override
31 | public String toString() {
32 | return "SensorMultilevel [ " + super.toString() + " ]";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SensorMultiline.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SensorMultiline} represents a sensor multiline from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SensorMultiline extends Device {
20 | @Override
21 | public String update() {
22 | return mCommandHandler.update(this);
23 | }
24 |
25 | /*
26 | * (non-Javadoc)
27 | *
28 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
29 | */
30 | @Override
31 | public String toString() {
32 | return "SensorMultiline [ " + super.toString() + " ]";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SwitchBinary.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SwitchBinary} represents a switch binary from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SwitchBinary extends Device {
20 | @Override
21 | public String on() {
22 | return mCommandHandler.on(this);
23 | }
24 |
25 | @Override
26 | public String off() {
27 | return mCommandHandler.off(this);
28 | }
29 |
30 | @Override
31 | public String update() {
32 | return mCommandHandler.update(this);
33 | }
34 |
35 | /*
36 | * (non-Javadoc)
37 | *
38 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
39 | */
40 | @Override
41 | public String toString() {
42 | return "SwitchBinary [ " + super.toString() + " ]";
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SwitchControl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SwitchControl} represents a switch binary from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SwitchControl extends Device {
20 | @Override
21 | public String on() {
22 | return mCommandHandler.on(this);
23 | }
24 |
25 | @Override
26 | public String off() {
27 | return mCommandHandler.off(this);
28 | }
29 |
30 | @Override
31 | public String exact(String level) {
32 | return mCommandHandler.exact(this, level);
33 | }
34 |
35 | @Override
36 | public String upstart() {
37 | return mCommandHandler.upstart(this);
38 | }
39 |
40 | @Override
41 | public String upstop() {
42 | return mCommandHandler.upstop(this);
43 | }
44 |
45 | @Override
46 | public String downstart() {
47 | return mCommandHandler.downstart(this);
48 | }
49 |
50 | @Override
51 | public String downstop() {
52 | return mCommandHandler.downstop(this);
53 | }
54 |
55 | @Override
56 | public String update() {
57 | return mCommandHandler.update(this);
58 | }
59 |
60 | /*
61 | * (non-Javadoc)
62 | *
63 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
64 | */
65 | @Override
66 | public String toString() {
67 | return "SwitchControl [ " + super.toString() + " ]";
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SwitchMultilevel.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SwitchMultilevel} represents a switch multilevel from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SwitchMultilevel extends Device {
20 | @Override
21 | public String on() {
22 | return mCommandHandler.on(this);
23 | }
24 |
25 | @Override
26 | public String up() {
27 | return mCommandHandler.up(this);
28 | }
29 |
30 | @Override
31 | public String off() {
32 | return mCommandHandler.off(this);
33 | }
34 |
35 | @Override
36 | public String down() {
37 | return mCommandHandler.down(this);
38 | }
39 |
40 | @Override
41 | public String min() {
42 | return mCommandHandler.min(this);
43 | }
44 |
45 | @Override
46 | public String max() {
47 | return mCommandHandler.max(this);
48 | }
49 |
50 | @Override
51 | public String upMax() {
52 | return mCommandHandler.upMax(this);
53 | }
54 |
55 | @Override
56 | public String increase() {
57 | return mCommandHandler.increase(this);
58 | }
59 |
60 | @Override
61 | public String decrease() {
62 | return mCommandHandler.decrease(this);
63 | }
64 |
65 | @Override
66 | public String update() {
67 | return mCommandHandler.update(this);
68 | }
69 |
70 | @Override
71 | public String exact(String level) {
72 | return mCommandHandler.exact(this, level);
73 | }
74 |
75 | @Override
76 | public String exactSmooth(String level, Integer duration) {
77 | return mCommandHandler.exactSmooth(this, level, duration);
78 | }
79 |
80 | @Override
81 | public String stop() {
82 | return mCommandHandler.stop(this);
83 | }
84 |
85 | @Override
86 | public String startUp() {
87 | return mCommandHandler.startUp(this);
88 | }
89 |
90 | @Override
91 | public String startDown() {
92 | return mCommandHandler.startDown(this);
93 | }
94 |
95 | /*
96 | * (non-Javadoc)
97 | *
98 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
99 | */
100 | @Override
101 | public String toString() {
102 | return "SwitchMultilevel [ " + super.toString() + " ]";
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SwitchRGBW.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SwitchRGBW} represents a color switch from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SwitchRGBW extends Device {
20 | @Override
21 | public String on() {
22 | return mCommandHandler.on(this);
23 | }
24 |
25 | @Override
26 | public String off() {
27 | return mCommandHandler.off(this);
28 | }
29 |
30 | @Override
31 | public String exact(Integer red, Integer green, Integer blue) {
32 | return mCommandHandler.exact(this, red, green, blue);
33 | }
34 |
35 | /*
36 | * (non-Javadoc)
37 | *
38 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
39 | */
40 | @Override
41 | public String toString() {
42 | return "SwitchBinary [ " + super.toString() + " ]";
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/SwitchToggle.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link SwitchToggle} represents a switch toggle from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class SwitchToggle extends Device {
20 | @Override
21 | public String on() {
22 | return mCommandHandler.on(this);
23 | }
24 |
25 | /*
26 | * (non-Javadoc)
27 | *
28 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
29 | */
30 | @Override
31 | public String toString() {
32 | return "SwitchToggle [ " + super.toString() + " ]";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/Text.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link Text} represents the text device type from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class Text extends Device {
20 | /*
21 | * (non-Javadoc)
22 | *
23 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
24 | */
25 | @Override
26 | public String toString() {
27 | return "Text [ " + super.toString() + " ]";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/Thermostat.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link Thermostat} represents a thermostat from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class Thermostat extends Device {
20 | @Override
21 | public String exact(String level) {
22 | return mCommandHandler.exact(this, level);
23 | }
24 |
25 | /*
26 | * (non-Javadoc)
27 | *
28 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
29 | */
30 | @Override
31 | public String toString() {
32 | return "Thermostat [ " + super.toString() + " ]";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/devices/types/ToggleButton.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.devices.types;
10 |
11 | import de.fh_zwickau.informatik.sensor.model.devices.Device;
12 |
13 | /**
14 | * The {@link ToggleButton} represents a switch binary from ZAutomation API. See also:
15 | * http://docs.zwayhomeautomation.apiary.io/#
16 | *
17 | * @author Patrick Hecker - Initial contribution
18 | */
19 | public class ToggleButton extends Device {
20 | @Override
21 | public String on() {
22 | return mCommandHandler.on(this);
23 | }
24 |
25 | @Override
26 | public String off() {
27 | return mCommandHandler.off(this);
28 | }
29 |
30 | @Override
31 | public String exact(String level) {
32 | return mCommandHandler.exact(this, level);
33 | }
34 |
35 | @Override
36 | public String upstart() {
37 | return mCommandHandler.upstart(this);
38 | }
39 |
40 | @Override
41 | public String upstop() {
42 | return mCommandHandler.upstop(this);
43 | }
44 |
45 | @Override
46 | public String downstart() {
47 | return mCommandHandler.downstart(this);
48 | }
49 |
50 | @Override
51 | public String downstop() {
52 | return mCommandHandler.downstop(this);
53 | }
54 |
55 | @Override
56 | public String update() {
57 | return mCommandHandler.update(this);
58 | }
59 |
60 | /*
61 | * (non-Javadoc)
62 | *
63 | * @see de.fh_zwickau.informatik.sensor.model.devices.Device#toString()
64 | */
65 | @Override
66 | public String toString() {
67 | return "ToggleButton [ " + super.toString() + " ]";
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/icons/Icon.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.icons;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link Icon} represents a icon. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class Icon {
22 | @SerializedName("file")
23 | private String mFile;
24 | @SerializedName("orgfile")
25 | private String mOrgFile;
26 | @SerializedName("source")
27 | private String mSource;
28 | @SerializedName("name")
29 | private String mName;
30 | @SerializedName("id")
31 | private String mId;
32 | @SerializedName("timestamp")
33 | private Long mTimestamp;
34 | @SerializedName("source_title")
35 | private String mSourceTitle;
36 |
37 | /**
38 | * Instantiate a icon with default values.
39 | */
40 | public Icon() {
41 | mFile = "";
42 | mOrgFile = "";
43 | mSource = "";
44 | mName = "";
45 | mId = "";
46 | mTimestamp = -1l;
47 | mSourceTitle = "";
48 | }
49 |
50 | public String getFile() {
51 | if (mFile == null) {
52 | mFile = "";
53 | }
54 | return mFile;
55 | }
56 |
57 | public void setFile(String file) {
58 | this.mFile = file;
59 | }
60 |
61 | public String getOrgFile() {
62 | if (mOrgFile == null) {
63 | mOrgFile = "";
64 | }
65 | return mOrgFile;
66 | }
67 |
68 | public void setOrgFile(String orgFile) {
69 | this.mOrgFile = orgFile;
70 | }
71 |
72 | public String getSource() {
73 | if (mSource == null) {
74 | mSource = "";
75 | }
76 | return mSource;
77 | }
78 |
79 | public void setSource(String source) {
80 | this.mSource = source;
81 | }
82 |
83 | public String getName() {
84 | if (mName == null) {
85 | mName = "";
86 | }
87 | return mName;
88 | }
89 |
90 | public void setName(String name) {
91 | this.mName = name;
92 | }
93 |
94 | public String getId() {
95 | if (mId == null) {
96 | mId = "";
97 | }
98 | return mId;
99 | }
100 |
101 | public void setId(String id) {
102 | this.mId = id;
103 | }
104 |
105 | public Long getTimestamp() {
106 | if (mTimestamp == null) {
107 | mTimestamp = -1l;
108 | }
109 | return mTimestamp;
110 | }
111 |
112 | public void setTimestamp(Long timestamp) {
113 | this.mTimestamp = timestamp;
114 | }
115 |
116 | public String getSourceTitle() {
117 | if (mSourceTitle == null) {
118 | mSourceTitle = "";
119 | }
120 | return mSourceTitle;
121 | }
122 |
123 | public void setSourceTitle(String sourceTitle) {
124 | this.mSourceTitle = sourceTitle;
125 | }
126 |
127 | /*
128 | * (non-Javadoc)
129 | *
130 | * @see java.lang.Object#toString()
131 | */
132 | @Override
133 | public String toString() {
134 | return new ToStringBuilder(this).append("file", mFile).append("orgfile", mOrgFile).append("source", mSource)
135 | .append("name", mName).append("id", mId).append("timestamp", mTimestamp)
136 | .append("sourceTitle", mSourceTitle).toString();
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/icons/IconList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.icons;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | /**
17 | * The {@link IconList} represents a icon list. See also:
18 | * http://docs.zwayhomeautomation.apiary.io/#
19 | *
20 | * @author Patrick Hecker - Initial contribution
21 | */
22 | public class IconList {
23 | private List mIcons;
24 |
25 | /**
26 | * Instantiate a icon list with default values.
27 | */
28 | public IconList() {
29 | mIcons = new ArrayList();
30 | }
31 |
32 | public void addIcon(Icon icon) {
33 | mIcons.add(icon);
34 | }
35 |
36 | public List getIcons() {
37 | return mIcons;
38 | }
39 |
40 | /*
41 | * (non-Javadoc)
42 | *
43 | * @see java.lang.Object#toString()
44 | */
45 | @Override
46 | public String toString() {
47 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
48 | for (Icon icon : mIcons) {
49 | toStringBuilder.append(icon);
50 | }
51 |
52 | return new ToStringBuilder(this).append("iconList", toStringBuilder.toString()).toString();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/icons/IconListDeserializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.icons;
10 |
11 | import com.google.gson.Gson;
12 | import com.google.gson.JsonArray;
13 | import com.google.gson.JsonElement;
14 |
15 | /**
16 | * The {@link IconListDeserializer} build a icon list with known, concrete icon based on JSON data. See
17 | * also: http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class IconListDeserializer {
22 | /**
23 | * @param iconsAsJson icon list as JSON data
24 | * @return icon list
25 | */
26 | public IconList deserializeIconList(JsonArray iconsAsJson) {
27 | IconList iconList = new IconList();
28 |
29 | for (JsonElement iconAsJson : iconsAsJson) {
30 | Icon icon = deserializeIcon(iconAsJson);
31 |
32 | if (icon != null) {
33 | iconList.addIcon(icon);
34 | }
35 | }
36 |
37 | return iconList;
38 | }
39 |
40 | /**
41 | * @param iconAsJson a single icon as JSON data
42 | * @return icon
43 | */
44 | public Icon deserializeIcon(JsonElement iconAsJson) {
45 | Gson gson = new Gson();
46 |
47 | Icon icon = gson.fromJson(iconAsJson, Icon.class);
48 |
49 | return icon;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/Instance.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances;
10 |
11 | import java.util.Date;
12 |
13 | import org.apache.commons.lang3.builder.ToStringBuilder;
14 |
15 | import com.google.gson.annotations.SerializedName;
16 |
17 | /**
18 | * The {@link Instance} represents a instance. See also:
19 | * http://docs.zwayhomeautomation.apiary.io/#
20 | *
21 | * @author Patrick Hecker - Initial contribution
22 | */
23 | public abstract class Instance {
24 | @SerializedName("instanceId")
25 | private String mInstanceId;
26 | @SerializedName("moduleId")
27 | private String mModuleId;
28 | @SerializedName("active")
29 | private Boolean mActive;
30 | @SerializedName("title")
31 | private String mTitle;
32 | @SerializedName("id")
33 | private Integer mId;
34 | @SerializedName("creationTime")
35 | private Long mCreationTime;
36 |
37 | /**
38 | * Instantiate a instance with default values.
39 | */
40 | public Instance() {
41 | mInstanceId = "";
42 | mModuleId = "";
43 | mActive = true;
44 | mTitle = "";
45 | mId = -1;
46 | mCreationTime = new Date().getTime() / 1000;
47 | }
48 |
49 | public String getInstanceId() {
50 | if (mInstanceId == null) {
51 | mInstanceId = "";
52 | }
53 | return mInstanceId;
54 | }
55 |
56 | public void setInstanceId(String instanceId) {
57 | this.mInstanceId = instanceId;
58 | }
59 |
60 | public String getModuleId() {
61 | if (mModuleId == null) {
62 | mModuleId = "";
63 | }
64 | return mModuleId;
65 | }
66 |
67 | public void setModuleId(String moduleId) {
68 | this.mModuleId = moduleId;
69 | }
70 |
71 | public Boolean getActive() {
72 | if (mActive == null) {
73 | mActive = true;
74 | }
75 | return mActive;
76 | }
77 |
78 | public void setActive(Boolean active) {
79 | this.mActive = active;
80 | }
81 |
82 | public String getTitle() {
83 | if (mTitle == null) {
84 | mTitle = "";
85 | }
86 | return mTitle;
87 | }
88 |
89 | public void setTitle(String title) {
90 | this.mTitle = title;
91 | }
92 |
93 | public Integer getId() {
94 | if (mId == null) {
95 | mId = -1;
96 | }
97 | return mId;
98 | }
99 |
100 | public void setId(Integer id) {
101 | this.mId = id;
102 | }
103 |
104 | public Long getCreationTime() {
105 | if (mCreationTime == null) {
106 | mCreationTime = -1l;
107 | }
108 | return mCreationTime;
109 | }
110 |
111 | public void setCreationTime(Long creationTime) {
112 | this.mCreationTime = creationTime;
113 | }
114 |
115 | /*
116 | * (non-Javadoc)
117 | *
118 | * @see java.lang.Object#toString()
119 | */
120 | @Override
121 | public String toString() {
122 | return new ToStringBuilder(this).append("instanceId", mInstanceId).append("moduleId", mModuleId)
123 | .append("active", mActive).append("title", mTitle).append("id", mId)
124 | .append("creationTime", mCreationTime).toString();
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/InstanceList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | /**
17 | * The {@link InstanceList} represents a instance list. See also:
18 | * http://docs.zwayhomeautomation.apiary.io/#
19 | *
20 | * @author Patrick Hecker - Initial contribution
21 | */
22 | public class InstanceList {
23 | private List mInstances;
24 |
25 | /**
26 | * Instantiate a instance list with default values.
27 | */
28 | public InstanceList() {
29 | mInstances = new ArrayList();
30 | }
31 |
32 | public void addInstance(Instance instance) {
33 | mInstances.add(instance);
34 | }
35 |
36 | public List getInstances() {
37 | return mInstances;
38 | }
39 |
40 | /**
41 | * Return the first occurrence of instance
42 | *
43 | * @param moduleId ZAutomation module id
44 | * @return instance or null if not found
45 | */
46 | public Instance getInstanceByModuleId(String moduleId) {
47 | for (Instance instance : mInstances) {
48 | if (instance.getModuleId().equals(moduleId)) {
49 | return instance;
50 | }
51 | }
52 | return null;
53 | }
54 |
55 | /*
56 | * (non-Javadoc)
57 | *
58 | * @see java.lang.Object#toString()
59 | */
60 | @Override
61 | public String toString() {
62 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
63 | for (Instance instance : mInstances) {
64 | toStringBuilder.append(instance);
65 | }
66 |
67 | return new ToStringBuilder(this).append("instanceList", toStringBuilder.toString()).toString();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/InstanceListDeserializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances;
10 |
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import com.google.gson.Gson;
15 | import com.google.gson.JsonArray;
16 | import com.google.gson.JsonElement;
17 |
18 | import de.fh_zwickau.informatik.sensor.model.instances.dummydevice.DummyDevice;
19 | import de.fh_zwickau.informatik.sensor.model.instances.openhabconnector.OpenHABConnector;
20 |
21 | /**
22 | * The {@link InstanceListDeserializer} build a instance list with known, concrete instances based on JSON data. See
23 | * also: http://docs.zwayhomeautomation.apiary.io/#
24 | *
25 | * @author Patrick Hecker - Initial contribution
26 | */
27 | public class InstanceListDeserializer {
28 |
29 | private Logger logger = LoggerFactory.getLogger(this.getClass());
30 |
31 | /**
32 | * @param instancesAsJson instance list as JSON data
33 | * @return instance list
34 | */
35 | public InstanceList deserializeInstanceList(JsonArray instancesAsJson) {
36 | InstanceList instanceList = new InstanceList();
37 |
38 | for (JsonElement instanceAsJson : instancesAsJson) {
39 | Instance instance = deserializeInstance(instanceAsJson);
40 |
41 | if (instance != null) {
42 | instanceList.addInstance(instance);
43 | }
44 | }
45 |
46 | return instanceList;
47 | }
48 |
49 | /**
50 | * @param instanceAsJson a single instance as JSON data
51 | * @return instance
52 | */
53 | public Instance deserializeInstance(JsonElement instanceAsJson) {
54 | Gson gson = new Gson();
55 |
56 | String moduleId = instanceAsJson.getAsJsonObject().get("moduleId").getAsString();
57 | Instance instance = null;
58 | switch (moduleId) {
59 | case "OpenHABConnector":
60 | instance = gson.fromJson(instanceAsJson, OpenHABConnector.class);
61 | break;
62 | case "DummyDevice":
63 | instance = gson.fromJson(instanceAsJson, DummyDevice.class);
64 | break;
65 | default:
66 | logger.debug("Unknown module id: " + moduleId);
67 | break;
68 | }
69 | return instance;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/dummydevice/DummyDevice.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances.dummydevice;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | import de.fh_zwickau.informatik.sensor.model.instances.Instance;
16 |
17 | /**
18 | * The {@link DummyDevice} represents the instance representation of openHAB connector. See also:
19 | * http://docs.zwayhomeautomation.apiary.io/#
20 | *
21 | * @author Patrick Hecker - Initial contribution
22 | */
23 | public class DummyDevice extends Instance {
24 | @SerializedName("params")
25 | private DummyDeviceParams mParams;
26 |
27 | /**
28 | * Instantiate a openHAB connector with default values.
29 | */
30 | public DummyDevice() {
31 | super();
32 |
33 | setInstanceId("0");
34 | setModuleId("DummyDevice");
35 | setActive(true);
36 | mParams = new DummyDeviceParams();
37 | }
38 |
39 | public DummyDeviceParams getParams() {
40 | if (mParams == null) {
41 | mParams = new DummyDeviceParams();
42 | }
43 | return mParams;
44 | }
45 |
46 | public void setParams(DummyDeviceParams params) {
47 | this.mParams = params;
48 | }
49 |
50 | /*
51 | * (non-Javadoc)
52 | *
53 | * @see de.fh_zwickau.informatik.sensor.model.instances.Instance#toString()
54 | */
55 | @Override
56 | public String toString() {
57 | return new ToStringBuilder(this).append("instance", super.toString()).append("params", mParams).toString();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/dummydevice/DummyDeviceParams.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances.dummydevice;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link DummyDeviceParams} represents a part of dummy device configuration. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class DummyDeviceParams {
22 | @SerializedName("deviceType")
23 | private String mDeviceType;
24 |
25 | /**
26 | * Instantiate a the params part of dummy device configuration with default values.
27 | */
28 | public DummyDeviceParams() {
29 | mDeviceType = "";
30 | }
31 |
32 | public String getDeviceType() {
33 | return mDeviceType;
34 | }
35 |
36 | public void setDeviceType(String deviceType) {
37 | this.mDeviceType = deviceType;
38 | }
39 |
40 | /*
41 | * (non-Javadoc)
42 | *
43 | * @see java.lang.Object#toString()
44 | */
45 | @Override
46 | public String toString() {
47 | return new ToStringBuilder(this).append("deviceType", mDeviceType).toString();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/openhabconnector/OpenHABConnector.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances.openhabconnector;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | import de.fh_zwickau.informatik.sensor.model.instances.Instance;
16 |
17 | /**
18 | * The {@link OpenHABConnector} represents the instance representation of openHAB connector. See also:
19 | * http://docs.zwayhomeautomation.apiary.io/#
20 | *
21 | * @author Patrick Hecker - Initial contribution
22 | */
23 | public class OpenHABConnector extends Instance {
24 | @SerializedName("params")
25 | private OpenHABConnectorParams mParams;
26 |
27 | /**
28 | * Instantiate a openHAB connector with default values.
29 | */
30 | public OpenHABConnector() {
31 | super();
32 |
33 | mParams = new OpenHABConnectorParams();
34 | }
35 |
36 | public OpenHABConnectorParams getParams() {
37 | if (mParams == null) {
38 | mParams = new OpenHABConnectorParams();
39 | }
40 | return mParams;
41 | }
42 |
43 | public void setParams(OpenHABConnectorParams params) {
44 | this.mParams = params;
45 | }
46 |
47 | /*
48 | * (non-Javadoc)
49 | *
50 | * @see de.fh_zwickau.informatik.sensor.model.instances.Instance#toString()
51 | */
52 | @Override
53 | public String toString() {
54 | return new ToStringBuilder(this).append("instance", super.toString()).append("params", mParams).toString();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/openhabconnector/OpenHABConnectorParams.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances.openhabconnector;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link OpenHABConnectorParams} represents a part of openHAB connector configuration. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class OpenHABConnectorParams {
22 | @SerializedName("commonOptions")
23 | private OpenHABConnectorParamsCommonOptions mCommonOptions;
24 |
25 | /**
26 | * Instantiate a the params part of openHAB connector configuration with default values.
27 | */
28 | public OpenHABConnectorParams() {
29 | mCommonOptions = new OpenHABConnectorParamsCommonOptions();
30 | }
31 |
32 | public OpenHABConnectorParamsCommonOptions getCommonOptions() {
33 | if (mCommonOptions == null) {
34 | mCommonOptions = new OpenHABConnectorParamsCommonOptions();
35 | }
36 | return mCommonOptions;
37 | }
38 |
39 | public void setCommonOptions(OpenHABConnectorParamsCommonOptions commonOptions) {
40 | this.mCommonOptions = commonOptions;
41 | }
42 |
43 | /*
44 | * (non-Javadoc)
45 | *
46 | * @see java.lang.Object#toString()
47 | */
48 | @Override
49 | public String toString() {
50 | return new ToStringBuilder(this).append("commonOptions", mCommonOptions).toString();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/openhabconnector/OpenHABConnectorParamsCommonOptions.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances.openhabconnector;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | import com.google.gson.annotations.SerializedName;
17 |
18 | /**
19 | * The {@link OpenHABConnectorParamsCommonOptions} represents a part of openHAB connector configuration. See also:
20 | * http://docs.zwayhomeautomation.apiary.io/#
21 | *
22 | * @author Patrick Hecker - Initial contribution
23 | */
24 | public class OpenHABConnectorParamsCommonOptions {
25 | @SerializedName("openHabServers")
26 | private List mOpenHabServers;
27 |
28 | /**
29 | * Instantiate a the common option part of openHAB connector configuration with default values.
30 | */
31 | public OpenHABConnectorParamsCommonOptions() {
32 | mOpenHabServers = new ArrayList();
33 | }
34 |
35 | public List getOpenHabServers() {
36 | if (mOpenHabServers == null) {
37 | mOpenHabServers = new ArrayList();
38 | }
39 | return mOpenHabServers;
40 | }
41 |
42 | public void setOpenHabServers(List openHabServers) {
43 | this.mOpenHabServers = openHabServers;
44 | }
45 |
46 | /**
47 | * Adds server if not exist in configuration or update ip address and port if openHAB alias is the same.
48 | *
49 | * @param pServer openHAB server
50 | * @return updated or added
51 | */
52 | public boolean updateOpenHabServer(OpenHabConnectorZWayServer pServer) {
53 | boolean serverExist = false;
54 | boolean serverUpdated = false;
55 |
56 | for (OpenHabConnectorZWayServer server : mOpenHabServers) {
57 | if (server.equals(pServer)) {
58 | serverExist = true;
59 | } else if (server.getOpenHabAlias().equals(pServer.getOpenHabAlias())) {
60 | serverUpdated = true;
61 |
62 | server.setIpAddress(pServer.getIpAddress());
63 | server.setPort(pServer.getPort());
64 | }
65 | }
66 |
67 | if (!serverExist && !serverUpdated) {
68 | mOpenHabServers.add(pServer);
69 | }
70 |
71 | if (!serverExist || serverUpdated) {
72 | return true;
73 | } else {
74 | return false;
75 | }
76 | }
77 |
78 | /**
79 | * Removes server if exist.
80 | *
81 | * @param pServer openHAB server
82 | * @return removed
83 | */
84 | public boolean removeOpenHabServer(OpenHabConnectorZWayServer pServer) {
85 | boolean serverExist = false;
86 |
87 | for (OpenHabConnectorZWayServer server : mOpenHabServers) {
88 | if (server.equals(pServer)) {
89 | serverExist = true;
90 | break;
91 | }
92 | }
93 |
94 | if (serverExist) {
95 | mOpenHabServers.remove(pServer);
96 | return true;
97 | }
98 |
99 | return false;
100 | }
101 |
102 | /*
103 | * (non-Javadoc)
104 | *
105 | * @see java.lang.Object#toString()
106 | */
107 | @Override
108 | public String toString() {
109 | return new ToStringBuilder(this).append("openHabServers", mOpenHabServers).toString();
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/instances/openhabconnector/OpenHabConnectorZWayServer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.instances.openhabconnector;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link OpenHabConnectorZWayServer} represents the Z-Way server of openHAB connector. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class OpenHabConnectorZWayServer {
22 | @SerializedName("openHabAlias")
23 | private String mOpenHabAlias;
24 | @SerializedName("ipAddress")
25 | private String mIpAddress;
26 | @SerializedName("port")
27 | private Integer mPort;
28 |
29 | /**
30 | * Instantiate a Z-Way server with default values.
31 | */
32 | public OpenHabConnectorZWayServer() {
33 | mOpenHabAlias = "";
34 | mIpAddress = "";
35 | mPort = -1;
36 | }
37 |
38 | /**
39 | * Instantiate a Z-Way server with passed values.
40 | *
41 | * @param openHabAlias
42 | * @param ipAddress
43 | * @param port
44 | */
45 | public OpenHabConnectorZWayServer(String openHabAlias, String ipAddress, Integer port) {
46 | if (openHabAlias == null || openHabAlias.isEmpty()) {
47 | throw new IllegalArgumentException("openHAB alias is required");
48 | }
49 | if (ipAddress == null || ipAddress.isEmpty()) {
50 | throw new IllegalArgumentException("ip address is required");
51 | }
52 | if (port == null) {
53 | throw new IllegalArgumentException("port is required");
54 | }
55 |
56 | mOpenHabAlias = openHabAlias;
57 | mIpAddress = ipAddress;
58 | mPort = port;
59 | }
60 |
61 | public String getOpenHabAlias() {
62 | if (mOpenHabAlias == null) {
63 | mOpenHabAlias = "";
64 | }
65 | return mOpenHabAlias;
66 | }
67 |
68 | public void setOpenHabAlias(String openHabAlias) {
69 | if (openHabAlias == null || openHabAlias.isEmpty()) {
70 | throw new IllegalArgumentException("openHAB alias is required");
71 | }
72 |
73 | this.mOpenHabAlias = openHabAlias;
74 | }
75 |
76 | public String getIpAddress() {
77 | if (mIpAddress == null) {
78 | mIpAddress = "";
79 | }
80 | return mIpAddress;
81 | }
82 |
83 | public void setIpAddress(String ipAddress) {
84 | if (ipAddress == null || ipAddress.isEmpty()) {
85 | throw new IllegalArgumentException("ip address is required");
86 | }
87 |
88 | this.mIpAddress = ipAddress;
89 | }
90 |
91 | public Integer getPort() {
92 | if (mPort == null) {
93 | mPort = -1;
94 | }
95 | return mPort;
96 | }
97 |
98 | public void setPort(Integer port) {
99 | if (port == null) {
100 | throw new IllegalArgumentException("port is required");
101 | }
102 |
103 | this.mPort = port;
104 | }
105 |
106 | /*
107 | * (non-Javadoc)
108 | *
109 | * @see java.lang.Object#toString()
110 | */
111 | @Override
112 | public String toString() {
113 | return new ToStringBuilder(this).append("openHabAlias", mOpenHabAlias).append("ipAddress", mIpAddress)
114 | .append("port", mPort).toString();
115 | }
116 |
117 | /*
118 | * (non-Javadoc)
119 | *
120 | * @see java.lang.Object#hashCode()
121 | */
122 | @Override
123 | public int hashCode() {
124 | final int prime = 31;
125 | int result = 1;
126 | result = prime * result + ((mIpAddress == null) ? 0 : mIpAddress.hashCode());
127 | result = prime * result + ((mOpenHabAlias == null) ? 0 : mOpenHabAlias.hashCode());
128 | result = prime * result + ((mPort == null) ? 0 : mPort.hashCode());
129 | return result;
130 | }
131 |
132 | /*
133 | * (non-Javadoc)
134 | *
135 | * @see java.lang.Object#equals(java.lang.Object)
136 | */
137 | @Override
138 | public boolean equals(Object obj) {
139 | if (this == obj) {
140 | return true;
141 | }
142 | if (obj == null) {
143 | return false;
144 | }
145 | if (getClass() != obj.getClass()) {
146 | return false;
147 | }
148 | OpenHabConnectorZWayServer other = (OpenHabConnectorZWayServer) obj;
149 | if (mIpAddress == null) {
150 | if (other.mIpAddress != null) {
151 | return false;
152 | }
153 | } else if (!mIpAddress.equals(other.mIpAddress)) {
154 | return false;
155 | }
156 | if (mOpenHabAlias == null) {
157 | if (other.mOpenHabAlias != null) {
158 | return false;
159 | }
160 | } else if (!mOpenHabAlias.equals(other.mOpenHabAlias)) {
161 | return false;
162 | }
163 | if (mPort == null) {
164 | if (other.mPort != null) {
165 | return false;
166 | }
167 | } else if (!mPort.equals(other.mPort)) {
168 | return false;
169 | }
170 | return true;
171 | }
172 | }
173 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/locations/Location.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.locations;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link Location} represents a location. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class Location {
22 | @SerializedName("id")
23 | private Integer mId;
24 | @SerializedName("title")
25 | private String mTitle;
26 | @SerializedName("user_img")
27 | private String mUserImg;
28 |
29 | /**
30 | * Instantiate a location with default values.
31 | */
32 | public Location() {
33 | mId = -1;
34 | mTitle = "";
35 | mUserImg = "";
36 | }
37 |
38 | public Integer getId() {
39 | if (mId == null) {
40 | mId = -1;
41 | }
42 | return mId;
43 | }
44 |
45 | public void setId(Integer id) {
46 | this.mId = id;
47 | }
48 |
49 | public String getTitle() {
50 | if (mTitle == null) {
51 | mTitle = "";
52 | }
53 | return mTitle;
54 | }
55 |
56 | public void setTitle(String title) {
57 | this.mTitle = title;
58 | }
59 |
60 | public String getUserImg() {
61 | if (mUserImg == null) {
62 | mUserImg = "";
63 | }
64 | return mUserImg;
65 | }
66 |
67 | public void setUserImg(String userImg) {
68 | this.mUserImg = userImg;
69 | }
70 |
71 | /*
72 | * (non-Javadoc)
73 | *
74 | * @see java.lang.Object#toString()
75 | */
76 | @Override
77 | public String toString() {
78 | return new ToStringBuilder(this).append("id", mId).append("title", mTitle).append("userImg", mUserImg)
79 | .toString();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/locations/LocationList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.locations;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | /**
17 | * The {@link LocationList} represents a location list. See also:
18 | * http://docs.zwayhomeautomation.apiary.io/#
19 | *
20 | * @author Patrick Hecker - Initial contribution
21 | */
22 | public class LocationList {
23 | private List mLocations;
24 |
25 | /**
26 | * Instantiate a location list with default values.
27 | */
28 | public LocationList() {
29 | mLocations = new ArrayList();
30 | }
31 |
32 | public void addLocation(Location location) {
33 | mLocations.add(location);
34 | }
35 |
36 | public List getLocations() {
37 | return mLocations;
38 | }
39 |
40 | /**
41 | * Return the first occurrence of location
42 | *
43 | * @param id ZAutomation location id
44 | * @return location or null if not found
45 | */
46 | public Location getLocationById(Integer id) {
47 | for (Location location : mLocations) {
48 | if (location.getId().equals(id)) {
49 | return location;
50 | }
51 | }
52 | return null;
53 | }
54 |
55 | /*
56 | * (non-Javadoc)
57 | *
58 | * @see java.lang.Object#toString()
59 | */
60 | @Override
61 | public String toString() {
62 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
63 | for (Location location : mLocations) {
64 | toStringBuilder.append(location);
65 | }
66 |
67 | return new ToStringBuilder(this).append("locationList", toStringBuilder.toString()).toString();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/locations/LocationListDeserializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.locations;
10 |
11 | import com.google.gson.Gson;
12 | import com.google.gson.JsonArray;
13 | import com.google.gson.JsonElement;
14 |
15 | /**
16 | * The {@link LocationListDeserializer} build a location list based on JSON data. See
17 | * also: http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class LocationListDeserializer {
22 | /**
23 | * @param locationsAsJson location list as JSON data
24 | * @return location list
25 | */
26 | public LocationList deserializeLocationList(JsonArray locationsAsJson) {
27 | LocationList locationList = new LocationList();
28 |
29 | for (JsonElement locationAsJson : locationsAsJson) {
30 | Location location = deserializeLocation(locationAsJson);
31 |
32 | if (location != null) {
33 | locationList.addLocation(location);
34 | }
35 | }
36 |
37 | return locationList;
38 | }
39 |
40 | /**
41 | * @param locationAsJson a single location as JSON data
42 | * @return location
43 | */
44 | public Location deserializeLocation(JsonElement locationAsJson) {
45 | Gson gson = new Gson();
46 |
47 | Location location = gson.fromJson(locationAsJson, Location.class);
48 |
49 | return location;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/login/LoginForm.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.login;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link LoginForm} represents the Z-Way login form. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class LoginForm {
22 | @SerializedName("form")
23 | private Boolean mForm;
24 | @SerializedName("login")
25 | private String mLogin;
26 | @SerializedName("password")
27 | private String mPassword;
28 | @SerializedName("keepme")
29 | private Boolean mKeepme;
30 | @SerializedName("default_ui")
31 | private Integer mDefaultUI;
32 |
33 | /**
34 | * Instantiate a login form with default values.
35 | */
36 | public LoginForm() {
37 | mForm = true;
38 | mLogin = "";
39 | mPassword = "";
40 | mKeepme = false;
41 | mDefaultUI = 1;
42 | }
43 |
44 | /**
45 | * Instantiate a login form with passed values.
46 | *
47 | * @param form should be true
48 | * @param login username
49 | * @param password password
50 | * @param keepme should be false
51 | * @param defaultUI should be 1
52 | */
53 | public LoginForm(Boolean form, String login, String password, Boolean keepme, Integer defaultUI) {
54 | mForm = form;
55 | mLogin = login;
56 | mPassword = password;
57 | mKeepme = keepme;
58 | mDefaultUI = defaultUI;
59 | }
60 |
61 | /*
62 | * (non-Javadoc)
63 | *
64 | * @see java.lang.Object#toString()
65 | */
66 | @Override
67 | public String toString() {
68 | return new ToStringBuilder(this).append("form", mForm).append("login", mLogin).append("password", mPassword)
69 | .append("keepme", mKeepme).append("defaultui", mDefaultUI).toString();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/modules/Module.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.modules;
10 |
11 | public class Module {
12 | // TODO
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/modules/ModuleList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.modules;
10 |
11 | public class ModuleList {
12 | // TODO
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/namespaces/Namespace.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.namespaces;
10 |
11 | public class Namespace {
12 | // TODO
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/namespaces/NamespaceList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.namespaces;
10 |
11 | public class NamespaceList {
12 | // TODO
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/notifications/Message.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.notifications;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link Message} represents the message field of a notification. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class Message {
22 | @SerializedName("dev")
23 | private String mDev;
24 | @SerializedName("l")
25 | private String mL;
26 |
27 | public Message() {
28 | mDev = "";
29 | mL = "";
30 | }
31 |
32 | public String getDev() {
33 | if (mDev == null) {
34 | mDev = "";
35 | }
36 | return mDev;
37 | }
38 |
39 | public void setDev(String dev) {
40 | this.mDev = dev;
41 | }
42 |
43 | public String getL() {
44 | if (mL == null) {
45 | mL = "";
46 | }
47 | return mL;
48 | }
49 |
50 | public void setL(String l) {
51 | this.mL = l;
52 | }
53 |
54 | /*
55 | * (non-Javadoc)
56 | *
57 | * @see java.lang.Object#toString()
58 | */
59 | @Override
60 | public String toString() {
61 | return new ToStringBuilder(this).append("dev", mDev).append("l", mL).toString();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/notifications/Notification.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.notifications;
10 |
11 | import java.util.Date;
12 |
13 | import org.apache.commons.lang3.builder.ToStringBuilder;
14 |
15 | import com.google.gson.annotations.SerializedName;
16 |
17 | /**
18 | * The {@link Notification} represents a notification. See also:
19 | * http://docs.zwayhomeautomation.apiary.io/#
20 | *
21 | * @author Patrick Hecker - Initial contribution
22 | */
23 | public class Notification {
24 | @SerializedName("id")
25 | private Long mId;
26 | @SerializedName("timestamp")
27 | private Date mTimestamp;
28 | @SerializedName("level")
29 | private String mLevel;
30 | @SerializedName("message")
31 | private Message mMessage;
32 | @SerializedName("type")
33 | private String mType;
34 | @SerializedName("source")
35 | private String mSource;
36 |
37 | /**
38 | * Instantiate a notification with default values.
39 | */
40 | public Notification() {
41 | mId = -1l;
42 | mTimestamp = new Date();
43 | mLevel = "";
44 | mMessage = new Message();
45 | mType = "";
46 | mSource = "";
47 | }
48 |
49 | public Long getId() {
50 | if (mId == null) {
51 | mId = -1l;
52 | }
53 | return mId;
54 | }
55 |
56 | public void setId(Long id) {
57 | this.mId = id;
58 | }
59 |
60 | public Date getTimestamp() {
61 | if (mTimestamp == null) {
62 | mTimestamp = new Date();
63 | }
64 | return mTimestamp;
65 | }
66 |
67 | public void setTimestamp(Date timestamp) {
68 | this.mTimestamp = timestamp;
69 | }
70 |
71 | public String getLevel() {
72 | if (mLevel == null) {
73 | mLevel = "";
74 | }
75 | return mLevel;
76 | }
77 |
78 | public void setLevel(String level) {
79 | this.mLevel = level;
80 | }
81 |
82 | public Message getMessage() {
83 | if (mMessage == null) {
84 | mMessage = new Message();
85 | }
86 | return mMessage;
87 | }
88 |
89 | public void setMessage(Message message) {
90 | this.mMessage = message;
91 | }
92 |
93 | public String getType() {
94 | if (mType == null) {
95 | mType = "";
96 | }
97 | return mType;
98 | }
99 |
100 | public void setType(String type) {
101 | this.mType = type;
102 | }
103 |
104 | public String getSource() {
105 | if (mSource == null) {
106 | mSource = "";
107 | }
108 | return mSource;
109 | }
110 |
111 | public void setSource(String source) {
112 | this.mSource = source;
113 | }
114 |
115 | /*
116 | * (non-Javadoc)
117 | *
118 | * @see java.lang.Object#toString()
119 | */
120 | @Override
121 | public String toString() {
122 | return new ToStringBuilder(this).append("id", mId).append("timestamp", mTimestamp).append("level", mLevel)
123 | .append("message", mMessage).append("type", mType).append("source", mSource).toString();
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/notifications/NotificationList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.notifications;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | /**
17 | * The {@link NotificationList} represents a notification list. See also:
18 | * http://docs.zwayhomeautomation.apiary.io/#
19 | *
20 | * @author Patrick Hecker - Initial contribution
21 | */
22 | public class NotificationList {
23 | private List mNotifications;
24 |
25 | /**
26 | * Instantiate a instance list with default values.
27 | */
28 | public NotificationList() {
29 | mNotifications = new ArrayList();
30 | }
31 |
32 | public void addNotification(Notification notification) {
33 | mNotifications.add(notification);
34 | }
35 |
36 | public List getNotifications() {
37 | return mNotifications;
38 | }
39 |
40 | /**
41 | * /*
42 | * (non-Javadoc)
43 | *
44 | * @see java.lang.Object#toString()
45 | */
46 | @Override
47 | public String toString() {
48 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
49 | for (Notification notification : mNotifications) {
50 | toStringBuilder.append(notification);
51 | }
52 |
53 | return new ToStringBuilder(this).append("notificationList", toStringBuilder.toString()).toString();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/notifications/NotificationListDeserializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.notifications;
10 |
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import com.google.gson.Gson;
15 | import com.google.gson.GsonBuilder;
16 | import com.google.gson.JsonArray;
17 | import com.google.gson.JsonElement;
18 |
19 | import de.fh_zwickau.informatik.sensor.ZWayConstants;
20 |
21 | /**
22 | * The {@link NotificationListDeserializer} build a notification list based on JSON data. See
23 | * also: http://docs.zwayhomeautomation.apiary.io/#
24 | *
25 | * @author Patrick Hecker - Initial contribution
26 | */
27 | public class NotificationListDeserializer {
28 |
29 | private Logger logger = LoggerFactory.getLogger(this.getClass());
30 |
31 | /**
32 | * @param notificationsAsJson notification list as JSON data
33 | * @return notification list
34 | */
35 | public NotificationList deserializeNotificationList(JsonArray notificationsAsJson) {
36 | NotificationList notificationList = new NotificationList();
37 |
38 | for (JsonElement notificationAsJson : notificationsAsJson) {
39 | Notification notification = deserializeNotification(notificationAsJson);
40 |
41 | if (notification != null) {
42 | notificationList.addNotification(notification);
43 | }
44 | }
45 |
46 | return notificationList;
47 | }
48 |
49 | /**
50 | * @param notificationAsJson a single notification as JSON data
51 | * @return notification
52 | */
53 | public Notification deserializeNotification(JsonElement notificationAsJson) {
54 | Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").create();
55 |
56 | String notificationType = notificationAsJson.getAsJsonObject().get("level").getAsString();
57 | Notification notification = null;
58 | switch (notificationType) {
59 | case ZWayConstants.NOTIFICATION_TYPE_DEVICE_INFO:
60 | notification = gson.fromJson(notificationAsJson, Notification.class);
61 | break;
62 | default:
63 | logger.debug("Unknown notification type: " + notificationType);
64 | }
65 |
66 | return notification;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/profiles/Profile.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.profiles;
10 |
11 | import java.util.HashSet;
12 | import java.util.Set;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | import com.google.gson.annotations.SerializedName;
17 |
18 | /**
19 | * The {@link Profile} represents a notification. See also:
20 | * http://docs.zwayhomeautomation.apiary.io/#
21 | *
22 | * @author Patrick Hecker - Initial contribution
23 | */
24 | public class Profile {
25 | @SerializedName("id")
26 | private Integer mId;
27 | @SerializedName("name")
28 | private String mName;
29 | @SerializedName("lang")
30 | private String mLang;
31 | @SerializedName("color")
32 | private String mColor;
33 | @SerializedName("dashboard")
34 | private Set mDashboard;
35 | @SerializedName("interval")
36 | private Integer mInterval;
37 | @SerializedName("rooms")
38 | private Set mRooms;
39 | @SerializedName("expert_view")
40 | private Boolean mExpertView;
41 | @SerializedName("hide_all_device_events")
42 | private Boolean mHideAllDeviceEvents;
43 | @SerializedName("hide_system_events")
44 | private Boolean mHideSystemEvents;
45 | @SerializedName("hide_single_device_events")
46 | private Set mHideSingleDeviceEvents;
47 | @SerializedName("email")
48 | private String mEmail;
49 |
50 | /**
51 | * Instantiate a profile with default values.
52 | */
53 | public Profile() {
54 | mId = -1;
55 | mName = "";
56 | mLang = "";
57 | mColor = "";
58 | mDashboard = new HashSet<>();
59 | mInterval = -1;
60 | mRooms = new HashSet<>();
61 | mExpertView = false;
62 | mHideAllDeviceEvents = false;
63 | mHideSystemEvents = false;
64 | mHideSingleDeviceEvents = new HashSet<>();
65 | mEmail = "";
66 | }
67 |
68 | public Integer getId() {
69 | if (mId == null) {
70 | mId = -1;
71 | }
72 | return mId;
73 | }
74 |
75 | public void setId(Integer id) {
76 | this.mId = id;
77 | }
78 |
79 | public String getName() {
80 | if (mName == null) {
81 | mName = "";
82 | }
83 | return mName;
84 | }
85 |
86 | public void setName(String name) {
87 | this.mName = name;
88 | }
89 |
90 | public String getLang() {
91 | if (mLang == null) {
92 | mLang = "";
93 | }
94 | return mLang;
95 | }
96 |
97 | public void setLang(String lang) {
98 | this.mLang = lang;
99 | }
100 |
101 | public String getColor() {
102 | if (mColor == null) {
103 | mColor = "";
104 | }
105 | return mColor;
106 | }
107 |
108 | public void setColor(String color) {
109 | this.mColor = color;
110 | }
111 |
112 | public Set getDashboard() {
113 | if (mDashboard == null) {
114 | mDashboard = new HashSet<>();
115 | }
116 | return mDashboard;
117 | }
118 |
119 | public void setDashboard(Set dashboard) {
120 | this.mDashboard = dashboard;
121 | }
122 |
123 | public Integer getInterval() {
124 | if (mInterval == null) {
125 | mInterval = -1;
126 | }
127 | return mInterval;
128 | }
129 |
130 | public void setInterval(Integer interval) {
131 | this.mInterval = interval;
132 | }
133 |
134 | public Set getRooms() {
135 | if (mRooms == null) {
136 | mRooms = new HashSet<>();
137 | }
138 | return mRooms;
139 | }
140 |
141 | public void setRooms(Set rooms) {
142 | this.mRooms = rooms;
143 | }
144 |
145 | public Boolean getExpertView() {
146 | if (mExpertView == null) {
147 | mExpertView = false;
148 | }
149 | return mExpertView;
150 | }
151 |
152 | public void setExpertView(Boolean expertView) {
153 | this.mExpertView = expertView;
154 | }
155 |
156 | public Boolean getHideAllDeviceEvents() {
157 | if (mHideAllDeviceEvents == null) {
158 | mHideAllDeviceEvents = false;
159 | }
160 | return mHideAllDeviceEvents;
161 | }
162 |
163 | public void setHideAllDeviceEvents(Boolean hideAllDeviceEvents) {
164 | this.mHideAllDeviceEvents = hideAllDeviceEvents;
165 | }
166 |
167 | public Boolean getHideSystemEvents() {
168 | if (mHideSystemEvents == null) {
169 | mHideSystemEvents = false;
170 | }
171 | return mHideSystemEvents;
172 | }
173 |
174 | public void setHideSystemEvents(Boolean hideSystemEvents) {
175 | this.mHideSystemEvents = hideSystemEvents;
176 | }
177 |
178 | public Set getHideSingleDeviceEvents() {
179 | if (mHideSingleDeviceEvents == null) {
180 | mHideSingleDeviceEvents = new HashSet<>();
181 | }
182 | return mHideSingleDeviceEvents;
183 | }
184 |
185 | public void setHideSingleDeviceEvents(Set hideSingleDeviceEvents) {
186 | this.mHideSingleDeviceEvents = hideSingleDeviceEvents;
187 | }
188 |
189 | public String getEmail() {
190 | if (mEmail == null) {
191 | mEmail = "";
192 | }
193 | return mEmail;
194 | }
195 |
196 | public void setEmail(String email) {
197 | this.mEmail = email;
198 | }
199 |
200 | /*
201 | * (non-Javadoc)
202 | *
203 | * @see java.lang.Object#toString()
204 | */
205 | @Override
206 | public String toString() {
207 | return new ToStringBuilder(this).append("id", mId).append("name", mName).append("lang", mLang)
208 | .append("color", mColor).append("dashboard", mDashboard).append("interval", mInterval)
209 | .append("rooms", mRooms).append("expertView", mExpertView)
210 | .append("hideAllDeviceEvents", mHideAllDeviceEvents).append("hideSystemEvents", mHideSystemEvents)
211 | .append("hideSingleDeviceEvents", mHideSingleDeviceEvents).append("email", mEmail).toString();
212 | }
213 | }
214 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/profiles/ProfileList.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.profiles;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | /**
17 | * The {@link ProfileList} represents a profile list. See also:
18 | * http://docs.zwayhomeautomation.apiary.io/#
19 | *
20 | * @author Patrick Hecker - Initial contribution
21 | */
22 | public class ProfileList {
23 | private List mProfiles;
24 |
25 | /**
26 | * Instantiate a instance list with default values.
27 | */
28 | public ProfileList() {
29 | mProfiles = new ArrayList();
30 | }
31 |
32 | public void addProfile(Profile profile) {
33 | mProfiles.add(profile);
34 | }
35 |
36 | public List getProfiles() {
37 | return mProfiles;
38 | }
39 |
40 | /**
41 | * /*
42 | * (non-Javadoc)
43 | *
44 | * @see java.lang.Object#toString()
45 | */
46 | @Override
47 | public String toString() {
48 | ToStringBuilder toStringBuilder = new ToStringBuilder(this);
49 | for (Profile profile : mProfiles) {
50 | toStringBuilder.append(profile);
51 | }
52 |
53 | return new ToStringBuilder(this).append("profileList", toStringBuilder.toString()).toString();
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/profiles/ProfileListDeserializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.profiles;
10 |
11 | import com.google.gson.Gson;
12 | import com.google.gson.JsonArray;
13 | import com.google.gson.JsonElement;
14 |
15 | /**
16 | * The {@link ProfileListDeserializer} build a profile list based on JSON data. See
17 | * also: http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class ProfileListDeserializer {
22 | /**
23 | * @param profilesAsJson profile list as JSON data
24 | * @return profile list
25 | */
26 | public ProfileList deserializeProfileList(JsonArray profilesAsJson) {
27 | ProfileList profileList = new ProfileList();
28 |
29 | for (JsonElement profileAsJson : profilesAsJson) {
30 | Profile profile = deserializeProfile(profileAsJson);
31 |
32 | if (profile != null) {
33 | profileList.addProfile(profile);
34 | }
35 | }
36 |
37 | return profileList;
38 | }
39 |
40 | /**
41 | * @param profileAsJson a single profile as JSON data
42 | * @return profile
43 | */
44 | public Profile deserializeProfile(JsonElement profileAsJson) {
45 | Gson gson = new Gson();
46 |
47 | Profile profile = gson.fromJson(profileAsJson, Profile.class);
48 |
49 | return profile;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/system/SystemInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.system;
10 |
11 | import java.util.Date;
12 |
13 | import org.apache.commons.lang3.builder.ToStringBuilder;
14 |
15 | import com.google.gson.annotations.SerializedName;
16 |
17 | /**
18 | * The {@link SystemInfo} represents a data element. See also:
19 | * http://docs.zwayhomeautomation.apiary.io/#
20 | *
21 | * Example:
22 | * "data": {
23 | * "first_start_up": "2016-08-03T19:24:13.208z",
24 | * "count_of_reconnects": 52,
25 | * "current_firmware": "2.3.4",
26 | * "current_firmware_majurity": "..."
27 | * }
28 | *
29 | * @author Patrick Hecker - Initial contribution
30 | */
31 | public class SystemInfo {
32 | @SerializedName("first_start_up")
33 | private Date mFirstStartUp;
34 | @SerializedName("count_of_reconnects")
35 | private Integer mCountOfReconnects;
36 | @SerializedName("current_firmware")
37 | private String mCurrentFirmware;
38 | @SerializedName("current_firmware_majurity")
39 | private String mCurrentFirmwareMajurity;
40 |
41 | /**
42 | * Instantiate a system info element object with default values.
43 | */
44 |
45 | public SystemInfo() {
46 | mFirstStartUp = new Date();
47 | mCountOfReconnects = -1;
48 | mCurrentFirmware = "";
49 | mCurrentFirmwareMajurity = "";
50 | }
51 |
52 | public Date getFirstStartUp() {
53 | if (mFirstStartUp == null) {
54 | mFirstStartUp = new Date();
55 | }
56 | return mFirstStartUp;
57 | }
58 |
59 | public void setFirstStartUp(Date firstStartUp) {
60 | this.mFirstStartUp = firstStartUp;
61 | }
62 |
63 | public Integer getCountOfReconnects() {
64 | if (mCountOfReconnects == null) {
65 | mCountOfReconnects = -1;
66 | }
67 | return mCountOfReconnects;
68 | }
69 |
70 | public void setCountOfReconnects(Integer countOfReconnects) {
71 | this.mCountOfReconnects = countOfReconnects;
72 | }
73 |
74 | public String getCurrentFirmware() {
75 | if (mCurrentFirmware == null) {
76 | mCurrentFirmware = "";
77 | }
78 | return mCurrentFirmware;
79 | }
80 |
81 | public void setCurrentFirmware(String currentFirmware) {
82 | this.mCurrentFirmware = currentFirmware;
83 | }
84 |
85 | public String getCurrentFirmwareMajurity() {
86 | if (mCurrentFirmwareMajurity == null) {
87 | mCurrentFirmwareMajurity = "";
88 | }
89 | return mCurrentFirmwareMajurity;
90 | }
91 |
92 | public void setCurrentFirmwareMajurity(String currentFirmwareMajurity) {
93 | this.mCurrentFirmwareMajurity = currentFirmwareMajurity;
94 | }
95 |
96 | /*
97 | * (non-Javadoc)
98 | *
99 | * @see java.lang.Object#toString()
100 | */
101 | @Override
102 | public String toString() {
103 | return new ToStringBuilder(this).append("first_start_up", mFirstStartUp)
104 | .append("count_of_reconnects", mCountOfReconnects).append("current_firmware", mCurrentFirmware)
105 | .append("current_firmware_majurity", mCurrentFirmwareMajurity).toString();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/ZWaveDataElement.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link ZWaveDataElement} represents a data element. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * Example:
20 | * "givenName": {
21 | * "invalidateTime": 1463302196,
22 | * "updateTime": 1466020714,
23 | * "type": "string",
24 | * "value": "iTemp Sensor"
25 | * }
26 | *
27 | * @author Patrick Hecker - Initial contribution
28 | */
29 | public class ZWaveDataElement {
30 | @SerializedName("invalidateTime")
31 | private Integer mInvalidateTime;
32 | @SerializedName("updateTime")
33 | private Integer mUpdateTime;
34 | @SerializedName("type")
35 | private String mType;
36 | @SerializedName("value")
37 | private String mValue;
38 |
39 | /**
40 | * Instantiate a Z-Wave data element object with default values.
41 | */
42 | public ZWaveDataElement() {
43 | mInvalidateTime = -1;
44 | mUpdateTime = -1;
45 | mType = "";
46 | mValue = "";
47 | }
48 |
49 | public Integer getmInvalidateTime() {
50 | if (mInvalidateTime == null) {
51 | mInvalidateTime = -1;
52 | }
53 | return mInvalidateTime;
54 | }
55 |
56 | public void setInvalidateTime(Integer invalidateTime) {
57 | this.mInvalidateTime = invalidateTime;
58 | }
59 |
60 | public Integer getUpdateTime() {
61 | if (mUpdateTime == null) {
62 | mUpdateTime = -1;
63 | }
64 | return mUpdateTime;
65 | }
66 |
67 | public void setUpdateTime(Integer updateTime) {
68 | this.mUpdateTime = updateTime;
69 | }
70 |
71 | public String getType() {
72 | if (mType == null) {
73 | mType = "";
74 | }
75 | return mType;
76 | }
77 |
78 | public void setType(String type) {
79 | this.mType = type;
80 | }
81 |
82 | public String getValue() {
83 | if (mValue == null) {
84 | mValue = "";
85 | }
86 | return mValue;
87 | }
88 |
89 | public void setValue(String value) {
90 | this.mValue = value;
91 | }
92 |
93 | /*
94 | * (non-Javadoc)
95 | *
96 | * @see java.lang.Object#toString()
97 | */
98 | @Override
99 | public String toString() {
100 | return new ToStringBuilder(this).append("invalidateTime", mInvalidateTime).append("updateTime", mUpdateTime)
101 | .append("type", mType).append("value", mValue).toString();
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/controller/ZWaveController.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.controller;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link ZWaveController} represents the controller from ZWave API. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class ZWaveController {
22 | @SerializedName("data")
23 | private ZWaveControllerData mData;
24 |
25 | /**
26 | * Instantiate a Z-Wave device object with default values.
27 | */
28 | public ZWaveController() {
29 | mData = new ZWaveControllerData();
30 | }
31 |
32 | public ZWaveControllerData getData() {
33 | if (mData == null) {
34 | mData = new ZWaveControllerData();
35 | }
36 | return mData;
37 | }
38 |
39 | public void setData(ZWaveControllerData data) {
40 | this.mData = data;
41 | }
42 |
43 | /*
44 | * (non-Javadoc)
45 | *
46 | * @see java.lang.Object#toString()
47 | */
48 | @Override
49 | public String toString() {
50 | return new ToStringBuilder(this).append("data", mData).toString();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDevice.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link ZWaveDevice} represents a device from ZWave API. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class ZWaveDevice {
22 | @SerializedName("instances")
23 | private ZWaveDeviceInstances mInstances;
24 | @SerializedName("data")
25 | private ZWaveDeviceData mData;
26 | @SerializedName("id")
27 | private Integer mId;
28 |
29 | /**
30 | * Instantiate a Z-Wave device object with default values.
31 | */
32 | public ZWaveDevice() {
33 | mInstances = new ZWaveDeviceInstances();
34 | mData = new ZWaveDeviceData();
35 | mId = -1;
36 | }
37 |
38 | public ZWaveDeviceInstances getInstances() {
39 | if (mInstances == null) {
40 | mInstances = new ZWaveDeviceInstances();
41 | }
42 | return mInstances;
43 | }
44 |
45 | public void setInstances(ZWaveDeviceInstances instances) {
46 | this.mInstances = instances;
47 | }
48 |
49 | public ZWaveDeviceData getData() {
50 | if (mData == null) {
51 | mData = new ZWaveDeviceData();
52 | }
53 | return mData;
54 | }
55 |
56 | public void setData(ZWaveDeviceData data) {
57 | this.mData = data;
58 | }
59 |
60 | public Integer getId() {
61 | if (mId == null) {
62 | mId = -1;
63 | }
64 | return mId;
65 | }
66 |
67 | public void setId(Integer id) {
68 | this.mId = id;
69 | }
70 |
71 | /*
72 | * (non-Javadoc)
73 | *
74 | * @see java.lang.Object#toString()
75 | */
76 | @Override
77 | public String toString() {
78 | return new ToStringBuilder(this).append("instances", mInstances).append("data", mData).append("id", mId)
79 | .toString();
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDeviceInstance.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link ZWaveDeviceInstance} represents a device instance from ZWave API. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class ZWaveDeviceInstance {
22 | @SerializedName("commandClasses")
23 | private ZWaveDeviceInstanceCommandClasses mCommandClasses;
24 | @SerializedName("data")
25 | private ZWaveDeviceInstanceData mData;
26 | @SerializedName("id")
27 | private Integer mId;
28 |
29 | public ZWaveDeviceInstance() {
30 | mCommandClasses = new ZWaveDeviceInstanceCommandClasses();
31 | mData = new ZWaveDeviceInstanceData();
32 | mId = -1;
33 | }
34 |
35 | public ZWaveDeviceInstanceCommandClasses getCommandClasses() {
36 | if (mCommandClasses == null) {
37 | mCommandClasses = new ZWaveDeviceInstanceCommandClasses();
38 | }
39 | return mCommandClasses;
40 | }
41 |
42 | public void setCommandClasses(ZWaveDeviceInstanceCommandClasses commandClasses) {
43 | this.mCommandClasses = commandClasses;
44 | }
45 |
46 | public ZWaveDeviceInstanceData getData() {
47 | if (mData == null) {
48 | mData = new ZWaveDeviceInstanceData();
49 | }
50 | return mData;
51 | }
52 |
53 | public void setData(ZWaveDeviceInstanceData data) {
54 | this.mData = data;
55 | }
56 |
57 | public Integer getId() {
58 | if (mId == null) {
59 | mId = -1;
60 | }
61 | return mId;
62 | }
63 |
64 | public void setId(Integer id) {
65 | this.mId = id;
66 | }
67 |
68 | /*
69 | * (non-Javadoc)
70 | *
71 | * @see java.lang.Object#toString()
72 | */
73 | @Override
74 | public String toString() {
75 | return new ToStringBuilder(this).append("id", mId).append("commandClasses", mCommandClasses)
76 | .append("data", mData).toString();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDeviceInstanceCommandClass64.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import java.util.HashMap;
12 | import java.util.Map;
13 |
14 | import org.apache.commons.lang3.builder.ToStringBuilder;
15 |
16 | import com.google.gson.annotations.SerializedName;
17 |
18 | /**
19 | * The {@link ZWaveDeviceInstanceCommandClass64} represents command class of Z-Wave device instance. See also:
20 | * http://docs.zwayhomeautomation.apiary.io/#
21 | *
22 | * @author Patrick Hecker - Initial contribution
23 | */
24 | public class ZWaveDeviceInstanceCommandClass64 {
25 | @SerializedName("name")
26 | private String mName;
27 | @SerializedName("id")
28 | private Integer mId;
29 | @SerializedName("data")
30 | private ZWaveDeviceInstanceCommandClass64Data mData;
31 |
32 | public ZWaveDeviceInstanceCommandClass64() {
33 | this.mName = "";
34 | this.mId = -1;
35 | this.mData = new ZWaveDeviceInstanceCommandClass64Data();
36 | }
37 |
38 | public ZWaveDeviceInstanceCommandClass64Data getData() {
39 | if (mData == null) {
40 | mData = new ZWaveDeviceInstanceCommandClass64Data();
41 | }
42 | return mData;
43 | }
44 |
45 | public void setData(ZWaveDeviceInstanceCommandClass64Data data) {
46 | this.mData = data;
47 | }
48 |
49 | public String getName() {
50 | if (mName == null) {
51 | mName = "";
52 | }
53 | return mName;
54 | }
55 |
56 | public void setName(String name) {
57 | this.mName = name;
58 | }
59 |
60 | public Integer getId() {
61 | if (mId == null) {
62 | mId = -1;
63 | }
64 | return mId;
65 | }
66 |
67 | public void setId(Integer id) {
68 | this.mId = id;
69 | }
70 |
71 | /*
72 | * extra methods (not zway)
73 | */
74 | public Map getThermostatModes() {
75 | Map modes = new HashMap();
76 |
77 | if (mData.get0() != null && !mData.get0().getModeName().getValue().equals("")) {
78 | modes.put(0, mData.get0().getModeName().getValue());
79 | }
80 |
81 | if (mData.get1() != null && !mData.get1().getModeName().getValue().equals("")) {
82 | modes.put(1, mData.get1().getModeName().getValue());
83 | }
84 |
85 | if (mData.get2() != null && !mData.get2().getModeName().getValue().equals("")) {
86 | modes.put(2, mData.get2().getModeName().getValue());
87 | }
88 |
89 | if (mData.get11() != null && !mData.get11().getModeName().getValue().equals("")) {
90 | modes.put(11, mData.get11().getModeName().getValue());
91 | }
92 |
93 | if (mData.get31() != null && !mData.get31().getModeName().getValue().equals("")) {
94 | modes.put(31, mData.get31().getModeName().getValue());
95 | }
96 |
97 | return modes;
98 | }
99 |
100 | /*
101 | * (non-Javadoc)
102 | *
103 | * @see java.lang.Object#toString()
104 | */
105 | @Override
106 | public String toString() {
107 | return new ToStringBuilder(this).append("name", mName).append("id", mId).append("data", mData).toString();
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDeviceInstanceCommandClass64Data.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | import de.fh_zwickau.informatik.sensor.model.zwaveapi.ZWaveDataElement;
16 |
17 | /**
18 | * The {@link ZWaveDeviceInstanceCommandClass64Data} represents the data field of command class of Z-Wave device
19 | * instance.
20 | * See also:
21 | * http://docs.zwayhomeautomation.apiary.io/#
22 | *
23 | * @author Patrick Hecker - Initial contribution
24 | */
25 | public class ZWaveDeviceInstanceCommandClass64Data {
26 | @SerializedName("support")
27 | private ZWaveDataElement mSupported;
28 | @SerializedName("version")
29 | private ZWaveDataElement mVersion;
30 | @SerializedName("security")
31 | private ZWaveDataElement mSecurity;
32 | @SerializedName("interviewDone")
33 | private ZWaveDataElement mInterviewDone;
34 | @SerializedName("interviewCounter")
35 | private ZWaveDataElement mInterviewCounter;
36 | @SerializedName("modemask")
37 | private ZWaveDataElement mModemask;
38 | @SerializedName("mode")
39 | private ZWaveDataElement mMode;
40 | @SerializedName("0")
41 | private ZWaveDeviceInstanceCommandClass64DataMode m0;
42 | @SerializedName("1")
43 | private ZWaveDeviceInstanceCommandClass64DataMode m1;
44 | @SerializedName("2")
45 | private ZWaveDeviceInstanceCommandClass64DataMode m2;
46 | @SerializedName("11")
47 | private ZWaveDeviceInstanceCommandClass64DataMode m11;
48 | @SerializedName("31")
49 | private ZWaveDeviceInstanceCommandClass64DataMode m31;
50 |
51 | public ZWaveDeviceInstanceCommandClass64Data() {
52 | mSupported = new ZWaveDataElement();
53 | mVersion = new ZWaveDataElement();
54 | mSecurity = new ZWaveDataElement();
55 | mInterviewDone = new ZWaveDataElement();
56 | mInterviewCounter = new ZWaveDataElement();
57 | mModemask = new ZWaveDataElement();
58 | mMode = new ZWaveDataElement();
59 | m0 = new ZWaveDeviceInstanceCommandClass64DataMode();
60 | m1 = new ZWaveDeviceInstanceCommandClass64DataMode();
61 | m2 = new ZWaveDeviceInstanceCommandClass64DataMode();
62 | m11 = new ZWaveDeviceInstanceCommandClass64DataMode();
63 | m31 = new ZWaveDeviceInstanceCommandClass64DataMode();
64 | }
65 |
66 | public ZWaveDataElement getSupported() {
67 | if (mSupported == null) {
68 | mSupported = new ZWaveDataElement();
69 | }
70 | return mSupported;
71 | }
72 |
73 | public void setSupported(ZWaveDataElement supported) {
74 | this.mSupported = supported;
75 | }
76 |
77 | public ZWaveDataElement getVersion() {
78 | if (mVersion == null) {
79 | mVersion = new ZWaveDataElement();
80 | }
81 | return mVersion;
82 | }
83 |
84 | public void setVersion(ZWaveDataElement version) {
85 | this.mVersion = version;
86 | }
87 |
88 | public ZWaveDataElement getSecurity() {
89 | if (mSecurity == null) {
90 | mSecurity = new ZWaveDataElement();
91 | }
92 | return mSecurity;
93 | }
94 |
95 | public void setSecurity(ZWaveDataElement security) {
96 | this.mSecurity = security;
97 | }
98 |
99 | public ZWaveDataElement getInterviewDone() {
100 | if (mInterviewDone == null) {
101 | mInterviewDone = new ZWaveDataElement();
102 | }
103 | return mInterviewDone;
104 | }
105 |
106 | public void setInterviewDone(ZWaveDataElement interviewDone) {
107 | this.mInterviewDone = interviewDone;
108 | }
109 |
110 | public ZWaveDataElement getInterviewCounter() {
111 | if (mInterviewCounter == null) {
112 | mInterviewCounter = new ZWaveDataElement();
113 | }
114 | return mInterviewCounter;
115 | }
116 |
117 | public void setInterviewCounter(ZWaveDataElement interviewCounter) {
118 | this.mInterviewCounter = interviewCounter;
119 | }
120 |
121 | public ZWaveDataElement getModemask() {
122 | if (mModemask == null) {
123 | mModemask = new ZWaveDataElement();
124 | }
125 | return mModemask;
126 | }
127 |
128 | public void setModemask(ZWaveDataElement modemask) {
129 | this.mModemask = modemask;
130 | }
131 |
132 | public ZWaveDataElement getMode() {
133 | if (mMode == null) {
134 | mMode = new ZWaveDataElement();
135 | }
136 | return mMode;
137 | }
138 |
139 | public void setMode(ZWaveDataElement mode) {
140 | this.mMode = mode;
141 | }
142 |
143 | public ZWaveDeviceInstanceCommandClass64DataMode get0() {
144 | if (m0 == null) {
145 | m0 = new ZWaveDeviceInstanceCommandClass64DataMode();
146 | }
147 | return m0;
148 | }
149 |
150 | public void set0(ZWaveDeviceInstanceCommandClass64DataMode p0) {
151 | this.m0 = p0;
152 | }
153 |
154 | public ZWaveDeviceInstanceCommandClass64DataMode get1() {
155 | if (m1 == null) {
156 | m1 = new ZWaveDeviceInstanceCommandClass64DataMode();
157 | }
158 | return m1;
159 | }
160 |
161 | public void set1(ZWaveDeviceInstanceCommandClass64DataMode p1) {
162 | this.m1 = p1;
163 | }
164 |
165 | public ZWaveDeviceInstanceCommandClass64DataMode get2() {
166 | if (m2 == null) {
167 | m2 = new ZWaveDeviceInstanceCommandClass64DataMode();
168 | }
169 | return m2;
170 | }
171 |
172 | public void set2(ZWaveDeviceInstanceCommandClass64DataMode p2) {
173 | this.m2 = p2;
174 | }
175 |
176 | public ZWaveDeviceInstanceCommandClass64DataMode get11() {
177 | if (m11 == null) {
178 | m11 = new ZWaveDeviceInstanceCommandClass64DataMode();
179 | }
180 | return m11;
181 | }
182 |
183 | public void set11(ZWaveDeviceInstanceCommandClass64DataMode p11) {
184 | this.m11 = p11;
185 | }
186 |
187 | public ZWaveDeviceInstanceCommandClass64DataMode get31() {
188 | if (m31 == null) {
189 | m31 = new ZWaveDeviceInstanceCommandClass64DataMode();
190 | }
191 | return m31;
192 | }
193 |
194 | public void set31(ZWaveDeviceInstanceCommandClass64DataMode p31) {
195 | this.m31 = p31;
196 | }
197 |
198 | /*
199 | * (non-Javadoc)
200 | *
201 | * @see java.lang.Object#toString()
202 | */
203 | @Override
204 | public String toString() {
205 | return new ToStringBuilder(this).append("supported", mSupported).append("version", mVersion)
206 | .append("security", mSecurity).append("interviewDone", mInterviewDone)
207 | .append("interviewCounter", mInterviewCounter).append("modemask", mModemask).append("mode", mMode)
208 | .append("0", m0).append("1", m1).append("11", m11).append("31", m31).toString();
209 | }
210 | }
211 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDeviceInstanceCommandClass64DataMode.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | import de.fh_zwickau.informatik.sensor.model.zwaveapi.ZWaveDataElement;
16 |
17 | /**
18 | * The {@link ZWaveDeviceInstanceCommandClass64DataMode} represents modes for command class 64 of Z-Wave device
19 | * instance. See also:
20 | * http://docs.zwayhomeautomation.apiary.io/#
21 | *
22 | * @author Patrick Hecker - Initial contribution
23 | */
24 | public class ZWaveDeviceInstanceCommandClass64DataMode {
25 | @SerializedName("modeName")
26 | private ZWaveDataElement mModeName;
27 |
28 | public ZWaveDeviceInstanceCommandClass64DataMode() {
29 | this.mModeName = new ZWaveDataElement();
30 | }
31 |
32 | public ZWaveDataElement getModeName() {
33 | return mModeName;
34 | }
35 |
36 | public void setModeName(ZWaveDataElement mModeName) {
37 | this.mModeName = mModeName;
38 | }
39 |
40 | /*
41 | * (non-Javadoc)
42 | *
43 | * @see java.lang.Object#toString()
44 | */
45 | @Override
46 | public String toString() {
47 | return new ToStringBuilder(this).append("modeName", mModeName).toString();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDeviceInstanceCommandClasses.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link ZWaveDeviceInstanceCommandClasses} represents the data field of Z-Wave device instance. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class ZWaveDeviceInstanceCommandClasses {
22 | @SerializedName("64")
23 | private ZWaveDeviceInstanceCommandClass64 m64;
24 |
25 | public ZWaveDeviceInstanceCommandClasses() {
26 | this.m64 = new ZWaveDeviceInstanceCommandClass64();
27 | }
28 |
29 | public ZWaveDeviceInstanceCommandClass64 get64() {
30 | if (m64 == null) {
31 | m64 = new ZWaveDeviceInstanceCommandClass64();
32 | }
33 | return m64;
34 | }
35 |
36 | public void set64(ZWaveDeviceInstanceCommandClass64 p64) {
37 | this.m64 = p64;
38 | }
39 |
40 | /*
41 | * (non-Javadoc)
42 | *
43 | * @see java.lang.Object#toString()
44 | */
45 | @Override
46 | public String toString() {
47 | return new ToStringBuilder(this).append("64", m64).toString();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDeviceInstanceData.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | import de.fh_zwickau.informatik.sensor.model.zwaveapi.ZWaveDataElement;
16 |
17 | /**
18 | * The {@link ZWaveDeviceInstanceData} represents the data field of Z-Wave device instance. See also:
19 | * http://docs.zwayhomeautomation.apiary.io/#
20 | *
21 | * @author Patrick Hecker - Initial contribution
22 | */
23 | public class ZWaveDeviceInstanceData {
24 | @SerializedName("dynamic")
25 | private ZWaveDataElement mDynamic;
26 | @SerializedName("genericType")
27 | private ZWaveDataElement mGenericType;
28 | @SerializedName("specificType")
29 | private ZWaveDataElement mSpecificType;
30 | @SerializedName("nodeInfoFrame")
31 | private ZWaveDataElement mNodeInfoFrame;
32 |
33 | public ZWaveDeviceInstanceData() {
34 | this.mDynamic = new ZWaveDataElement();
35 | this.mGenericType = new ZWaveDataElement();
36 | this.mSpecificType = new ZWaveDataElement();
37 | this.mNodeInfoFrame = new ZWaveDataElement();
38 | }
39 |
40 | public ZWaveDataElement getDynamic() {
41 | if (mDynamic == null) {
42 | mDynamic = new ZWaveDataElement();
43 | }
44 | return mDynamic;
45 | }
46 |
47 | public void setDynamic(ZWaveDataElement dynamic) {
48 | this.mDynamic = dynamic;
49 | }
50 |
51 | public ZWaveDataElement getGenericType() {
52 | if (mGenericType == null) {
53 | mGenericType = new ZWaveDataElement();
54 | }
55 | return mGenericType;
56 | }
57 |
58 | public void setGenericType(ZWaveDataElement genericType) {
59 | this.mGenericType = genericType;
60 | }
61 |
62 | public ZWaveDataElement getSpecificType() {
63 | if (mSpecificType == null) {
64 | mSpecificType = new ZWaveDataElement();
65 | }
66 | return mSpecificType;
67 | }
68 |
69 | public void setSpecificType(ZWaveDataElement specificType) {
70 | this.mSpecificType = specificType;
71 | }
72 |
73 | public ZWaveDataElement getNodeInfoFrame() {
74 | if (mNodeInfoFrame == null) {
75 | mNodeInfoFrame = new ZWaveDataElement();
76 | }
77 | return mNodeInfoFrame;
78 | }
79 |
80 | public void setNodeInfoFrame(ZWaveDataElement nodeInfoFrame) {
81 | this.mNodeInfoFrame = nodeInfoFrame;
82 | }
83 |
84 | /*
85 | * (non-Javadoc)
86 | *
87 | * @see java.lang.Object#toString()
88 | */
89 | @Override
90 | public String toString() {
91 | return new ToStringBuilder(this).append("dynamic", mDynamic).append("genericType", mGenericType)
92 | .append("specificType", mSpecificType).append("nodeInfoFrame", mNodeInfoFrame).toString();
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/de/fh_zwickau/informatik/sensor/model/zwaveapi/devices/ZWaveDeviceInstances.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2016 by Software-Systementwicklung Zwickau Research Group
3 | *
4 | * All rights reserved. This program and the accompanying materials
5 | * are made available under the terms of the Eclipse Public License v1.0
6 | * which accompanies this distribution, and is available at
7 | * http://www.eclipse.org/legal/epl-v10.html
8 | */
9 | package de.fh_zwickau.informatik.sensor.model.zwaveapi.devices;
10 |
11 | import org.apache.commons.lang3.builder.ToStringBuilder;
12 |
13 | import com.google.gson.annotations.SerializedName;
14 |
15 | /**
16 | * The {@link ZWaveDeviceInstances} represents a list of device instances from ZWave API. See also:
17 | * http://docs.zwayhomeautomation.apiary.io/#
18 | *
19 | * @author Patrick Hecker - Initial contribution
20 | */
21 | public class ZWaveDeviceInstances {
22 | @SerializedName("0")
23 | private ZWaveDeviceInstance m0;
24 |
25 | public ZWaveDeviceInstances() {
26 | m0 = new ZWaveDeviceInstance();
27 | }
28 |
29 | public ZWaveDeviceInstance get0() {
30 | if (m0 == null) {
31 | m0 = new ZWaveDeviceInstance();
32 | }
33 | return m0;
34 | }
35 |
36 | public void set0(ZWaveDeviceInstance p0) {
37 | this.m0 = p0;
38 | }
39 |
40 | /*
41 | * (non-Javadoc)
42 | *
43 | * @see java.lang.Object#toString()
44 | */
45 | @Override
46 | public String toString() {
47 | return new ToStringBuilder(this).append("0", m0).toString();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------