Sha256: 6b86c005bcaa3f3d5cfcd3ac8b19ad7616fbc546cbc93ea628fa3fd1a514e0f4

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

#!/usr/bin/env ruby

require 'jfy/client'
require 'pvoutput/client'
require 'awesome_print'
require 'yaml'

pvoutput_config = YAML.load_file('/etc/jfy_collector/pvoutput.yaml')

params = {}
params[:serial_port] = ARGV[0] if ARGV[0]

jfy = Jfy::Client.new params

retries = 0

begin
  puts 'Re Register'
  jfy.re_register

  puts 'Offine Query'
  serial = jfy.offline_query
rescue Jfy::BadPacket, Jfy::ReadTimeout => e
  puts "Bad Packet #{e} ... Retrying" if @debug
  puts if @debug
  retries += 1
  exit if retries > 5
  retry
end

serial_num = 0x02
jfy.register(serial, serial_num)

puts 'Inverter Info'
data = jfy.query_inverter_info(serial_num)
ap data

# puts 'Set Info'
# data = jfy.query_set_info(serial_num)
# ap data

pvoutput = PVOutput::Client.new(pvoutput_config[:system_id], pvoutput_config[:api_key])

loop do
  data = jfy.query_normal_info(serial_num)

  puts
  puts '-------------------------'
  puts
  puts "Time: #{Time.now}"
  puts
  puts 'Realtime:'
  puts "  Temp: #{data[:temperature]} C"
  puts "  V: #{data[:voltage].join('/')} V"
  puts "  I: #{data[:current].join('/')} A"
  puts "  P: #{data[:power][:now]} W"
  puts
  puts 'Total:'
  puts "  Power (today): #{data[:power][:today]} kWH"
  puts "  Power (all time): #{data[:power][:total]} kWH"
  puts "  Run Time: #{data[:hours]} Hours"
  puts

  pvoutput.add_status(
    :energy_generated => data[:power][:today],
    :power_generated  => data[:power][:now],
    :temperature      => data[:temperature],
    :voltage          => data[:voltage].first,
  )

  sleep(60 * 5)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jfy_collector-0.1.2 exe/jfy_collector
jfy_collector-0.1.1 exe/jfy_collector