Skip to content

Commit

Permalink
[openhabcloud] Further README improvements (openhab#16942)
Browse files Browse the repository at this point in the history
Also-by: Jimmy Tanagra <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 authored Jun 28, 2024
1 parent ae34f95 commit 7475e5d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 20 deletions.
97 changes: 77 additions & 20 deletions bundles/org.openhab.io.openhabcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,39 @@ The openHAB Cloud service (and thus the connector to it) is useful for different

## Installation via UI

* Open the openHAB web portal and login as an administrator.
* Click on Add-on Store, followed by Other
* Using the Install button you can install the openHAB Cloud Connector
* Register your session (https://myopenhab.org/) using UUID and Secret identity
* Open the openHAB web UI and login as an administrator.
* Click on Add-on Store, followed by System Integrations.
* Use the Install button to install the openHAB Cloud Connector.
* Register your session (https://myopenhab.org/) using UUID and Secret.

## UUID and Secret

To authenticate with the openHAB Cloud service the add-on generates two values when the add-on is installed.
To authenticate with the openHAB Cloud service, the add-on generates two values when the add-on is installed.
These values need to be entered in your account settings of the openHAB Cloud service.

The first one is a unique identifier, which allows to identify your runtime.
One can think of it as something similar like a username for the cloud authentication.
The second one is a random secret key which serves as a password.
Both values are written to the local file system.

If you loose these files for some reason, openHAB will automatically generate new ones.
You will then have to reconfigure UUID and secret in the openHAB Cloud service under the _My account_ section.
You will need these values to register on the website before connection is accepted.

Location of UUID and Secret:

| File | Regular Installation | APT Installation |
|--------|------------------------------|---------------------------------------|
| UUID | userdata/uuid | /var/lib/openhab/uuid |
| Secret | userdata/openhabcloud/secret | /var/lib/openhab/openhabcloud/secret |
| File | Regular Installation | APT & RPM Installation |
|--------|---------------------------------------|--------------------------------------|
| UUID | $OPENHAB_USERDATA/uuid | /var/lib/openhab/uuid |
| Secret | $OPENHAB_USERDATA/openhabcloud/secret | /var/lib/openhab/openhabcloud/secret |

## Configuration

After installing this add-on, you will find configuration options in the openHAB portal under _Settings -> Add-on Settings -> openHAB Cloud Connector_:

![Configuration](doc/configuration.png)

By default both remote access and push notifications are enabled.
By default, both remote access and push notifications are enabled.

### Advanced Configuration

Expand Down Expand Up @@ -105,7 +107,7 @@ The parameters for these actions have the following meaning:

- `emailAddress`: String containing the email address the target user is registered with in the cloud instance.
- `message`: String containing the notification message text.
- `icon`: String containing the icon name (as described in [Items]({{base}}/configuration/items.html#icons)).
- `icon`: String containing the icon name (as described in [Items: Icons]({{base}}/configuration/items.html#icons)).
- `severity`: String containing a description of the severity of the incident.

`null` may be used to skip the `icon` or `severity` parameter.
Expand Down Expand Up @@ -133,15 +135,15 @@ The additional parameter for these variants have the following meaning:
- `title`: The title of the notification. Defaults to "openHAB" inside the Android and iOS apps.
- `onClickAction`: The action to be performed when the user clicks on the notification. Specified using the [action syntax](#action-syntax).
- `mediaAttachmentUrl`: The URL of the media attachment to be displayed with the notification. This URL must be reachable by the push notification client.
- `actionButton1`: The action to be performed when the user clicks on the first action button. Specified as `Titel=$action`, where `$action` follow the [action syntax](#action-syntax).
- `actionButton2`: The action to be performed when the user clicks on the second action button. Specified as `Titel=$action`, where `$action` follow the [action syntax](#action-syntax).
- `actionButton3`: The action to be performed when the user clicks on the third action button. Specified as `Titel=$action`, where `$action` follow the [action syntax](#action-syntax).
- `actionButton1`: The action to be performed when the user clicks on the first action button. Specified as `Title=$action`, where `$action` follows the [action syntax](#action-syntax).
- `actionButton2`: The action to be performed when the user clicks on the second action button. Specified as `Title=$action`, where `$action` follows the [action syntax](#action-syntax).
- `actionButton3`: The action to be performed when the user clicks on the third action button. Specified as `Title=$action`, where `$action` follows the [action syntax](#action-syntax).

These parameters may be skipped by setting them to `null`.

#### Action Syntax

The action syntax is a string containing the action type and the action payload seperated by a colon.
The action syntax is a string containing the action type and the action payload separated by a colon.

There are two types of actions available:

Expand All @@ -167,7 +169,7 @@ Notify the openHAB Cloud user with email address [email protected]_ that the front d

::: tab DSL

```java
```java
rule "Front Door Notification"
when
Item Apartment_FrontDoor changed to OPEN
Expand All @@ -181,12 +183,29 @@ end

```javascript
rules.when().item('Apartment_FrontDoor').changed().to('OPEN').then(() => {
actions.notificationBuilder('Front door was opened!').addUserId('[email protected]').send();
actions.notificationBuilder('Front door was opened!')
.addUserId('[email protected]')
.send();
}).build('Front Door Notification');
```

:::

::: tab JRuby

```ruby
rule "Front Door Notification" do
changed Apartment_FrontDoor, to: OPEN
run do
notify("Front door was opened!", email: "[email protected]")
end
end
```

See [notify](https://openhab.github.io/openhab-jruby/main/OpenHAB/Core/Actions.html#notify-class_method)

:::

::::

Notify all openHAB Cloud users that the window was opened:
Expand All @@ -210,15 +229,33 @@ end

```javascript
rules.when().item('Apartment_Window').changed().to('OPEN').then(() => {
actions.notificationBuilder('Apartment window was opened!').withIcon('window').withSeverity('HIGH').send();
actions.notificationBuilder('Apartment window was opened!')
.withIcon('window')
.withSeverity('HIGH')
.send();
}).build('Open Window Notification');
```

:::

::: tab JRuby

Broadcast notification is performed by calling [notify](https://openhab.github.io/openhab-jruby/main/OpenHAB/Core/Actions.html#notify-class_method) without providing an email address.

```ruby
rule "Open Window Notification" do
changed Apartment_Window, to: OPEN
run do
notify("Apartment window was opened!", icon: "window", severity: "HIGH")
end
end
```

:::

::::

Notify all openHAB Cloud users that motion was detected, attach a camera snapshot and add action button to turn on the light:
Notify all openHAB Cloud users that motion was detected, attach a camera snapshot and add an action button to turn on the light:

:::: tabs

Expand All @@ -229,7 +266,9 @@ rule "Motion Detected Notification"
when
Item Apartment_MotionSensor changed to ON
then
sendBroadcastNotification("Motion detected in the apartment!", "motion", "MEDIUM", "Motion Detected", null, "https://apartment.my/camera-snapshot.jpg", "command:Apartment_Light:ON", null, null)
sendBroadcastNotification("Motion detected in the apartment!", "motion", "MEDIUM",
"Motion Detected", null, "https://apartment.my/camera-snapshot.jpg",
"Turn on the light=command:Apartment_Light:ON", null, null)
end
```

Expand All @@ -251,4 +290,22 @@ rules.when().item('Apartment_MotionSensor').changed().to('ON').then(() => {

:::

::: tab JRuby

```ruby
rule "Motion Detected Notification" do
changed Apartment_MotionSensor, to: ON
run do
notify "Motion detected in the apartment!",
icon: "motion",
severity: "MEDIUM",
title: "Motion Detected",
attachment: "https://apartment.my/camera-snapshot.jpg",
buttons: { "Turn on the light" => "command:Apartment_Light:ON" }
end
end
```

:::

::::
Binary file modified bundles/org.openhab.io.openhabcloud/doc/configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7475e5d

Please sign in to comment.