Created
December 2, 2020 21:22
-
-
Save ErikDeBruijn/048b59f2baf0eab89c2d81a62258ce6c to your computer and use it in GitHub Desktop.
Bitbar plugin for live stats for solar power generation and EV charging in Culemborg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#BitBar Metadata | |
# <bitbar.title>Power generation and supply to chargers</bitbar.title> | |
# <bitbar.version>v0.1</bitbar.version> | |
# <bitbar.author>Erik de Bruijn</bitbar.author> | |
# <bitbar.author.github>Erik de Bruijn</bitbar.author.github> | |
# <bitbar.desc>Displays the power output of the solar array and supply to the charging stations.</bitbar.desc> | |
require 'net/http' | |
require 'uri' | |
require 'json' | |
def fetch_from_pi | |
url1 = "https://d83001ea56a0e97eb94c603211f6b38f.balena-devices.com/node-red/powerNow" | |
JSON.parse(Net::HTTP.get(URI(url1))) | |
rescue | |
nil | |
end | |
last_update_time, pac, pdc, uac, udc, yield_day, yield_yesterday, yield_month, yield_year, yield_total, cons_pac, cons_yield_day, cons_yield_yesterday, cons_yield_month, cons_yield_year, cons_yield_total, total_power, * = fetch_from_pi.values | |
puts "☀️️️ #{(pac/1000).round(1)} kW (#{(yield_day/1000).round} kWh) 🚗 #{(cons_pac/1000).round(1)} kW (#{(yield_yesterday/1000).round} kWh)" | |
puts "---" | |
puts "DC: #{(pdc/1000).round(1)} kW" | |
puts "Yield: #{(yield_day/1000).round} kWh today, #{(yield_yesterday/1000).round} kWh yesterday" | |
puts "Consumption: #{(cons_yield_day/1000).round} kWh today, #{(cons_yield_yesterday/1000).round} kWh yesterday" | |
puts "Last updated #{last_update_time}" | |
puts "Show details | href=https://d83001ea56a0e97eb94c603211f6b38f.balena-devices.com/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment