def query_normal_info(serial_num)
      packet = Jfy::Packet.new(Jfy::Codes::QUERY_NORMAL_INFO, [], :dst => serial_num)
      packet = write(packet)

      fail(BadPacket, 'invalid query normal info response') unless packet.command == Jfy::Codes::QUERY_NORMAL_INFO_RESP

      data = packet.data

      modes = {
        [0x0, 0x0] => :wait,
        [0x0, 0x1] => :normal,
        [0x0, 0x2] => :warning,
        [0x0, 0x3] => :error,
      }
      mode = modes[data[24, 2]] || fail("Unkown mode #{data[24]} #{data[25]}")

      metrics = {
        :temperature => short(data, 0) / 10.0,
        :mode        => mode,
        :voltage     => [
          short(data, 2) / 10.0,
          short(data, 4) / 10.0,
          short(data, 6) / 10.0,
          # FIXME: Need to test on larger inverter
          # short(data, 28) / 10.0,
          # short(data, 30) / 10.0,
          # short(data, 32) / 10.0,
          # short(data, 40) / 10.0,
          # short(data, 42) / 10.0,
          # short(data, 44) / 10.0,
        ],
        :current     => [
          short(data, 8) / 10.0,
          short(data, 10) / 10.0,
          short(data, 12) / 10.0,
          # FIXME: Need to test on larger inverter
          # short(data, 34) / 10.0,
          # short(data, 36) / 10.0,
          # short(data, 38) / 10.0,
          # short(data, 46) / 10.0,
          # short(data, 48) / 10.0,
          # short(data, 50) / 10.0,
        ],
        :hours       => long(data, 18),
        :power       => {
          :total => long(data, 14) / 10.0 * 1_000,
          :today => short(data, 26) / 100.0 * 1_000,
          :now   => short(data, 22),
        },
      }

      if data.size > 68
        metrics.merge!(
          :fault => {
            :temperature => short(data, 114) / 10.0,
            :voltage     => [
              short(data, 116) / 10.0,
              short(data, 118) / 10.0,
              short(data, 120) / 10.0,
            ],
          },
        )
      end

      metrics
    end
def query_normal_info(serial_num)
      packet = Jfy::Packet.new(Jfy::Codes::QUERY_NORMAL_INFO, [], :dst => serial_num)
      packet = write(packet)

      fail(BadPacket, 'invalid query normal info response') unless packet.command == Jfy::Codes::QUERY_NORMAL_INFO_RESP

      data = packet.data

      modes = {
        [0x0, 0x0] => :wait,
        [0x0, 0x1] => :normal,
        [0x0, 0x2] => :warning,
        [0x0, 0x3] => :error,
      }
      mode = modes[data[24, 2]] || fail("Unkown mode #{data[24]} #{data[25]}")

      metrics = {
        :temperature => short(data, 0) / 10.0,
        :mode        => mode,
        :voltage     => [
          short(data, 2) / 10.0,
          short(data, 4) / 10.0,
          short(data, 6) / 10.0,
          # FIXME: Need to test on larger inverter
          # short(data, 28) / 10.0,
          # short(data, 30) / 10.0,
          # short(data, 32) / 10.0,
          # short(data, 40) / 10.0,
          # short(data, 42) / 10.0,
          # short(data, 44) / 10.0,
        ],
        :current     => [
          short(data, 8) / 10.0,
          short(data, 10) / 10.0,
          short(data, 12) / 10.0,
          # FIXME: Need to test on larger inverter
          # short(data, 34) / 10.0,
          # short(data, 36) / 10.0,
          # short(data, 38) / 10.0,
          # short(data, 46) / 10.0,
          # short(data, 48) / 10.0,
          # short(data, 50) / 10.0,
        ],
        :hours       => long(data, 18),
        :power       => {
          :total => long(data, 14) / 10.0 * 1_000,
          :today => short(data, 26) / 100.0 * 1_000,
          :now   => short(data, 22),
        },
      }

      if data.size > 68
        metrics.merge!(
          :fault => {
            :temperature => short(data, 114) / 10.0,
            :voltage     => [
              short(data, 116) / 10.0,
              short(data, 118) / 10.0,
              short(data, 120) / 10.0,
            ],
          },
        )
      end

      metrics
    end
rubocop:disable Metrics/AbcSize, Metrics/MethodLength