dwm-bar for archlinux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.3 KiB

4 years ago
  1. #!/bin/sh
  2. dwm_solar_panel () {
  3. if [[ -f ~/.cache/solar_panel.cache ]];
  4. then
  5. read SID < ~/.cache/solar_panel.cache
  6. if [ "$SID" == "null" ];
  7. then
  8. #Getting session id
  9. SID=`curl -s --location --request POST 'http://192.168.1.126/dyn/login.json' \
  10. --header 'Content-Type: text/plain' \
  11. --data-raw '{"right":"usr","pass":"ciao1234"}' | jq .result.sid`
  12. SID=${SID//\"}
  13. fi
  14. #checks if it got a session token
  15. if [ "$SID" != "" ] || [ "$SID" != "null" ];
  16. then
  17. echo $SID > ~/.cache/solar_panel.cache
  18. #get data, don't modify a single line of this url,except for the IP(192.168.1.126)
  19. WATTS=$(curl -s --location --request POST "http://192.168.1.126/dyn/getValues.json?sid=$SID" \
  20. --header 'Content-Type: text/plain' \
  21. --data-raw '{"destDev":[],"keys":["6100_00543100","6800_008AA200","6100_40263F00","6800_00832A00","6180_08214800","6180_08414900","6180_08522F00","6400_00543A00","6400_00260100","6800_08811F00","6400_00462E00"]}' | jq '.result."0156-76BC3EC6"."6100_40263F00"."1"[0].val')
  22. if [ "$WATTS" == "" ] || [ "$WATTS" == "null" ];
  23. then
  24. echo "null" > ~/.cache/solar_panel.cache
  25. else
  26. WATTC=`bc <<< "scale=3; $WATTS / 1000"`
  27. printf "%s💡 $WATTC W %s" "$SEP1" "$SEP2"
  28. fi
  29. fi
  30. else
  31. touch ~/.cache/solar_panel.cache
  32. echo "null" > ~/.cache/solar_panel.cache
  33. fi
  34. }
  35. dwm_solar_panel