mirror of
https://github.com/XiaoMi/ha_xiaomi_home.git
synced 2025-11-21 11:38:58 +08:00
Created Feed, start cooking, play text and execute text directive (markdown)
80
Feed,-start-cooking,-play-text-and-execute-text-directive.md
Normal file
80
Feed,-start-cooking,-play-text-and-execute-text-directive.md
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
## Problem Description
|
||||||
|
|
||||||
|
There are no UI entries to
|
||||||
|
- feed in a fish tank or a pet feeder
|
||||||
|
- start cooking in a cooker or a health pot
|
||||||
|
- play text or execute text directive in an intelligent WiFi speaker.
|
||||||
|
|
||||||
|
## Reason
|
||||||
|
|
||||||
|
The device functions of feeding, starting cooking, playing text and executing text directive are defined as actions with parameters in MIoT-Spec-V2 protocol. The "in" field of the action instance is an array of the action's input parameters. The elements of the "in" field array indicate the piids of the properties in the same service. For example, if the "in" field of siid=7 aiid=4 action is [2,3], it means that the action has two input parameters, and the first parameter is the value of piid=2 property in siid=7 service while the second parameter is the value of piid=3 property in siid=7 service. The input parameter order is the same as the element order of the "in" field array.
|
||||||
|
|
||||||
|
The MIoT-Spec-V2 action with input parameters is converted to the Notify entity in Home Assistant. You can use the Notify entity in the automation action to send the command message to the device.
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/673dd8c8-8a7e-4493-b16b-3cfe5c5685ce" alt="Add a new automation">
|
||||||
|
<br>
|
||||||
|
<em>Figure 1: Add a new automation action of notification</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
The message is a JSON array in which every element must follow the format and the order of the parameters of the MIoT-Spec-V2 action instance.
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/d852b729-79f3-4007-8539-7441638941cd" alt="Add a new automation">
|
||||||
|
<br>
|
||||||
|
<em>Figure 2: Choose entity and set the message</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
The input parameters' format and order can be found in the Notify entity attributes pane.
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/71a2d04e-bb1b-4497-85c2-30edfcfc2c72" alt="Action attribute">
|
||||||
|
<br>
|
||||||
|
<em>Figure 3: Action input parameters' format and order</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Checking the option `xiaomi_home > CONFIGURE > Debug mode for action`, a Text entity will be generated alongside the Notify entity. You can use the Text entity to send the command message to the device and verify whether it is correct. Press **Enter** in the Text entity to activate sending message to the device.
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/11ba9253-7089-41cb-845d-c69ce9745780" alt="Text entity">
|
||||||
|
<br>
|
||||||
|
<em>Figure 4: Text entity in debug mode for action</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
### Feed
|
||||||
|
For example, [xiaomi.feeder.pi2001](http://poc.miot-spec.srv/miot-spec-v2/instance?type=urn:miot-spec-v2:device:pet-feeder:0000A06C:xiaomi-pi2001:3) siid=2 aiid=1 is "Pet Food Out" action. Its "in" field is [**8**], meaning that **piid=8** "Feeding Measure" property in siid=2 service is the only input parameter of this action. The value of this property is the amount of food to be fed. It is an integer value in the range of 0 to 150. So the input can be [50].
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/d0f1181c-f472-4b8b-aef1-84d75cc7b61b" alt="Text entity for feeding">
|
||||||
|
<br>
|
||||||
|
<em>Figure 5: Feed the pet with a certain food measure</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
### Start cooking
|
||||||
|
For example, [xiaomi.health_pot.p1v2](http://poc.miot-spec.srv/miot-spec-v2/instance?type=urn:miot-spec-v2:device:health-pot:0000A051:xiaomi-p1v2:1) siid=2 aiid=1 is "Start Cook" action. Its "in" field is [**3**], meaning that **piid=3** "Mode" property in siid=2 service is the only input parameter of this action. The value of this property is the cooking mode. It is an integer value restricted to a value list. The input can be [4], specifying the cooking mode as "Green Tea".
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/74b990e1-ecb7-4d0e-b2f2-3ce97def93c1" alt="Text entity for cooking">
|
||||||
|
<br>
|
||||||
|
<em>Figure 6: Start cooking with the selected cooking mode</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
### Play text
|
||||||
|
For example, [xiaomi.wifispeaker.l05b](http://poc.miot-spec.srv/miot-spec-v2/instance?type=urn:miot-spec-v2:device:speaker:0000A015:xiaomi-l05b:1) siid=5 aiid=3 is "Play Text" action. Its "in" field is [**1**], meaning that **piid=1** "Text Content" property in siid=5 service is the only input parameter of this action. The value of this property is the text content to be played. It is a string value. The input can be ["Hello world!"].
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/ae158ebe-2102-490b-a5df-809db958d5f8" alt="Text entity for playing">
|
||||||
|
<br>
|
||||||
|
<em>Figure 7: Play text content</em>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
### Execute text directive
|
||||||
|
For example, [xiaomi.wifispeaker.l05b](http://poc.miot-spec.srv/miot-spec-v2/instance?type=urn:miot-spec-v2:device:speaker:0000A015:xiaomi-l05b:1) siid=5 aiid=4 is "Execute Text Directive" action. Its "in" field is [**1**,**2**], meaning that **piid=1** "Text Content" property in siid=5 service is the first input parameter of the action and **piid=2** "Silent Execution" property in siid=5 service is the second input parameter of the action. siid=5 piid=1 property is a string value. siid=5 piid=2 property is a bool value. So the input can be ["Turn on the light",true].
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://github.com/user-attachments/assets/53f47978-ac1a-4cf5-ab83-d7175d712af0" alt="Text entity for executing">
|
||||||
|
<br>
|
||||||
|
<em>Figure 8: Execute text directive in silence</em>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user