Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 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|TargetHeatingCoolingState )
  22. if [ $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.info.state') = '"off"' ]; then
  23. echo 0
  24. else
  25. case $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.info.mode') in
  26. '"heat"' )
  27. echo 2
  28. ;;
  29. '"cool"' )
  30. echo 1
  31. ;;
  32. '"fan"' )
  33. echo 0
  34. ;;
  35. '"dry"' )
  36. echo 0
  37. ;;
  38. esac
  39. fi
  40. ;;
  41. #damper open/closed = switch on/off = 1/0
  42. On )
  43. if [ $(curl -s http://$ip/getSystemData | jq '.aircons.ac1.zones.z01.state') = '"open"' ]; then
  44. echo 1
  45. else
  46. echo 0
  47. fi
  48. ;;
  49. esac
  50. fi
  51.  
  52. if [ "$1" = "Set" ]; then
  53. case "$3" in
  54. TargetHeatingCoolingState )
  55. case "$4" in
  56. 0 )
  57. curl -g http://$ip/setAircon?json={"ac1":{"info":{"state":"off"}}}
  58. ;;
  59.  
  60. 1 )
  61. curl -g http://$ip/setAircon?json={"ac1":{"info":{"state":"on"",""mode":"heat"}}}
  62. ;;
  63.  
  64. 2 )
  65. curl -g http://$ip/setAircon?json={"ac1":{"info":{"state":"on"",""mode":"cool"}}}
  66. ;;
  67. esac
  68. ;;
  69.  
  70. TargetTemperature )
  71. curl -g http://$ip/setAircon?json={"ac1":{"info":{"setTemp":"$4"}}}
  72. ;;
  73.  
  74. On )
  75. if [ "$4" = "true" ]; then
  76. curl -g http://$ip/setAircon?json={"ac1":{"zones":{"z01":{"state":"open"}}}}
  77. else
  78. curl -g http://$ip/setAircon?json={"ac1":{"zones":{"z01":{"state":"close"}}}}
  79. fi
  80. ;;
  81. esac
  82. fi
  83. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement