mirror of
https://github.com/nostr-protocol/nips.git
synced 2024-12-23 00:45:53 -05:00
Update 107.md
This commit is contained in:
parent
80b56485a2
commit
0b2bc68313
50
107.md
50
107.md
|
@ -34,20 +34,15 @@ A `device` can publish any of the events described in [NIP-91 Event Kinds](https
|
|||
A `user` can publish these event kinds:
|
||||
|
||||
| Kind | | Description | NIP |
|
||||
|--------|----------|-------------------------------|-----------------------------------------------------------------------------------------|
|
||||
|---------|----------|-------------------------------|-----------------------------------------------------------------------------------------|
|
||||
| `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).
|
||||
|
||||
## Intent Events
|
||||
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:
|
||||
|
||||
| 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.
|
||||
### Configure Device Event (`kind: 30107`)
|
||||
This message is sent by an admin `user` to a `device`. The `device` saves the config locally and then uses it.
|
||||
|
||||
**Event Content**:
|
||||
```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>]],
|
||||
"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`.>
|
||||
"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. |
|
||||
| `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
|
||||
{
|
||||
"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>,
|
||||
"settings":[ [<String (optional), user public-key>]]
|
||||
}
|
||||
"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`.
|
||||
|
||||
|
||||
### 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`:
|
||||
- Standard `settings` include:
|
||||
- eg: `[["on", <bool>], ["range", <int, 0-1000>], ["timer_on", <int unix timestamp>], ["timer_off", <int unix timestamp>]]`
|
||||
|
||||
**Event Tags**:
|
||||
```json
|
||||
"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`.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user