Configuration file for dwm-bar on macbook air
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.

55 lines
1.7 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #!/bin/bash
  2. # This module can get data from a SMA Inverter.
  3. # Its purpose is to show you how much Watts are being produced
  4. # To make it work change the INVERTER_IP variable and your User password
  5. # Vincenzo Petrolo <vincenzo.petrolo99@gmail.com>
  6. # For infos on how i made it, and help or bugs, you cant contact me or
  7. # open an issue
  8. # GNU GPLv3
  9. # P.s: Be careful when trying to modify urls, as they contains special
  10. # characters that may change the behaviour of the query
  11. dwm_solar_panel () {
  12. INVERTER_IP="YOUR INVERTER IP"
  13. PASSWORD="YOUR PASSWORD"
  14. if [[ -f ~/.cache/solar_panel.cache ]];
  15. then
  16. read SID < ~/.cache/solar_panel.cache
  17. if [ "$SID" == "null" ];
  18. then
  19. #Getting session id
  20. SID=$( curl -s --location --request POST "http://$INVERTER_IP/dyn/login.json" \
  21. --header 'Content-Type: text/plain' \
  22. --data-raw "{\"right\":\"usr\",\"pass\":\""$PASSWORD\""}" | jq .result.sid)
  23. SID=${SID//\"}
  24. fi
  25. #checks if it got a session token
  26. if [ "$SID" != "" ] && [ "$SID" != "null" ];
  27. then
  28. echo $SID > ~/.cache/solar_panel.cache
  29. WATTS=$(curl -s --location --request POST "http://$INVERTER_IP/dyn/getValues.json?sid=$SID" \
  30. --header 'Content-Type: text/plain' \
  31. --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')
  32. if [ "$WATTS" == "" ] || [ "$WATTS" == "null" ];
  33. then
  34. echo "null" > ~/.cache/solar_panel.cache
  35. else
  36. printf "%s💡 $WATTS W %s" "$SEP1" "$SEP2"
  37. fi
  38. fi
  39. else
  40. touch ~/.cache/solar_panel.cache
  41. echo "null" > ~/.cache/solar_panel.cache
  42. fi
  43. }
  44. dwm_solar_panel