Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # IP address
  4. ip="192.168.0.172:2025"
  5.  
  6. if [ "$1" = "Get" ]; then
  7. case "$3" in
  8.  
  9. CurrentTemperature )
  10. echo $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.zones.z01.measuredTemp')
  11. ;;
  12.  
  13. TargetTemperature )
  14. echo $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.info.setTemp')
  15. ;;
  16.  
  17. TemperatureDisplayUnits )
  18. echo 0
  19. ;;
  20.  
  21. CurrentHeatingCoolingState )
  22. if [ $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.info.mode') = '"cool"' ]; then
  23. echo 2
  24. elif [ $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.info.mode') = '"heat"' ]; then
  25. echo 1
  26. else
  27. echo 0
  28. fi
  29. ;;
  30.  
  31. #damper open/closed = switch on/off = 1/0
  32. On )
  33. if [ $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.zones.z01.state') = '"open"' ]; then
  34. echo 1
  35. else
  36. echo 0
  37. fi
  38. ;;
  39. esac
  40. fi
  41.  
  42. if [ "$1" = "Set" ]; then
  43. case "$3" in
  44. TargetHeatingCoolingState )
  45. case "$4" in
  46. 0 )
  47. curl -g http://$ip/setAircon?json={"ac1":{"info":{"state":"off"}}}
  48. ;;
  49.  
  50. 1 )
  51. curl -g http://$ip/setAircon?json={"ac1":{"info":{"state":"on"",""mode":"heat"}}}
  52. ;;
  53.  
  54. 2 )
  55. curl -g http://$ip/setAircon?json={"ac1":{"info":{"state":"on"",""mode":"cool"}}}
  56. ;;
  57. esac
  58. ;;
  59.  
  60. TargetTemperature )
  61. curl -g http://$ip/setAircon?json={"ac1":{"info":{"setTemp":"$4"}}}
  62. ;;
  63.  
  64. On )
  65. if [ "$4" = "true" ]; then
  66. curl -g http://$ip/setAircon?json={"ac1":{"zones":{"z01":{"state":"open"}}}}
  67. else
  68. curl -g http://$ip/setAircon?json={"ac1":{"zones":{"z01":{"state":"close"}}}}
  69. fi
  70. ;;
  71. esac
  72. fi
  73.  
  74. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement