akki76

home.rules

May 8th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import org.openhab.model.script.actions.*
  2. import org.openhab.core.library.types.*
  3. import java.util.*
  4.  
  5. rule "voice"
  6.  
  7. when
  8. Item VoiceCommand received command
  9. then
  10. var String command = VoiceCommand.state.toString.toLowerCase
  11. logInfo("Voice.Rec","VoiceCommand received "+command)
  12.  
  13. if (command.contains("turn on fan") || (command.contains("turn on the fan"))) {
  14. fan.sendCommand(ON)
  15. }
  16. else if (command.contains("turn off fan") || (command.contains("turn off the fan"))) {
  17. fan.sendCommand(OFF)
  18. }
  19. else if (command.contains("turn off light") || (command.contains("turn off the light"))) {
  20. light.sendCommand(OFF)
  21. }
  22. else if (command.contains("turn on light") || (command.contains("turn on the light"))) {
  23. light.sendCommand(ON)
  24. }
  25. else if (command.contains("turn on night lamp") || (command.contains("turn on the night lamp"))) {
  26. night_light.sendCommand(ON)
  27. }
  28. else if (command.contains("turn off night lamp") || (command.contains("turn off the light lamp"))) {
  29. night_light.sendCommand(OFF)
  30. }
  31. else if (command.contains("turn on exhaust fan") || (command.contains("turn on the exhaust fan"))) {
  32. exhaust.sendCommand(ON)
  33. }
  34. else if (command.contains("turn off exhaust fan") || (command.contains("turn off the exhaust fan"))) {
  35. exhaust.sendCommand(OFF)
  36. }
  37. end
Add Comment
Please, Sign In to add comment