Skip to content

Commit

Permalink
Add JRuby examples in READMEs (openhab#16948)
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Tanagra <[email protected]>
  • Loading branch information
jimtng authored and matchews committed Oct 18, 2024
1 parent 889db00 commit b0d5801
Show file tree
Hide file tree
Showing 8 changed files with 395 additions and 178 deletions.
46 changes: 28 additions & 18 deletions bundles/org.openhab.binding.deconz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ There is one bridge (`deconz`) that manages the connection to the deCONZ softwar
These sensors are supported:

| Device type | Resource Type | Thing type |
|-----------------------------------|-----------------------------------|------------------------|
| --------------------------------- | --------------------------------- | ---------------------- |
| Presence Sensor | ZHAPresence, CLIPPresence | `presencesensor` |
| Power Sensor | ZHAPower, CLIPPower | `powersensor` |
| Consumption Sensor | ZHAConsumption | `consumptionsensor` |
Expand All @@ -33,7 +33,7 @@ These sensors are supported:
Additionally, lights, window coverings (blinds), door locks and thermostats are supported:

| Device type | Resource Type | Thing type |
|--------------------------------------|-----------------------------------------------|-------------------------|
| ------------------------------------ | --------------------------------------------- | ----------------------- |
| Dimmable Light | Dimmable light, Dimmable plug-in unit | `dimmablelight` |
| On/Off Light | On/Off light, On/Off plug-in unit, Smart plug | `onofflight` |
| Color Temperature Light | Color temperature light | `colortemperaturelight` |
Expand Down Expand Up @@ -61,7 +61,7 @@ If your device is not discovered, please check the DEBUG log for unknown devices
These configuration parameters are available:

| Parameter | Description | Type | Default |
|------------------|-------------------------------------------------------------------------------------------------------------------------|---------|---------|
| ---------------- | ----------------------------------------------------------------------------------------------------------------------- | ------- | ------- |
| host | Host address (hostname / ip) of deCONZ interface | string | n/a |
| httpPort | Port of deCONZ HTTP interface | string | 80 |
| port | Port of deCONZ Websocket (optional, can be filled automatically) **(Advanced)** | string | n/a |
Expand Down Expand Up @@ -125,7 +125,7 @@ Bridge deconz:deconz:homeserver [ host="192.168.0.10", apikey="ABCDEFGHIJ" ]
The sensor devices support some of the following channels:

| Channel Type ID | Item Type | Access Mode | Description | Thing types |
|-----------------------|--------------------------|-------------|-------------------------------------------------------------------------------------------|---------------------------------------------------|
| --------------------- | ------------------------ | ----------- | ----------------------------------------------------------------------------------------- | ------------------------------------------------- |
| airquality | String | R | Airquality as string | airqualitysensor |
| airqualityppb | Number:Dimensionless | R | Airquality (in parts-per-billion) | airqualitysensor |
| alarm | Switch | R | Status of an alarm: `ON` = alarm was triggered; `OFF` = no alarm | alarmsensor |
Expand Down Expand Up @@ -175,14 +175,14 @@ The `last_seen` channel is added when it is available AND the `lastSeenPolling`
Other devices support

| Channel Type ID | Item Type | Access Mode | Description | Thing types |
|-------------------|----------------------|:-----------:|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| brightness | Dimmer | R/W | Brightness of the light | `dimmablelight`, `colortemperaturelight` |
| ----------------- | -------------------- | :---------: | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| brightness | Dimmer | R/W | Brightness of the light | `dimmablelight`, `colortemperaturelight` |
| switch | Switch | R/W | State of a ON/OFF device | `onofflight` |
| color | Color | R/W | Color of an multi-color light | `colorlight`, `extendedcolorlight`, `lightgroup` |
| color_temperature | Number | R/W | Color temperature in Kelvin. The value range is determined by each individual light | `colortemperaturelight`, `extendedcolorlight`, `lightgroup` |
| effect | String | R/W | Effect selection. Allowed commands are set dynamically | `colorlight` |
| effectSpeed | Number | W | Effect Speed | `colorlight` |
| lock | Switch | R/W | Lock (ON) or unlock (OFF) the doorlock | `doorlock` |
| lock | Switch | R/W | Lock (ON) or unlock (OFF) the doorlock | `doorlock` |
| ontime | Number:Time | W | Timespan for which the light is turned on | all lights |
| position | Rollershutter | R/W | Position of the blind | `windowcovering` |
| heatsetpoint | Number:Temperature | R/W | Target Temperature in °C | `thermostat` |
Expand All @@ -192,7 +192,7 @@ Other devices support
| alert | String | W | Turn alerts on. Allowed commands are `none`, `select` (short blinking), `lselect` (long blinking) | `warningdevice`, `lightgroup`, `dimmablelight`, `colorlight`, `extendedcolorlight`, `colortemperaturelight` |
| all_on | Switch | R | All lights in group are on | `lightgroup` |
| any_on | Switch | R | Any light in group is on | `lightgroup` |
| scene | String | W | Recall a scene. Allowed commands are set dynamically | `lightgroup` |
| scene | String | W | Recall a scene. Allowed commands are set dynamically | `lightgroup` |

**NOTE:** For groups `color` and `color_temperature` are used for sending commands to the group.
Their state represents the last command send to the group, not necessarily the actual state of the group.
Expand All @@ -202,7 +202,7 @@ Their state represents the last command send to the group, not necessarily the a
The dimmer switch additionally supports trigger channels.

| Channel Type ID | Description | Thing types |
|-----------------|--------------------------|----------------------|
| --------------- | ------------------------ | -------------------- |
| buttonevent | Event for switch pressed | switch, colorcontrol |
| gestureevent | Event for gestures | switch |

Expand All @@ -211,7 +211,7 @@ Both will be added during runtime if supported by the switch.
`gestureevent` can trigger one of the following events:

| Gesture | Event |
|----------------------------------|-------|
| -------------------------------- | ----- |
| GESTURE_NONE | 0 |
| GESTURE_SHAKE | 1 |
| GESTURE_DROP | 2 |
Expand All @@ -229,13 +229,13 @@ Thing actions can be used to manage the network and its content.
The `deconz` thing supports a thing action to allow new devices to join the network:

| Action name | Input Value | Return Value | Description |
|------------------------|----------------------|--------------|----------------------------------------------------------------------------------------------------------------|
| ---------------------- | -------------------- | ------------ | -------------------------------------------------------------------------------------------------------------- |
| `permitJoin(duration)` | `duration` (Integer) | - | allows new devices to join for `duration` seconds. Allowed values are 1-240, default is 120 if no value given. |

The `lightgroup` thing supports thing actions for managing scenes:

| Action name | Input Value | Return Value | Description |
|---------------------|-----------------|--------------|-------------------------------------------------------------------------------------------|
| ------------------- | --------------- | ------------ | ----------------------------------------------------------------------------------------- |
| `createScene(name)` | `name` (String) | `newSceneId` | Creates a new scene with the name `name` and returns the new scene's id (if successfull). |
| `deleteScene(id)` | `id` (Integer) | - | Deletes the scene with the given id. |
| `storeScene(id)` | `id` (Integer) | - | Store the current group's state as scene with the given id. |
Expand Down Expand Up @@ -305,10 +305,20 @@ then
end
```

# Thing Actions Example
## Thing Actions Example

:::: tabs

::: tab DSL

```java
val deconzActions = getActions("deconz", "deconz:lightgroup:00212E040ED9:5");
var retVal = deconzActions.createScene("TestScene");
deconzActions.storeScene(retVal.get("newSceneId"));
```

:::

::: tab JavaScript

```javascript
Expand All @@ -319,12 +329,12 @@ end

:::

::: tab DSL
::: tab JRuby

```java
val deconzActions = getActions("deconz", "deconz:lightgroup:00212E040ED9:5");
var retVal = deconzActions.createScene("TestScene");
deconzActions.storeScene(retVal.get("newSceneId"));
```ruby
deconz_thing = things["deconz:lightgroup:00212E040ED9:5"]
retval = deconz_thing.create_scene("TestScene")
deconz_thing.store_scene(retval["newSceneId"])
```

:::
Expand Down
47 changes: 29 additions & 18 deletions bundles/org.openhab.binding.dmx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,19 @@ The next `ON` command uses these values instead of the default (or configuration

## Channels

| Type-ID | Thing | Item | Description |
|-----------------|---------------------|----------------------|----------------------------------------------------|
|brightness |dimmer, tunablewhite |Switch, Dimmer | controls the brightness |
|color |color |Switch, Dimmer, Color | allows to set the color and brightness |
|color_temperature|tunablewhite |Number | allows to set the color temperature |
|brightness_r |color |Switch, Dimmer | controls the brightness of the red channel |
|brightness_g |color |Switch, Dimmer | controls the brightness of the green channel |
|brightness_b |color |Switch, Dimmer | controls the brightness of the blue channel |
|brightness_cw |tunablewhite |Switch, Dimmer | controls the brightness of the cool white channel |
|brightness_ww |tunablewhite |Switch, Dimmer | controls the brightness of the warm white channel |
|control |chaser |String | allows to change the chaser steps |
|switch |chaser |Switch | turns the chaser ON or OFF |
|mute |(all bridges) |Switch | mutes the DMX output of the bridge |
| Type-ID | Thing | Item | Description |
| ----------------- | -------------------- | --------------------- | ------------------------------------------------- |
| brightness | dimmer, tunablewhite | Switch, Dimmer | controls the brightness |
| color | color | Switch, Dimmer, Color | allows to set the color and brightness |
| color_temperature | tunablewhite | Number | allows to set the color temperature |
| brightness_r | color | Switch, Dimmer | controls the brightness of the red channel |
| brightness_g | color | Switch, Dimmer | controls the brightness of the green channel |
| brightness_b | color | Switch, Dimmer | controls the brightness of the blue channel |
| brightness_cw | tunablewhite | Switch, Dimmer | controls the brightness of the cool white channel |
| brightness_ww | tunablewhite | Switch, Dimmer | controls the brightness of the warm white channel |
| control | chaser | String | allows to change the chaser steps |
| switch | chaser | Switch | turns the chaser ON or OFF |
| mute | (all bridges) | Switch | mutes the DMX output of the bridge |

_Note:_ the string send to the control channel of chaser things has to be formatted like the `steps` configuration of the chaser thing.
If the new string is invalid, the old configuration will be used.
Expand All @@ -216,19 +216,19 @@ There is a separate instance for each bridge, which can be retrieved e.g. throug

::: tab DSL

```php
```java
val dmxActions = getActions("dmx","dmx:sacn-bridge:mydmxbridge")
```

where the first parameter always has to be `dmx` and the second is the full Thing UID of the bridge that should be used.
Once this action instance is retrieved, you can invoke the `sendFade(String channels, String fade, Boolean resumeAfter)` method on it:

```php
```java
dmxActions.sendFade("1:41/3","10000:255,255,255:-1", false)
```

The parameters are the same as in a chaser thing configuration.
Defining more than one step in `fadeString` is supported, too.
Defining more than one step in `fadeString` is supported.

:::

Expand All @@ -237,11 +237,22 @@ Defining more than one step in `fadeString` is supported, too.
The first parameter always has to be `dmx` and the second is the full Thing UID of the bridge that should be used.

```javascript
actions.get("dmx","dmx:sacn-bridge:mydmxbridge").sendFade("1:41/3","10000:255,255,255:-1", false);
actions.get("dmx","dmx:sacn-bridge:mydmxbridge").sendFade("1:41/3", "10000:255,255,255:-1", false);
```

The sendFade parameters are the same as in a chaser thing configuration.
Defining more than one step in `fadeString` is supported, too.
Defining more than one step in `fadeString` is supported.

:::

::: tab JRuby

```ruby
things["dmx:sacn-bridge:mydmxbridge"].send_fade("1:41/3", "10000:255,255,255:-1", false)
```

The `send_fade` parameters are the same as in a chaser thing configuration.
Defining more than one step in `fadeString` is supported.

:::

Expand Down
Loading

0 comments on commit b0d5801

Please sign in to comment.