以下是美的电饭煲的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或语音助手来操作美的电饭煲的相关功能。
本文转载网络分享,文章版权归作者所有,网址:http://wenda.jfweb.cn/15835.html
免责声明:本文文章内容来源于网络由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本站中有涉嫌抄袭的内容,请发送邮件至:glmpjh@163.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。