美的电饭煲oh代码(美的电饭煲OH代表什么)

未命名 访客 2023-07-14 10:27 410 0

以下是美的电饭煲的OH代码:

美的电饭煲oh代码(美的电饭煲OH代表什么)

items:

Number RiceCooker_Timer "计时器" {channel="mihome:xiaomi-miio-device:123456789:power", expire="10m,command=OFF"}

Switch RiceCooker_Mode "模式" {channel="mihome:xiaomi-miio-device:123456789:mode"}

Number RiceCooker_Status "状态" {channel="mihome:xiaomi-miio-device:123456789:status"}

rules:

rule "设置计时器"

when

Item RiceCooker_Timer received command

then

if(receivedCommand!=OFF){

val riceCookerCommand = newArrayList(

createMiIoCommand("set_power", "on"),

createMiIoCommand("set_timer", receivedCommand.toString())

)

sendCommand("mihome:xiaomi-miio-device:123456789:power", riceCookerCommand.toString)

}

rule "设置模式"

when

Item RiceCooker_Mode received command

then

val riceCookerCommand = newArrayList(

createMiIoCommand("set_mode", receivedCommand.toString())

)

sendCommand("mihome:xiaomi-miio-device:123456789:mode", riceCookerCommand.toString)

rule "查询状态"

when

Time cron "0 0/5 * * * ?"

then

val riceCookerCommand = newArrayList(

createMiIoCommand("get_prop", "mode,timer,pressure,switch"),

createMiIoCommand("get_status")

)

sendCommand("mihome:xiaomi-miio-device:123456789:status", riceCookerCommand.toString)

以上代码实现了设置和查询电饭煲的计时器、模式和状态。其中计时器和模式通过发送命令到米家设备,状态查询定时向米家设备发送查询命令来更新电饭煲状态。用户可以通过OpenHAB App或语音助手来操作美的电饭煲的相关功能。