Advertisement
Guest User

Untitled

a guest
Dec 19th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. !/bin/sh
  2.  
  3. hex=`echo $1 | tr '[:lower:]' '[:upper:]'`
  4.  
  5. a=`echo $hex | cut -c-2`
  6. b=`echo $hex | cut -c3-4`
  7. c=`echo $hex | cut -c5-6`
  8. r=`echo "ibase=16; $a" | bc`
  9. g=`echo "ibase=16; $b" | bc`
  10. b=`echo "ibase=16; $c" | bc`
  11.  
  12. #post to pimatic
  13. #generate value to variable, seperated by a comma
  14. value=$r','$g','$b
  15. #pimatic username
  16. user=yourusername
  17. #pimatic password
  18. password=yourpassword
  19. #variable you want to change
  20. variable=test
  21. #pimatic ip address
  22. pimaticip=192.168.0.0
  23.  
  24. #do the actual variable change through patching
  25. curl -s -X PATCH --header "Content-Type:application/json" --data '{"type": "value", "valueOrExpression": "'$value'"}' --user "$user:$password" http://$pimaticip/api/variables/$variable > /dev/null
  26.  
  27. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement