diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/HalDeConzZigbeeController.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/HalDeConzZigbeeController.java new file mode 100644 index 00000000..2223c6c0 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/HalDeConzZigbeeController.java @@ -0,0 +1,86 @@ +package se.hal.plugin.zigbee; + +import se.hal.HalContext; +import se.hal.intf.*; +import zutil.log.LogUtil; + +import java.util.logging.Logger; + +/** + * Class will handle Zigbee devices through the deConz REST API and with devices supporting. + * + *

+ * Rest documentatiuon for deConz: https://dresden-elektronik.github.io/deconz-rest-doc/ + */ +public class HalDeConzZigbeeController implements HalSensorController, HalEventController, HalAutoScannableController { + private static final Logger logger = LogUtil.getLogger(); + + public static final String CONFIG_ZIGBEE_REST_URL = "zigbee.rest_url"; + public static final String CONFIG_ZIGBEE_REST_PORT = "zigbee.rest_port"; + public static final String CONFIG_ZIGBEE_REST_USERNAME = "zigbee.rest_username"; + public static final String CONFIG_ZIGBEE_REST_PASSWORD = "zigbee.rest_password"; + public static final String CONFIG_ZIGBEE_COM_PORT = "zigbee.com_port"; + + + @Override + public boolean isAvailable() { + return HalContext.containsProperty(CONFIG_ZIGBEE_REST_URL); + } + + @Override + public void initialize() throws Exception { + // connect to deconz + // if username is set use that for basic auth + // else try without username or fail with log message that username should be setup + + // Get API key + } + + + @Override + public void setListener(HalEventReportListener listener) { + + } + + @Override + public void register(HalEventConfig eventConfig) { + + } + + @Override + public void deregister(HalEventConfig eventConfig) { + + } + + @Override + public void send(HalEventConfig eventConfig, HalEventData eventData) { + + } + + + @Override + public void register(HalSensorConfig sensorConfig) { + + } + + @Override + public void deregister(HalSensorConfig sensorConfig) { + + } + + @Override + public void setListener(HalSensorReportListener listener) { + + } + + + @Override + public int size() { + return 0; + } + + @Override + public void close() { + + } +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestConfig.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestConfig.java new file mode 100644 index 00000000..9fe27507 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestConfig.java @@ -0,0 +1,99 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; +import zutil.parser.DataNode; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * The configuration endpoint allows to retreive and modify the current configuration of the gateway. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/configuration/ + */ +public interface DeConzRestConfig { + + /** + * Creates a new API key which provides authorized access to the REST API. + * + * @param deviceType Name of the client application. (required) + * @param username Will be used as username. If not specified a random key will be generated. (optional) + */ + @WSRequestType(HTTP_POST) + @WSPath("/api") + DataNode getAPIKey(String deviceType, String username); + + /** + * Deletes an API key so it can no longer be used. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/config/whitelist/{{apikey2}}") + DataNode deleteAPIKey(String requestApiKey, String deleteApiKey); + + + /** + * Returns the current gateway configuration. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/config") + void getConfiguration(String requestApiKey); + + /** + * Modify configuration parameters. + */ + //@WSRequestType(HTTP_PUT) + //@WSPath("/api/{{requestApiKey}}/config") + //void setConfiguration(String requestApiKey); + + /** + * Returns the full state of the gateway including all its lights, groups, scenes and schedules. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}") + void getFullState(String requestApiKey); + + + /** + * Returns the newest software version available. Starts the update if available (only on raspberry pi). + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/config/update") + void updateSoftware(String requestApiKey); + + /** + * Starts the update firmware process if newer firmware is available. + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/config/updatefirmware") + void updateFirmware(String requestApiKey); + + /** + * Reset the gateway network settings to factory new and/or delete the deCONZ database (config, lights, scenes, groups, schedules, devices, rules). + * + * @param resetGW Set the network settings of the gateway to factory new. (optional) + * @param deleteDB Delete the Database. (optional) + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/config/reset") + void resetGateway(String requestApiKey, boolean resetGW, boolean deleteDB); + + + /** + * Change the Password of the Gateway. The parameter must be a Base64 encoded combination of “:”. + * + * @param username The user name (currently only “delight” is supported). (required) + * @param oldHash String The Base64 encoded combination of “username:old password”. (required) + * @param newHash String The Base64 encoded combination of “username:new password”. (required) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/config/password") + void setPassword(String requestApiKey, String username, String oldHash, String newHash); + + /** + * Resets the username and password to default (“delight”,”delight”). Only possible within 10 minutes after gateway start. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/config/password") + void resetPassword(String requestApiKey); + +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestGroups.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestGroups.java new file mode 100644 index 00000000..b3313c92 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestGroups.java @@ -0,0 +1,79 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; + +import java.util.List; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * Groups are useful to control many lights at once and provide the base to use scenes. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/groups/ + */ +public interface DeConzRestGroups { + + /** + * Creates a new empty group. + * + * @param name The name of the new group. (required) + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/groups") + void createGroup(String requestApiKey, String name); + + /** + * Returns a list of all groups. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/groups") + void getGroups(String requestApiKey); + + /** + * Returns the full state of a group. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/groups/{{groupId}}") + void getGroup(String requestApiKey, int groupId); + + /** + * Sets attributes of a group which are not related to its state. + * + * @param name The name of the group optional + * @param lights IDs of the lights which are members of the group. optional + * @param hidden Indicates the hidden status of the group. Has no effect at the gateway but apps can uses this to hide groups. optional + * @param lightSequence Specify a sorted list of light ids that can be used in apps. optional + * @param multiDeviceIds Append the subsequential light ids of multidevices like the FLS-PP if the app should handle that light differently. + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/groups/{{groupId}}") + void setGroup(String requestApiKey, int groupId, String name, List lights, boolean hidden, List lightSequence, List multiDeviceIds); + + /** + * Sets attributes of a group which are not related to its state. + * + * @param on Set to true to turn the lights on, false to turn them off. optional + * @param toggle Set to true toggles the lights of that group from on to off or vice versa, false has no effect. **Notice:** This setting supersedes the `on` parameter! optional + * @param bri Set the brightness of the group. Depending on the lights 0 might not mean visible "off" but minimum brightness. If the lights are off and the value is greater 0 a on=true shall also be provided. optional + * @param hue Set the color hue of the group. The hue parameter in the HSV color model is between 0°-360° and is mapped to 0..65535 to get 16-bit resolution. optional + * @param sat Set the color saturation of the group. There 0 means no color at all and 255 is the highest saturation of the color. optional + * @param ct Set the Mired color temperature of the group. (2000K - 6500K) optional + * @param xy Set the CIE xy color space coordinates as array [x, y] of real values (0..1). optional + * @param alert Trigger a temporary alert effect: none (lights are not performing an alert), select (lights are blinking a short time), lselect (lights are blinking a longer time). (optional) + * @param effect Trigger an effect of the group: none (no effect), colorloop (the lights of the group will cycle continously through all colors with the speed specified by colorloopspeed). (optional) + * @param colorLoopSpeed Specifies the speed of a colorloop. 1 = very fast, 255 = very slow (default: 15). This parameter only has an effect when it is called together with effect colorloop. (optional) + * @param transitionTime Transition time in 1/10 seconds between two states. (optional) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/groups/{{groupId}}/action") + void setGroupState(String requestApiKey, int groupId, boolean on, boolean toggle, int bri, int hue, int sat, int ct, List xy, String alert, String effect, int colorLoopSpeed, int transitionTime); + + /** + * Deletes a group. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/groups/{{groupId}}") + void deleteGroup(String requestApiKey, int groupId); + +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestLights.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestLights.java new file mode 100644 index 00000000..12e859d4 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestLights.java @@ -0,0 +1,81 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; + +import java.util.List; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * Monitor and control single lights. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/lights/ + */ +public interface DeConzRestLights { + + /** + * Returns a list of all lights. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/lights") + void getLights(String requestApiKey); + + /** + * Returns the full state of a light. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/lights/{{lightId}") + void getLight(String requestApiKey, int lightId); + + /** + * Returns the full state of a light. + * + * @param name Set the name of the light. (required) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/lights/{{lightId}") + void setLight(String requestApiKey, int lightId, String name); + + /** + * Sets the state of a light. + * + * @param on Set to true to turn the lights on, false to turn them off. optional + * @param toggle Set to true toggles the lights of that group from on to off or vice versa, false has no effect. **Notice:** This setting supersedes the `on` parameter! optional + * @param bri Set the brightness of the group. Depending on the lights 0 might not mean visible "off" but minimum brightness. If the lights are off and the value is greater 0 a on=true shall also be provided. optional + * @param hue Set the color hue of the group. The hue parameter in the HSV color model is between 0°-360° and is mapped to 0..65535 to get 16-bit resolution. optional + * @param sat Set the color saturation of the group. There 0 means no color at all and 255 is the highest saturation of the color. optional + * @param ct Set the Mired color temperature of the group. (2000K - 6500K) optional + * @param xy Set the CIE xy color space coordinates as array [x, y] of real values (0..1). optional + * @param alert Trigger a temporary alert effect: none (lights are not performing an alert), select (lights are blinking a short time), lselect (lights are blinking a longer time). (optional) + * @param effect Trigger an effect of the group: none (no effect), colorloop (the lights of the group will cycle continously through all colors with the speed specified by colorloopspeed). (optional) + * @param colorLoopSpeed Specifies the speed of a colorloop. 1 = very fast, 255 = very slow (default: 15). This parameter only has an effect when it is called together with effect colorloop. (optional) + * @param transitionTime Transition time in 1/10 seconds between two states. (optional) + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/lights/{{lightId}/state") + void setLightState(String requestApiKey, int lightId, boolean on, boolean toggle, int bri, int hue, int sat, int ct, List xy, String alert, String effect, int colorLoopSpeed, int transitionTime); + + /** + * Removes the light from the gateway. It will not be shown in any rest api call. Also deletes all groups and scenes on the light device. + * + * @param reset If true sends a network leave command to the light device (may not supported by each manufacturer). (optional) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/lights/{{lightId}") + void deleteLight(String requestApiKey, int lightId, boolean reset); + + /** + * Remove the light from all groups it is a member of. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/lights/{{lightId}/groups") + void deleteGroups(String requestApiKey, int lightId); + + /** + * Remove the light from all scenes it is a member of. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/lights/{{lightId}/scenes") + void deleteScenes(String requestApiKey, int lightId); +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestRules.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestRules.java new file mode 100644 index 00000000..13d49bed --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestRules.java @@ -0,0 +1,73 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; + +import java.util.List; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * Rules provide the ability to trigger actions of lights or groups when a specific sensor condition is met. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/rules/ + */ +public interface DeConzRestRules { + + /** + * Creates a new rule. + *

Note: To create ZigBee bindings between a sensor and a light or group use the BIND method. The rules condition specifies which ZigBee cluster will be used. + * + * @param name The name of the rule. required + * @param periodic Specifies if the rule should trigger periodically. 0 = trigger on event; >0 = time in ms the rule will be triggered periodically. Default is 0. optional + * @param status String ("enabled"|"disabled") + * @param actions An array of actions that will happen when the rule triggers. required + * action.address path to a light, group or scene resource required + * action.body Parameters that will be send to the resource formated as JSON. required + * action.method String Can be PUT, POST, DELETE (currently only used for green power devices) or BIND which will create a ZigBee binding between a sensor and a light or group. required + * @param conditions Array(condition) (1..8) The conditions that must be met to trigger a rule. required + * condition.address String path to a sensor resource and the related state required + * condition.operator String eq, gt, lt, dx (equals, greater than, lower than, on change). required + * condition.value String The value the operator is compared with. Will be casted automatically to the corresponding data type. required + */ + //@WSRequestType(HTTP_POST) + //@WSPath("/api/{{requestApiKey}}/rules") + //void createRule(String requestApiKey, String name, int periodic, String status, List actions, List conditions); + + /** + * Returns a list of all rules. If there are no rules in the system then an empty object {} will be returned. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/rules") + void getRules(String requestApiKey); + + /** + * Returns the rule with the specified id. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/rules/{{ruleId}}") + void getRule(String requestApiKey, int ruleId); + + /** + * Update a rule with the specified parameters. + * + * @param name The name of the rule. required + * @param periodic Specifies if the rule should trigger periodically. 0 = trigger on event; >0 = time in ms the rule will be triggered periodically. Default is 0. optional + * @param status String ("enabled"|"disabled") + * @param actions An array of actions that will happen when the rule triggers. required + * action.address path to a light, group or scene resource required + * action.body Parameters that will be send to the resource formated as JSON. required + * action.method String Can be PUT, POST, DELETE (currently only used for green power devices) or BIND which will create a ZigBee binding between a sensor and a light or group. required + * @param conditions Array(condition) (1..8) The conditions that must be met to trigger a rule. required + * condition.address String path to a sensor resource and the related state required + * condition.operator String eq, gt, lt, dx (equals, greater than, lower than, on change). required + * condition.value String The value the operator is compared with. Will be casted automatically to the corresponding data type. required + */ + //@WSRequestType(HTTP_PUT) + //@WSPath("/api/{{requestApiKey}}/rules/{{ruleId}}") + //void setRule(String requestApiKey, int ruleId, String name, int periodic, String status, List actions, List conditions); + + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/rules/{{ruleId}}") + void deleteRule(String requestApiKey, int ruleId); +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestScenes.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestScenes.java new file mode 100644 index 00000000..5a19e613 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestScenes.java @@ -0,0 +1,83 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; + +import java.util.List; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * Scenes provide an easy and performant way to recall often used states to a group. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/scenes/ + */ +public interface DeConzRestScenes { + + /** + * Creates a new scene for a group. The actual state of each light will become the lights scene state. + * + * @param name The name of the new scene. (required) + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes") + void createScene(String requestApiKey, int groupId, String name); + + /** + * Returns a list of all scenes of a group. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes") + void getScenes(String requestApiKey, int groupId); + + /** + * Returns all attributes of a scene. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes/{{sceneId}}") + void getScene(String requestApiKey, int groupId, int sceneId); + + /** + * Sets attributes of a scene. + * + * @param name Name of the scene. (optional) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes/{{sceneId}}") + void getScene(String requestApiKey, int groupId, int sceneId, String name); + + /** + * Stores the current group state in the scene. The actual state of each light in the group will become the lights scene state. + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes/{{sceneId}}/store") + String storeScene(String requestApiKey, int groupId, int sceneId); + + /** + * Recalls a scene. The actual state of each light in the group will become the lights scene state stored in each light. + * Note: Lights which are not reachable (turned off) won’t be affected! + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes/{{sceneId}}/recall") + void recallScene(String requestApiKey, int groupId, int sceneId); + + /** + * Recalls a scene. The actual state of each light in the group will become the lights scene state stored in each light. + * Note: Lights which are not reachable (turned off) won’t be affected! + * + * @param on Set to true to turn the lights on, false to turn them off. optional + * @param bri Set the brightness of the group. Depending on the lights 0 might not mean visible "off" but minimum brightness. If the lights are off and the value is greater 0 a on=true shall also be provided. optional + * @param xy Set the CIE xy color space coordinates as array [x, y] of real values (0..1). optional + * @param transitionTime Transition time in 1/10 seconds between two states. (optional) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes/{{sceneId}}/state/lights/{{lightId}}/state") + void setSceneState(String requestApiKey, int groupId, int sceneId, int lightId, int on, int bri, int xy, int transitionTime); + + /** + * Deletes a scene. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/groups/{{group_id}}/scenes/{{sceneId}}") + void deleteScene(String requestApiKey, int groupId, int sceneId); +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestSchedules.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestSchedules.java new file mode 100644 index 00000000..0f6a6586 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestSchedules.java @@ -0,0 +1,71 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; + +import java.util.List; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * Schedules provide the ability to trigger timed commands to groups or lights. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/schedules/ + */ +public interface DeConzRestSchedules { + + /** + * Creates a new schedule. + * + * @param name The name of the new schedule. If the name already exists a number will be appended. (optional) + * @param description The description of the schedule. (optional) + * @param command The command to execute when the schedule triggers. (required) + * command.address The address of a light or group resource. (required) + * command.method must be "PUT", (required) + * command.body The state that the light or group will activate when the schedule triggers, (required) + * @param status ("enabled"|"disabled") Whether the schedule is enabled or disabled. Default is enabled. (optional) + * @param autoDelete If true the schedule will be deleted after triggered. Else it will be disabled. Default is true. (optional) + * @param time Time when the schedule shall trigger in UTC ISO 8601:2004 format. (required) + */ + //@WSRequestType(HTTP_POST) + //@WSPath("/api/{{requestApiKey}}/schedules") + //int createSchedule(String requestApiKey, String name, String description, List command, String status, boolean autoDelete, String time); + + /** + * Returns a list of all schedules. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/schedules") + List getSchedules(String requestApiKey); + + /** + * Returns all attributes of a schedule. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/schedules/{{scheduleId}}") + List getSchedule(String requestApiKey, int scheduleId); + + /** + * Creates a new schedule. + * + * @param name The name of the new schedule. If the name already exists a number will be appended. (optional) + * @param description The description of the schedule. (optional) + * @param command The command to execute when the schedule triggers. (required) + * command.address The address of a light or group resource. (required) + * command.method must be "PUT", (required) + * command.body The state that the light or group will activate when the schedule triggers, (required) + * @param status ("enabled"|"disabled") Whether the schedule is enabled or disabled. Default is enabled. (optional) + * @param autoDelete If true the schedule will be deleted after triggered. Else it will be disabled. Default is true. (optional) + * @param time Time when the schedule shall trigger in UTC ISO 8601:2004 format. (required) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/schedules/{{scheduleId}}") + void setSchedule(String requestApiKey, int scheduleId, String name, String description, List command, String status, boolean autoDelete, String time); + + /** + * Returns all attributes of a schedule. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/schedules/{{scheduleId}}") + void deleteSchedule(String requestApiKey, int scheduleId); +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestSensors.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestSensors.java new file mode 100644 index 00000000..33ae9414 --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestSensors.java @@ -0,0 +1,97 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; + +import java.util.List; +import java.util.Map; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * Sensors can be used to measure environment parameters like brightness or activation of a switch. With a corresponding rule they can control lights and groups. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/sensors/ + */ +public interface DeConzRestSensors { + + /** + * Creates a new sensor. + * + * @param name The name of the sensor. required + * @param modelid The model identifier of the sensor. required + * @param swversion The software version of the sensor. required + * @param type The type of the sensor (see: allowed sensor types and its states). required + * @param uniqueid The unique id of the sensor. Should be the MAC address of the device. required + * @param manufacturername The manufacturer name of the sensor. required + * @param state The state of the sensor (see: supported sensor types and its states). optional + * @param config The config of the sensor. (optional) + * on - Bool - default: true + * reachable - Bool - default: true + * battery - Number (0..100) + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/sensors") + void createSensor(String requestApiKey, int groupId, String name, String modelid, String swversion, String type, String uniqueid, String manufacturername, Map state, Map config); + + /** + * Returns a list of all Sensors. If there are no sensors in the system then an empty object {} will be returned. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/sensors") + List getSensor(String requestApiKey); + + /** + * Returns a list of all Sensors. If there are no sensors in the system then an empty object {} will be returned. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/sensors/{{sensorId}}") + void getSensor(String requestApiKey, int sensorId); + + /** + * Update a sensor with the specified parameters. + * + * @param name The name of the sensor. (optional) + * @param mode Only available for dresden elektronik Lighting Switch. Set the mode of the switch. (optional) + * 1 = Scenes mode + * 2 = Two groups mode + * 3 = Color temperature mode + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/sensors/{{sensorId}}") + void setSensor(String requestApiKey, int sensorId, String name, int mode); + + /** + * Update a sensor with the specified parameters. + * + * @param on The on/off status of the sensor. (optional) + * @param reachable The reachable status of the sensor. (optional) + * @param battery The current battery state in percent, only for battery powered devices. (optional) + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/sensors/{{sensorId}}/config") + void setSensorConfig(String requestApiKey, int sensorId, boolean on, boolean reachable, int battery); + + /** + * Update a sensor state with the specified parameters. + * + * @param flag Sensor type | Allowed state | type + * CLIPSwitch buttonevent Number + * CLIPOpenClose open Bool + * CLIPPresence presence Bool + * CLIPTemperature temperature Number + * CLIPGenericFlag flag Bool + * CLIPGenericStatus status Number + * CLIPHumidity humidity Number + */ + @WSRequestType(HTTP_PUT) + @WSPath("/api/{{requestApiKey}}/sensors/{{sensorId}}/state") + void setSensorState(String requestApiKey, String flag); + + /** + * Delete a sensor. + */ + @WSRequestType(HTTP_DELETE) + @WSPath("/api/{{requestApiKey}}/sensors/{{sensorId}}/state") + void deleteSensor(String requestApiKey, int sensorId); +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestTouchlink.java b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestTouchlink.java new file mode 100644 index 00000000..ccf06b9a --- /dev/null +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/deconz/rest/DeConzRestTouchlink.java @@ -0,0 +1,47 @@ +package se.hal.plugin.zigbee.deconz.rest; + +import zutil.net.ws.WSInterface.WSPath; +import zutil.net.ws.WSInterface.WSRequestType; + +import java.util.List; + +import static zutil.net.ws.WSInterface.RequestType.*; + +/** + * The touchlink endpoint allows to communicate with near by located devices. + * + * @link https://dresden-elektronik.github.io/deconz-rest-doc/touchlink/ + */ +public interface DeConzRestTouchlink { + + /** + * Starts scanning on all channels for devices which are located close to the gateway. The whole scan process will take about 10 seconds. + *

Note: While scanning is in progress further API requests which require network access aren’t allowed. + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/touchlink/scan") + void startDeviceScan(String requestApiKey); + + /** + * Returns the results of a touchlink scan. + */ + @WSRequestType(HTTP_GET) + @WSPath("/api/{{requestApiKey}}/touchlink/scan") + void getScanResult(String requestApiKey); + + /** + * Puts a device into identify mode for example a light will blink a few times. + *

Note: touchlinkId must be one of the indentifiers which are returned in the scan result. + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/touchlink/{{touchlinkId}}/identify") + void identifyDevice(String requestApiKey, int touchlinkId); + + /** + * Send a reset to factory new request to a device. + *

Note: touchlinkId must be one of the indentifiers which are returned in the scan result. + */ + @WSRequestType(HTTP_POST) + @WSPath("/api/{{requestApiKey}}/touchlink/{{touchlinkId}}/reset") + void resetDevice(String requestApiKey, int touchlinkId); +} diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zwave/plugin.json b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/plugin.json similarity index 80% rename from plugins/hal-zigbee/src/se/hal/plugin/zwave/plugin.json rename to plugins/hal-zigbee/src/se/hal/plugin/zigbee/plugin.json index 209c89c0..d8c4ee66 100755 --- a/plugins/hal-zigbee/src/se/hal/plugin/zwave/plugin.json +++ b/plugins/hal-zigbee/src/se/hal/plugin/zigbee/plugin.json @@ -2,6 +2,6 @@ "version": 1.0, "name": "Hal-Zigbee", "interfaces": [ - {"se.hal.intf.HalAutoScannableController": "se.hal.plugin.zigbee.HalZigbeeController"} + {"se.hal.intf.HalAutoScannableController": "se.hal.plugin.zigbee.HalDeconzZigbeeController"} ] } \ No newline at end of file diff --git a/plugins/hal-zigbee/src/se/hal/plugin/zwave/HalZigbeeController.java b/plugins/hal-zigbee/src/se/hal/plugin/zwave/HalZigbeeController.java deleted file mode 100644 index 8e091fc1..00000000 --- a/plugins/hal-zigbee/src/se/hal/plugin/zwave/HalZigbeeController.java +++ /dev/null @@ -1,4 +0,0 @@ -package se.hal.plugin.zwave; - -public class HalZigbeeController { -}