Skip to content

Commit

Permalink
technical debt
Browse files Browse the repository at this point in the history
  • Loading branch information
e154 committed Jan 4, 2024
1 parent bc93e22 commit c737762
Show file tree
Hide file tree
Showing 23 changed files with 668 additions and 237 deletions.
51 changes: 41 additions & 10 deletions doc/content/en/docs/dashboard/automation/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,51 @@ description: >

{{< figure src="/smart-home/tasks_window1.png" >}}

&nbsp;
### Automation through Tasks in the Smart Home System

&nbsp;
The Smart Home system provides a powerful automation mechanism through the use of Tasks. Tasks are programmatic scenarios that are triggered in response to specific events, executed when conditions are met, and can impact devices in the home through a set of actions. This ensures flexibility and intelligence in managing a smart home.

Unfinished article
#### Components of a Task

### Configuration:
1. **Triggers:**
- **Event Definition:** A task begins execution in response to specific events, such as changes in the state of a device, temporal events, sensors, and other external factors.
- **Example:** Initiating a task when a door is opened, when there's motion in a room, on a schedule, etc.

2. **Conditions:**
- **Execution Logic:** A task can contain conditions that determine whether actions should be executed based on the current state of the system.
- **Example:** Execute actions only if the room temperature is above a certain threshold.

### Commands:
* Arbitrary set
3. **Actions:**
- **Device Management:** A task can influence devices in the system by changing their states, issuing commands, and performing other actions.
- **Example:** Turn on the lights when there is motion in the corridor, send a notification when a door is open.

### Attributes:
* Arbitrary set
#### Advantages of Automation through Tasks

### Status:
* Arbitrary set
1. **Flexibility in Configuration:**
- Users can create complex automation scenarios by combining various triggers, conditions, and actions to suit their needs.

2. **Intelligent Scenarios:**
- Automatic response to events and changes in the system makes the smart home more intelligent, providing a personalized experience.

3. **Efficient Energy Consumption:**
- Automation can be configured to optimize energy consumption, such as turning off lights and heating when there are no people in the house.

4. **Management of Multiple Devices:**
- Tasks allow simultaneous control of multiple devices, creating complex scenarios.

5. **Ease of Use:**
- The intuitive interface of the Smart Home system makes it easy for both novice and experienced users to create and manage tasks.

#### Example of a Scenario through Tasks

1. **Scenario "Welcome":**
- **Triggers:**
- Upon opening the door.
- **Conditions:**
- If it is morning or daytime.
- **Actions:**
- Turn on the lights in the hallway.
- Start playing music on the audio system.
- Send a notification that someone has arrived.

This scenario demonstrates how a task can be used to automate welcoming actions upon opening the door during specific times of the day.
69 changes: 59 additions & 10 deletions doc/content/en/docs/dashboard/automation/triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,57 @@ description: >

{{< figure src="/smart-home/triggers_window1.png" >}}

&nbsp;
Triggers in the Smart Home system are key elements that initiate the execution of tasks in response to specific events or conditions. Currently, the system supports three main types of triggers, each with its advantages, providing flexibility in automation configuration.

&nbsp;
#### 1. **Trigger "State Change":**

Each type of trigger has its own handler for performing the corresponding actions.
- **Description:**
- Activates upon the change of the state of a specific device or group of devices in the Smart Home system.

Here are examples of different types of triggers and their respective handlers:
- **Advantages:**
- **Reacting to Changes:** Ideal for scenarios where specific reactions are needed, such as turning lights on/off, opening doors, etc.
- **Customization Flexibility:** Allows selecting specific devices and state parameters for triggering.

#### 2. **Trigger "System":**

- **Description:**
- Activates upon the occurrence of system events, such as system start/stop, device connection/disconnection, and other events on the system bus.

- **Advantages:**
- **System Monitoring:** Used for monitoring the overall system state and detecting events related to the functioning of the smart home.
- **Integration with External Systems:** Enables interaction with systems operating within the system bus.

#### 3. **Trigger "Time (Cron)":**

- **Description:**
- Activates at specified time intervals according to a schedule defined in cron format.

- **Advantages:**
- **Regular Execution:** Ideal for tasks that need to be executed regularly on a schedule.
- **Energy Savings:** Can be used to optimize energy consumption, such as turning off lights or heating during nighttime.

#### Examples of Trigger Usage

1. **Trigger "State Change":**
- **Scenario:**
- Turn on the air conditioner when the window in the bedroom is opened.
- **Trigger Configuration:**
- Device: Window in the bedroom.
- State: Open.

2. **Trigger "System":**
- **Scenario:**
- Send a notification upon connecting a new device to the system.
- **Trigger Configuration:**
- System Event: Connection of a new device.

3. **Trigger "Time (Cron)":**
- **Scenario:**
- Turn off the lights in all rooms after midnight.
- **Trigger Configuration:**
- Time Interval: "0 0 * * *" corresponding to every midnight.

#### Examples in Coffeescript

1. `TriggerAlexa`:
```coffeescript
Expand All @@ -24,7 +68,7 @@ automationTriggerAlexa = (msg) ->
Done p
return false
```
The `automationTriggerAlexa` handler is invoked in response to a trigger from Amazon Alexa. It takes the `msg` message object and can perform specific actions related to this trigger.
The `automationTriggerAlexa` handler is called in response to a trigger from Amazon Alexa. It takes the message object `msg` and can perform specific actions related to this trigger.

2. `TriggerStateChanged`:
```coffeescript
Expand All @@ -34,7 +78,8 @@ automationTriggerStateChanged = (msg) ->
Done p.new_state.state.name
return false
```
The `automationTriggerStateChanged` handler is called when the state of a device changes. It takes the `msg` message object and can perform specific actions based on the new state of the device.
The `automationTriggerStateChanged` handler is called when the state of a device changes. It takes the message object
`msg` and can perform specific actions based on the new state of the device.

3. `TriggerSystem`:
```coffeescript
Expand All @@ -43,7 +88,7 @@ automationTriggerSystem = (msg) ->
Done p.event
return false
```
The `automationTriggerSystem` handler is invoked in response to system events. It takes the `msg` message object and can perform specific actions related to this event.
The `automationTriggerSystem` handler is called in response to system events. It takes the message object `msg` and can perform specific actions related to this event.

4. `TriggerTime`:
```coffeescript
Expand All @@ -52,17 +97,21 @@ automationTriggerTime = (msg) ->
Done p
return false
```
The `automationTriggerTime` handler is called after a certain amount of time has passed. It takes the `msg` message object and can perform specific actions related to this time.
The `automationTriggerTime` handler is called after a specified period of time has elapsed. It takes the message object `msg` and can perform specific actions related to this time.

Each trigger handler can execute the necessary logic in response to the corresponding trigger and then return `false` to indicate that further processing is not required.
Each trigger handler can execute the necessary logic in response to the corresponding trigger and then return the value `false` to indicate that further processing is not required.

Example implementation:

```coffeescript
automationTriggerStateChanged = (msg) ->
automationTriggerStateChanged = (msg)->
#print '---trigger---'
p = msg.payload
if !p.new_state || !p.new_state.state
return false
return msg.new_state.state.name == 'DOUBLE_CLICK'
```

#### Conclusion

The use of different types of triggers in the Smart Home system allows users to create complex and intelligent automation scenarios that seamlessly respond to changes in the system and external events. This provides users with a personalized and efficient smart home experience.
32 changes: 24 additions & 8 deletions doc/content/en/docs/dashboard/gate/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,32 @@ description: >

---

Unfinished article
Gate Server in the Smart Home system is a key component that provides secure and convenient remote access to the smart home, even in the absence of a static IP address. This server enables users to control and monitor their home from anywhere in the world via the internet, ensuring data security and comfortable interaction.

### Configuration:
#### Advantages of the Gate Server in the Smart Home System

1. **Security:**
- **Data Encryption:** All data transmitted between devices and the Gate Server is encrypted to prevent unauthorized access.
- **Authentication:** Built-in authentication mechanisms ensure that only authorized users have access to the system.

### Commands:
* Arbitrary set
2. **Convenience of Remote Access:**
- **No White IP:** Users can connect to the system even without a static IP address, making remote access more convenient and accessible.

### Attributes:
* Arbitrary set
3. **Configuration Flexibility:**
- **Connect to Test Gateway:** Smart Home provides a built-in Gate client that can connect to a test gateway at https://gate.e154.ru:8443 for testing and configuring remote access.

### Status:
* Arbitrary set
4. **Scalability:**
- **Support for Multiple Devices:** The Gate Server is designed to handle simultaneous requests from multiple devices, ensuring system scalability.

#### Working with the Gate Client in the Smart Home System

1. **Setting Up the Gate Client:**
- Enable the Gate Server mode in the Smart Home system, specifying the address of the test gateway or setting up your Gate Server.
- Configure security parameters such as encryption and authentication.

2. **Connecting to the Gate Server:**
- The Gate client automatically establishes a secure connection with the Gate Server, without requiring a white IP address.
- Users can use mobile applications or the web interface for remote access.

3. **Secure Remote Management:**
- Users can control devices, monitor the home's status, and receive notifications even when away from home.
22 changes: 0 additions & 22 deletions doc/content/en/docs/dashboard/gate/client.md

This file was deleted.

22 changes: 0 additions & 22 deletions doc/content/en/docs/dashboard/gate/server.md

This file was deleted.

40 changes: 32 additions & 8 deletions doc/content/en/docs/plugins/mqtt_bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,40 @@ description: >

---

Unfinished article
The MQTT Bridge plugin provides functionality for integrating devices through the MQTT protocol. This plugin allows efficient data exchange between devices and the Smart Home system using an MQTT broker.

### Configuration:
#### Device Settings

Each device created using the MQTT Bridge plugin has the following settings:

### Commands:
* Arbitrary set
- **`keepAlive` (type: Int)**: The time in seconds after which the device sends a ping to maintain an active connection with the broker.

### Attributes:
* Arbitrary set
- **`pingTimeout` (type: Int)**: The time in seconds expected to receive a response to the ping from the broker.

### Status:
* Arbitrary set
- **`broker` (type: String)**: The address of the MQTT broker to which the device will connect.

- **`clientID` (type: String)**: The client identifier used when connecting to the broker.

- **`connectTimeout` (type: Int)**: The time in seconds allocated for establishing a connection with the broker.

- **`cleanSession` (type: Bool)**: A flag indicating whether to use a "clean" session when connecting.

- **`username` (type: String)**: The username for authentication when connecting to the broker.

- **`password` (type: Encrypted)**: The encrypted password for authentication when connecting to the broker.

- **`qos` (type: Int)**: The Quality of Service level for interacting with the broker.

- **`direction` (type: String)**: The direction of interaction (e.g., "inbound" or "outbound").

- **`topics` (type: String)**: A list of topics with which the device will interact.

#### Device Statuses

Each device created using the MQTT Bridge plugin can have the following statuses:

- **`connected`**: The device is successfully connected to the MQTT broker and ready for data exchange.

- **`offline`**: The device is not connected to the broker or has lost the connection.

These settings and statuses provide flexibility in integrating devices through the MQTT protocol, allowing easy configuration and monitoring of their state within the Smart Home system.
32 changes: 24 additions & 8 deletions doc/content/en/docs/plugins/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,32 @@ description: >

---

Unfinished article
The Node plugin is designed for the integration of external Node agents, providing the ability to work with Modbus devices on remote servers in the network or from other subnets. This plugin simplifies the connection and interaction with remote Modbus agents, expanding the functionality of the Smart Home system.

### Configuration:
#### Device Properties

- **`thread` (type: Int)**: Identifier of the thread in which the Node agent is operating.

### Commands:
* Arbitrary set
- **`rps` (type: Int)**: Number of requests per second (Requests Per Second) processed by the agent.

### Attributes:
* Arbitrary set
- **`min` (type: Int)**: Minimum response time from the agent in milliseconds.

### Status:
* Arbitrary set
- **`max` (type: Int)**: Maximum response time from the agent in milliseconds.

- **`latency` (type: Int)**: Delay between the request and response from the agent in milliseconds.

- **`startedAt` (type: Time)**: Time when the Node agent was started.

#### Device Settings

- **`node_login` (type: String)**: Login for authentication on the Node agent.

- **`node_pass` (type: String)**: Password for authentication on the Node agent.

#### Device Statuses

- **`wait` (type: String)**: The agent is waiting for connections and requests from the Smart Home system.

- **`connected` (type: String)**: Successful connection established with the Node agent.

- **`error` (type: String)**: An error occurred during the interaction with the Node agent.
Loading

0 comments on commit c737762

Please sign in to comment.