Update 107.md

This commit is contained in:
Vlad Stan 2023-10-24 17:11:18 +03:00 committed by GitHub
parent 80b56485a2
commit 0b2bc68313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

54
107.md
View File

@ -33,21 +33,16 @@ The `device` can also push data such as sensor readings and updates.
A `device` can publish any of the events described in [NIP-91 Event Kinds](https://github.com/nostr-protocol/nips/blob/iot/91.md#event-kinds). A `device` can publish any of the events described in [NIP-91 Event Kinds](https://github.com/nostr-protocol/nips/blob/iot/91.md#event-kinds).
A `user` can publish these event kinds: A `user` can publish these event kinds:
| Kind | | Description | NIP | | Kind | | Description | NIP |
|--------|----------|-------------------------------|-----------------------------------------------------------------------------------------| |---------|----------|-------------------------------|-----------------------------------------------------------------------------------------|
| `8000` | `intent` | Trigger an action on a device | [NIP-91 Event Kinds](https://github.com/nostr-protocol/nips/blob/iot/91.md#event-kinds) | | `30107` | `config` | Configure a device | [NIP-107 Configure Device Event](https://github.com/arcbtc/nips/edit/nip_107/107.md#configure-device-event) |
| `8000` | `intent` | Trigger an action on a device | [NIP-91 Event Kinds](https://github.com/nostr-protocol/nips/blob/iot/91.md#event-kinds) |
The content of events can be transmitted in clear text (for public data) or as [NIP-59 Gift Wrap](https://github.com/staab/nips/blob/NIP-59/59.md). The content of events can be transmitted in clear text (for public data) or as [NIP-59 Gift Wrap](https://github.com/staab/nips/blob/NIP-59/59.md).
## Intent Events ### Configure Device Event (`kind: 30107`)
Intent Events represent different actions that can be performed on a device. These actions can be triggered by a `user` or by another `device`. The content of the event is a `JSON` which `MUST` have a `type` field indicating the what the JSON represents. Possible types: This message is sent by an admin `user` to a `device`. The `device` saves the config locally and then uses it.
| Message Type | Sent By | Description |
|--------------|----------------|------------------|
| 0 | User | Configure Device |
### Configure Device
This message is sent by a `user` to a `device`. The `device` saves the config locally and then uses it.
**Event Content**: **Event Content**:
```json ```json
@ -61,6 +56,7 @@ This message is sent by a `user` to a `device`. The `device` saves the config lo
"intents_from_pubkeys":[ [<String (optional), user public-key>]], "intents_from_pubkeys":[ [<String (optional), user public-key>]],
"publish_on_change": <Boolean (optional, default `true`), publish event each time a sensor value changes>, "publish_on_change": <Boolean (optional, default `true`), publish event each time a sensor value changes>,
"publish_interval": <Integer (optional), publish the sensor value at regular intervals (regardless the value changes or not). The value is in `millisecods`.> "publish_interval": <Integer (optional), publish the sensor value at regular intervals (regardless the value changes or not). The value is in `millisecods`.>
"unix_time": <Integer (optional), set system time in `millisecods`.>
} }
``` ```
@ -70,18 +66,30 @@ This message is sent by a `user` to a `device`. The `device` saves the config lo
| `publish_to_pubkeys` | List of public keys to which events are published. | | `publish_to_pubkeys` | List of public keys to which events are published. |
| `actions_from_pubkeys` | List of public keys that are allowed to trigger an action on this device.<br/> The `admin_pubkeys` implicitly have the `actions_from_pubkeys` permissions. | | `actions_from_pubkeys` | List of public keys that are allowed to trigger an action on this device.<br/> The `admin_pubkeys` implicitly have the `actions_from_pubkeys` permissions. |
### Event: Update a `device`
**Event Content**: > [!IMPORTANT]
> The content of the `30107` event should be encrypted if the user chooses the "encrypted" mode
**Event Tags**:
```json ```json
{ "tags": [["d", <String, pubkey of the configured device]]
"id": <String, UUID generated by the user. Sequential IDs (`0`, `1`, `2`...) are discouraged>, ```
"device_id": <String, UUID of the stall to which this device belong to>, - the `d` tag is required, its value MUST be the same as the pubkey of the `device`.
"settings":[ [<String (optional), user public-key>]]
}
### Intent Events (`kind: 8000`)
Intent Events represent different actions that can be performed on a device. These actions can be triggered by a `user` or by another `device`.
The content of the event is a `JSON` array
```json
[[8001, true], [8003, 20.9]]
``` ```
Note:
- `settings`: **Event Tags**:
- Standard `settings` include: ```json
- eg: `[["on", <bool>], ["range", <int, 0-1000>], ["timer_on", <int unix timestamp>], ["timer_off", <int unix timestamp>]]` "tags": [["d", <String, pubkey of the configured device]]
```
- the `d` tag is required, its value MUST be the same as the pubkey of the `device`.