Uploading net meter to pvoutput to get consumption.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rsilvers
    Junior Member
    • Apr 2016
    • 246

    #16
    I put the SDR on my Macbook and drove to pick up my kids at school. In the 8 minute drive I logged the kWh of over 300 utility meters. And I am not in the city - this is on a rural road. I should do it again next month and see what everyone's monthly consumption is. You can import to Excel, sort, and then remove duplicates.

    Interval is 15 seconds for my meter. But some are 30 seconds. Here is some output:

    2016-09-08T14:07:21.324314645-04:00,0,0,42396914,5,0x1,0x0,3733475,0xe7b6
    2016-09-08T14:07:21.712437182-04:00,0,0,42638296,5,0x1,0x1,6345075,0x1f00
    2016-09-08T14:07:22.323618024-04:00,0,0,65524437,12,0x2,0x0,134092,0xe6e3
    2016-09-08T14:07:22.601612163-04:00,0,0,42395970,5,0x0,0x0,1854720,0x939b
    2016-09-08T14:07:22.656200615-04:00,0,0,42396914,5,0x1,0x0,3733475,0xe7b6
    2016-09-08T14:07:23.213151073-04:00,0,0,1432172,4,0x0,0x2,25831,0x86ed
    2016-09-08T14:07:23.323982464-04:00,0,0,42638296,5,0x1,0x1,6345076,0x6d68
    2016-09-08T14:07:24.324863343-04:00,0,0,42638233,5,0x0,0x0,3319992,0x4604
    2016-09-08T14:07:24.547051084-04:00,0,0,42395970,5,0x0,0x0,1854720,0x939b
    2016-09-08T14:07:24.656547086-04:00,0,0,42638296,5,0x1,0x1,6345076,0x6d68
    2016-09-08T14:07:24.768129126-04:00,0,0,42396914,5,0x1,0x0,3733475,0xe7b6
    2016-09-08T14:07:26.545333575-04:00,0,0,44832551,7,0x0,0x0,1671103,0xdeb1
    2016-09-08T14:07:26.602241529-04:00,0,0,4382647,8,0x0,0x2,12079,0xe1b
    2016-09-08T14:07:26.991152112-04:00,0,0,42396914,5,0x1,0x0,3733475,0xe7b6
    2016-09-08T14:07:27.04693776-04:00,0,0,42395970,5,0x0,0x0,1854720,0x939b
    2016-09-08T14:07:27.156645697-04:00,0,0,42638296,5,0x1,0x1,6345077,0x8f8a
    2016-09-08T14:07:27.936022401-04:00,0,0,4382647,8,0x0,0x2,12079,0xe1b
    2016-09-08T14:07:28.324144943-04:00,0,0,42395970,5,0x0,0x0,1854720,0x939b

    Comment

    • rsilvers
      Junior Member
      • Apr 2016
      • 246

      #17
      It is uploading to pvoutput now. I am surprised there has not been more talk of this $20 solution. In my case, with my three main power panels, I would have had to spend at least $400 to do this with something off-the-shelf.

      Comment

      • rsilvers
        Junior Member
        • Apr 2016
        • 246

        #18
        I have rtlamr logging to a file in .csv format.

        Then I have a Ruby program reading that file, and uploading it whenever there is a change in the meter reading. My friend wrote it, not me.

        Eventually the log will fill the filesystem, but that will take over 200 days.

        This will break if my meter goes above 50 MWh due to how it handles values under 0 that are in the 99999 range. But that should never happen due to having solar production. Even if I didn't have production, it would be about two years.

        #!/usr/bin/ruby2.1

        require 'rb-inotify'
        require 'date'
        require 'open-uri'

        logfile = "/home/pi/amr.log"

        class PVReporter
        APIKey = "put_key_here"
        SystemID = "put_id_here"

        def initialize(logfile)
        @logfile = logfile
        @cur_consumption = nil
        @cur_consumption_start_ts = nil
        @state = :startup
        end

        def run
        File.open(@logfile, "r") do |f|
        while line = f.gets
        process(line)
        end

        queue = INotify::Notifier.new
        queue.watch(@logfile, :modify) do
        while line = f.gets
        process(line)
        end
        end
        queue.run
        end
        end

        def process(line)
        cols = line.split(",")
        ts, id, consumption = DateTime:arse(cols[0]), cols[3], cols[7].to_i

        return if id != "put_meter_id_here"

        if consumption > 50000
        consumption -= 100000
        end

        if @state == :startup
        @cur_consumption = consumption
        @state = :init
        elsif @state == :init
        if consumption != @cur_consumption
        @cur_consumption_start_ts = ts
        @cur_consumption = consumption
        @state = :active
        end
        elsif @state == :active
        if consumption != @cur_consumption
        record(consumption - @cur_consumption, ts, @cur_consumption_start_ts)
        @cur_consumption = consumption
        @cur_consumption_start_ts = ts
        end
        end
        end

        def record(kwh, ts, start_ts)
        h = (ts - start_ts) * 24
        w = (kwh / h * 1000).to_f.round
        puts "#{ts}, #{w}"
        url = "http://pvoutput.org/service/r2/addstatus.jsp?d=#{ts.strftime("%Y%m%d")}&t=#{ts.st rftime("%R")}&v4=#{w}&n=1"
        puts url
        resp = open(url, "X-Pvoutput-Apikey" => APIKey, "X-Pvoutput-SystemId" => SystemID).read
        puts resp
        end
        end

        r = PVReporter.new(logfile)
        r.run
        Last edited by rsilvers; 09-09-2016, 01:37 AM.

        Comment

        • shocksofmighty
          Junior Member
          • May 2016
          • 23

          #19
          Are you filtering out the ID of your meter from the command line? This seems to be an option:
          Usage of rtlamr: ...
          -filterid=: display only messages matching an id in a comma-separated list of ids.

          Comment

          • rsilvers
            Junior Member
            • Apr 2016
            • 246

            #20
            I am not because I have never received another meter from my home, but you should probably do: rtlamr -format=csv -logfile=amr.log -quiet=true -filterid=METER_NUMBER

            That code is going to change - my friend found some problems with it and has to make it upload at 15 minute intervals.
            Last edited by rsilvers; 09-09-2016, 03:39 PM.

            Comment

            • shocksofmighty
              Junior Member
              • May 2016
              • 23

              #21
              Sadly, I realized that I have the Focus AX-SD, which uses an entirely different protocol.

              Comment

              Working...